1、说明:
在Oracle 12.1.0.1的Grid Infrastructure 的安装中,可以选择是否安装Grid Infrastructure Management Repository (GIMR) 数据库。
在Grid Infrastructure 12.1.0.2 中,已经没有改选项,MIMR 数据库已经变成了强制选项。
在Oracle 12c 中Management Database 用来存储Cluster HealthMonitor(CHM/OS,ora.crf) ,Oracle Database QoS Management,Rapid Home Provisioning和其他的数据。
ManagementRepository 是受12c Clusterware 管理的一个单实例,在Cluster 启动的时会启动MGMTDG并在其中一个节点上运行,并受GI 管理,如果运行MGMTDG的节点宕机了,GI 会自动把MGMTDB 转移到其他的节点上。
默认情况,MGMTDB 数据库的数据文件存放在共享的设备,如OCR/Voting 的磁盘组中,但后期可以移动位置。
在12.1.0.1 中,GIMR 是可选的,如果在安装GI的时候,没有选择Management Database 数据库,那么所有依赖的特性,如ClusterHealth Monitor (CHM/OS) 就会被禁用。
当然,在12.1.0.2 中,可以忽略这个问题,因为是强制安装GIMR了。
另外,对于MGMT 数据库,在目前的版本中,也不需要手工对其进行备份。
2、基本操作:[grid@testdb01 ~]$ crsctl status res -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATADG.dg
ONLINE ONLINE testdb01 STABLE
ONLINE ONLINE testdb02 STABLE
ora.FRADG.dg
ONLINE ONLINE testdb01 STABLE
ONLINE ONLINE testdb02 STABLE
ora.LISTENER.lsnr
ONLINE ONLINE testdb01 STABLE
ONLINE ONLINE testdb02 STABLE
ora.OCR_VOTE.dg
ONLINE ONLINE testdb01 STABLE
ONLINE ONLINE testdb02 STABLE
ora.asm
ONLINE ONLINE testdb01 Started,STABLE
ONLINE ONLINE testdb02 Started,STABLE
ora.net1.network
ONLINE ONLINE testdb01 STABLE
ONLINE ONLINE testdb02 STABLE
ora.ons
ONLINE ONLINE testdb01 STABLE
ONLINE ONLINE testdb02 STABLE
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE testdb02 STABLE
ora.LISTENER_SCAN2.lsnr
1 ONLINE ONLINE testdb01 STABLE
ora.LISTENER_SCAN3.lsnr
1 ONLINE ONLINE testdb01 STABLE
ora.MGMTLSNR
1 ONLINE ONLINE testdb01 169.254.82.227 10.2
.1.101,STABLE
ora.cvu
1 ONLINE ONLINE testdb01 STABLE
ora.proddb.db
1 ONLINE ONLINE testdb01 Open,STABLE
2 ONLINE ONLINE testdb02 Open,STABLE
ora.mgmtdb
1 ONLINE ONLINE testdb01 Open,STABLE
ora.oc4j
1 ONLINE ONLINE testdb01 STABLE
ora.testdb01.vip
1 ONLINE ONLINE testdb01 STABLE
ora.testdb02.vip
1 ONLINE ONLINE testdb02 STABLE
ora.scan1.vip
1 ONLINE ONLINE testdb02 STABLE
ora.scan2.vip
1 ONLINE ONLINE testdb01 STABLE
ora.scan3.vip
1 ONLINE ONLINE testdb01 STABLE
--------------------------------------------------------------------------------
以上,可以看到对应的监听和数据库资源,我们可以查看此数据库运行的状态,此数据库运行在其中的一个节点的grid用户下:
[grid@testdb01 ~]$ ps -fu grid|grep lsnr
grid 62806 1 0 19:02 ? 00:00:00 /u01/app/12.1.0/grid/bin/tnslsnr LISTENER_SCAN2 -no_crs_notify -inherit
grid 62836 1 0 19:02 ? 00:00:00 /u01/app/12.1.0/grid/bin/tnslsnr LISTENER_SCAN3 -no_crs_notify -inherit
grid 63881 1 0 19:03 ? 00:00:00 /u01/app/12.1.0/grid/bin/tnslsnr LISTENER -no_crs_notify -inherit
grid 77180 1 0 19:16 ? 00:00:00 /u01/app/12.1.0/grid/bin/tnslsnr MGMTLSNR -no_crs_notify -inherit
grid 172409 172125 0 21:48 pts/2 00:00:00 grep lsnr
[grid@testdb01 ~]$ ps -ef| grep pmon_-MGMTDB
grid 77223 1 0 19:16 ? 00:00:00 mdb_pmon_-MGMTDB
grid 172554 172125 0 21:48 pts/2 00:00:00 grep pmon_-MGMTDB
[grid@testdb01 ~]$ ps -ef| grep MGMTLSNR
grid 77180 1 0 19:16 ? 00:00:00 /u01/app/12.1.0/grid/bin/tnslsnr MGMTLSNR -no_crs_notify -inherit
grid 172601 172125 0 21:48 pts/2 00:00:00 grep MGMTLSNR
[grid@testdb01 ~]$ lsnrctl status MGMTLSNR
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 11-DEC-2016 21:48:39
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=MGMTLSNR)))
STATUS of the LISTENER
------------------------
Alias MGMTLSNR
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 11-DEC-2016 19:16:46
Uptime 0 days 2 hr. 31 min. 53 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/12.1.0/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/testdb01/mgmtlsnr/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=MGMTLSNR)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.2.1.101)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=169.254.82.227)(PORT=1521)))
Services Summary...
Service "-MGMTDBXDB" has 1 instance(s).
Instance "-MGMTDB", status READY, has 1 handler(s) for this service...
Service "_mgmtdb" has 1 instance(s).
Instance "-MGMTDB", status READY, has 1 handler(s) for this service...
Service "testdb_cluster" has 1 instance(s).
Instance "-MGMTDB", status READY, has 1 handler(s) for this service...
The command completed successfully
MGMT数据库的启动和关闭:
正常情况下,MGMTDB 会在GI 启动的时候,会自动启动,但也可以手工管理,直接使用srvctl 操作即可:
Usage: srvctl start mgmtdb[-startoption <start_option>] [-node <node_name>]
Usage: srvctl start mgmtlsnr [-node <node_name>]
查看Management Database 的log 和trace 文件:
一般情况下,是不需要查看MGMT DB的trace的,如果要查看,用如下命令:
[grid@testdb01 ~]$ cd /u01/app/grid/diag/rdbms/
[grid@testdb01 rdbms]$ ls
_mgmtdb
进入$ORACLE_BASE下的trace目录。但是进入-MGMTDB时,要注意,不能直接cd:
[grid@testdb01 rdbms]$ cd _mgmtdb/
[grid@testdb01 _mgmtdb]$ ls
i_1.mif -MGMTDB
[grid@testdb01 _mgmtdb]$ cd -MGMTDB/
-bash: cd: -M: invalid option
cd: usage: cd [-L|-P] [dir]
[grid@testdb01 _mgmtdb]$
必须使用./-MGMTDB,如:
[grid@testdb01 _mgmtdb]$ cd ./-MGMTDB
[grid@testdb01 -MGMTDB]$ ls
alert cdump hm incident incpkg ir lck log metadata metadata_dgif metadata_pv stage sweep trace
[grid@testdb01 -MGMTDB]$ cd trace/
[grid@testdb01 trace]$ pwd
/u01/app/grid/diag/rdbms/_mgmtdb/-MGMTDB/trace
[grid@testdb01 trace]$ ls
可以看到有trc和alert日志文件:
alert_-MGMTDB.log -MGMTDB_mmon_77336.trm -MGMTDB_mmon_77336.trc
MGMT DB 的日志和trace 都在这个里。
MGMTDB是带一个PDB的CDB数据库:
前面说了,MGMTDB 是一个实例,实际上,MGMTDB是带一个PDB的CDB库,我们可以使用GI的命令直接去操作MGMTDB 对应的PDB。
--查看MGMTDB当前节点:
[grid@testdb01 /]$ oclumon manage -get master
Master = rac1
--查看状态:
[grid@testdb01 /]$ srvctl status mgmtdb
Database is enabled
Instance -MGMTDB is running on node testdb01
--查看配置信息:
[grid@testdb01 /]$ srvctl config mgmtdb
Database unique name: _mgmtdb
Database name:
Oracle home: <CRS home>
Oracle user: grid
Spfile: +OCR_VOTE/_MGMTDB/PARAMETERFILE/spfile.268.930338123
Password file:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Type: Management
PDB name: pordb_cluster
PDB service: pordb_cluster
Cluster name: pordb-cluster
Database instance: -MGMTDB
--连接MGMTDB实例
[grid@testdb01 /]$ export ORACLE_SID=-MGMTDB
[grid@testdb01 /]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production onMon Dec 8 15:24:37 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise EditionRelease 12.1.0.1.0 - 64bit Production
With the Partitioning, Automatic StorageManagement and Advanced Analytics options
SQL> select file_name from dba_data_files union select member file_name from V$logfile;
FILE_NAME
--------------------------------------------------------------------------------
+OCR_VOTE/_MGMTDB/DATAFILE/sysaux.257.930337963
+OCR_VOTE/_MGMTDB/DATAFILE/system.258.930337985
+OCR_VOTE/_MGMTDB/DATAFILE/undotbs1.259.930338011
+OCR_VOTE/_MGMTDB/ONLINELOG/group_1.261.930338049
+OCR_VOTE/_MGMTDB/ONLINELOG/group_2.262.930338049
+OCR_VOTE/_MGMTDB/ONLINELOG/group_3.263.930338051
6 rows selected.
这里查询的是MGMTDB的路径,也可以直接用如下命令查询:
[grid@testdb01 /]$ oclumon manage -get reppath
CHM Repository Path = +OCR_VOTE/_MGMTDB/FD9B43BF6A646F8CE043B6A9E80A2815/DATAFILE/sysmgmtdata.269.930338235
--查询MGMTDB用户:
SQL> col username for a20;
SQL> select username,account_status from dba_users ;
USERNAME ACCOUNT_STATUS
-------------------- --------------------------------
ANONYMOUS EXPIRED & LOCKED
DBSNMP EXPIRED & LOCKED
WMSYS EXPIRED & LOCKED
XDB EXPIRED & LOCKED
APPQOSSYS EXPIRED & LOCKED
GSMADMIN_INTERNAL EXPIRED & LOCKED
GSMCATUSER EXPIRED & LOCKED
SYSBACKUP EXPIRED & LOCKED
OUTLN EXPIRED & LOCKED
DIP EXPIRED & LOCKED
SYSDG EXPIRED & LOCKED
USERNAME ACCOUNT_STATUS
-------------------- --------------------------------
ORACLE_OCM EXPIRED & LOCKED
SYSKM EXPIRED & LOCKED
XS$NULL EXPIRED & LOCKED
GSMUSER EXPIRED & LOCKED
AUDSYS EXPIRED & LOCKED
SYSTEM OPEN
SYS OPEN
18 rows selected.