1 MGMTDB 说明

 

在Oracle 12.1.0.1的Grid Infrastructure 的安装中,可以选择是否安装Grid Infrastructure Management Repository (GIMR) :MGMTDB. 如下图:

 

\

 

在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 MGMTDB 基本操作

 

2.1 查看Management DB 相关的资源:

[[email protected] ~]# crsctl stat res -t

--------------------------------------------------------------------------------

Name Target State Server Statedetails

--------------------------------------------------------------------------------

Local Resources

--------------------------------------------------------------------------------

……

ora.MGMTLSNR

1 ONLINE ONLINE rac2 169.254.142.79 192.1

68.57.6,STABLE

ora.mgmtdb

1 ONLINE ONLINE rac2 Open,STABLE

……

[[email protected] ~]#

使用crsctl 命令可以看到ora.mgmtdb和ora.MGMTLSNR。

 

在操作系统层面,也可以查看到有2个对应的进程:

[[email protected] ~]# ps -ef| grep pmon_-MGMTDB

grid 7452 1 0 14:59 ? 00:00:00 mdb_pmon_-MGMTDB

root 7756 7727 0 15:02 pts/4 00:00:00 grep pmon_-MGMTDB



[[email protected] ~]# ps -ef| grep MGMTLSNR

grid 7411 1 014:58 ? 00:00:00/u01/gridsoft/12.1.0/bin/tnslsnr MGMTLSNR -no_crs_notify -inherit

root 7758 7727 0 15:02 pts/4 00:00:00 grep MGMTLSNR

[[email protected] ~]#

 

2.2 启动和关闭MGMT

正常情况下,MGMTDB 会在GI 启动的时候,会自动启动,但也可以手工管理,直接使用srtl 操作即可:

Usage: srvctl start mgmtdb[-startoption <start_option>] [-node <node_name>]

 

 

2.3 查看Management Database 的log 和trace 文件

 

一般情况下,是不需要查看MGMT DB的trace的,如果要查看,用如下命令:

[[email protected] _mgmtdb]$ pwd

/u01/gridbase/diag/rdbms/_mgmtdb

[[email protected] _mgmtdb]$ ls

i_1.mif -MGMTDB

[[email protected] _mgmtdb]$

 

进入$ORACLE_BASE下的trace目录。但是进入-MGMTDB时,要注意,不能直接cd:

 

[[email protected] _mgmtdb]$ cd -MGMTDB

-bash: cd: -M: invalid option

cd: usage: cd [-L|-P] [dir]

[[email protected] _mgmtdb]$

必须使用./-MGMTDB,如:

[[email protected] _mgmtdb]$ cd ./-MGMTDB

[[email protected] -MGMTDB]$ ls

alert hm incpkg lck metadata metadata_pv sweep

cdump incident ir log metadata_dgif stage trace

[[email protected] -MGMTDB]$



[[email protected] trace]$ pwd

/u01/gridbase/diag/rdbms/_mgmtdb/-MGMTDB/trace



[[email protected] trace]$ ls

alert_-MGMTDB.log -MGMTDB_ckpt_4772.trm -MGMTDB_lgwr_7475.trc -MGMTDB_m001_10288.trm -MGMTDB_ora_10486.trc -MGMTDB_p001_5645.trm

cdmp_20140807064254 -MGMTDB_ckpt_7477.trc -MGMTDB_lgwr_7475.trm -MGMTDB_m001_10330.trc -MGMTDB_ora_10486.trm -MGMTDB_p001_7523.trc

cdmp_20141208110548 -MGMTDB_ckpt_7477.trm -MGMTDB_m000_10101.trc -MGMTDB_m001_10330.trm -MGMTDB_ora_10830.trc -MGMTDB_p001_7523.trm

cdmp_20141208110550 -MGMTDB_dbrm_4764.trc -MGMTDB_m000_10101.trm -MGMTDB_m001_8055.trc -MGMTDB_ora_10830.trm -MGMTDB_rbal_10460.trc

cdmp_20141208110553 -MGMTDB_dbrm_4764.trm -MGMTDB_m000_10202.trc -MGMTDB_m001_8055.trm -MGMTDB_ora_3770.trc -MGMTDB_rbal_10460.trm

cdmp_20141208110555 -MGMTDB_dbrm_7469.trc -MGMTDB_m000_10202.trm -MGMTDB_mark_10484.trc -MGMTDB_ora_3770.trm -MGMTDB_rbal_4782.trc

 

MGMT DB 的日志和trace 都在这个里。

 

 

3 MGMTDB是带一个PDB的CDB数据库

 

前面说了,MGMTDB 是一个实例,实际上,MGMTDB是带一个PDB的CDB库,我们可以使用GI的命令直接去操作MGMTDB 对应的PDB。

 

--查看MGMTDB当前节点:

[[email protected] /]$ oclumon manage -get master

Master = rac1



--查看状态:

[[email protected] /]$ srvctl status mgmtdb

Database is enabled

Instance -MGMTDB is running on node rac2



--查看配置信息:

[[email protected] /]$ srvctl config mgmtdb

Database unique name: _mgmtdb

Database name:

 home: /u01/gridsoft/12.1.0

Oracle user: grid

Spfile:+OCR_VOTING/_mgmtdb/spfile-MGMTDB.ora

Password file:

Domain:

Start options: open

Stop options: immediate

Database role: PRIMARY

Management policy: AUTOMATIC

Database instance: -MGMTDB

Type: Management



--连接MGMTDB实例

[[email protected] /]$ export ORACLE_SID=-MGMTDB

[[email protected] /]$ 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 fromdba_data_files union select member file_name from V$logfile;



FILE_NAME

--------------------------------------------------------------------------------

+OCR_VOTING/_MGMTDB/DATAFILE/sysaux.258.854939615

+OCR_VOTING/_MGMTDB/DATAFILE/sysgridhomedata.261.854939891

+OCR_VOTING/_MGMTDB/DATAFILE/sysmgmtdata.260.854939737

+OCR_VOTING/_MGMTDB/DATAFILE/system.259.854939661

+OCR_VOTING/_MGMTDB/DATAFILE/undotbs1.257.854939605

+OCR_VOTING/_MGMTDB/ONLINELOG/group_1.263.854940051

+OCR_VOTING/_MGMTDB/ONLINELOG/group_2.264.854940053

+OCR_VOTING/_MGMTDB/ONLINELOG/group_3.265.854940057



8 rows selected.

 

 

这里查询的是MGMTDB的路径,也可以直接用如下命令查询:

[[email protected] /]$ oclumon manage -get reppath

CHM Repository Path =+OCR_VOTING/_MGMTDB/DATAFILE/sysmgmtdata.260.854939737

[[email protected] /]$





--查询MGMTDB用户:

SQL> select username,account_status fromdba_users where username like 'CH%';



USERNAME ACCOUNT_STATUS

------------- ----------------

CHM OPEN

CHA OPEN