Oracle 12c中的MGMTDB

0    76    1

👉 本文共约18728个字,系统预计阅读时间或需71分钟。

简介

在12.1.0.1 中, GIMR 是可选的,如果在安装 GI 的时候,没有选择 Management Database 数据库,那么所有依赖的特性,如 Cluster Health Monitor(CHM/OS) 就会被禁用。当然,在 12.1.0.2 中,可以忽略这个问题,因为是强制安装 GIMR 了, 但是在19c 中又变为了可选选项了 。

Starting with Oracle Grid Infrastructure 19c, the Grid Infrastructure Management Repository (GIMR) is optional for new installations of Oracle Standalone Cluster. Oracle Domain Services Clusters still require the installation of a GIMR as a service component.

命令

12c Grid Infrastructure 管理资料库(GIMR) 问答 (文档 ID 2047608.1)

适用于:

Oracle Database - Enterprise Edition - 版本 12.1.0.1 和更高版本
Oracle Database Cloud Schema Service - 版本 N/A 和更高版本
Oracle Database Exadata Express Cloud Service - 版本 N/A 和更高版本
Oracle Database Exadata Cloud Machine - 版本 N/A 和更高版本
Oracle Cloud Infrastructure - Database Service - 版本 N/A 和更高版本
本文档所含信息适用于所有平台

用途

此文档是一个对 12c Grid Infrastructure 的新功能:管理资料库的 FAQ 文档。

问题和答案

什么是管理资料库?

管理资料库是一个由 12c 集群软件管理的单实例数据库。因为此数据库为单实例数据库,所以它只在集群的一个节点运行。也正是因为这个数据库是被集群管理的,所以如果数据库运行节点 down 掉,数据库也会被自动切换到另外的节点。在 12.2 的版本上,MGMTLSNR 也监听在公网上,所以 ora.MGMTLSNR 资源也依赖 VIP 资源;当公网有问题时,MGMTLSNR 和 MGMTDB 都会切换。

管理资料库是用来干什么的?

在 12c,管理资料库是一个用来集中存放 Cluster Health Monitor 数据(又称:CHM/OS,ora.crf)以及其他的数据的资料库。

管理资料库的数据文件放在哪里?

在12.1版本,管理资料库默认和 OCR、Voting disk 使用一样的共享存储。在12.2,在安装时可以指定使用单独的diskgroup。

在安装升级的时候,如果不配置管理资料库会有什么样的问题?

管理资料库在 12.1是非强制的,如果在使用 OUI 安装升级的时候未选择该选项,所有的依赖于管理资料库的功能都会被禁用(比如 CHM/OS 等等)。

在 12.1.0.2 中,管理资料库变为强制安装(除了 Exadata环境)。

从 Oracle Grid Infrastructure 19c 开始,对于 Oracle Standalone Cluster 类型的GI 来说,Grid Infrastructure Management Repository (GIMR) 不再是强制的,而是可选的。不过 GIMR 对于Oracle Domain Services Clusters来说仍然是必须的。 参考

对于 ODA 18.3 和更高版本,GIMR 不是强制需要的。参考 Doc ID 2516859.1

有哪些和管理资料库相关的资源?

从“crsctl stat res –t”的输出结果来看,以下是和管理资料库有关的资源:

ora.mgmtdb
1 ONLINE ONLINE Open,STABLE

ora.MGMTLSNR
1 ONLINE ONLINE ,STABLE

在 OS 层面,可以看到数据库“-MGMTDB”和监听器“MGMTLSNR”:

ps -ef| grep pmon_-MGMTDB

grid 3500 1 0 Jun04 ? 00:06:18 mdbpmon-MGMTDB

ps -ef| grep MGMTLSNR

grid 3308 1 0 Jun04 ? 00:00:55 /ocw/c101/bin/tnslsnr MGMTLSNR -no_crs_notify -inherit

如果管理资料库停掉,怎样手工启动?

管理资料库被集群管理而且应该一直运行。如果资料库因为一些原因停掉,下面的 srvctl 命令可以用来启动资料库:

Usage: srvctl start mgmtdb [-startoption ] [-node ]
Usage: srvctl start mgmtlsnr [-node ]

怎样“cd”到管理资料库的子目录去查看跟踪文件?

通常来讲,一般没有必要去查看管理资料库的跟踪文件。如果需要查看则必须在数据库名前加上“./”以避免以下的错误,因为资料库数据库名前面有个“-”:

cd -MGMTDB
-bash: cd: -M: invalid option
cd: usage: cd [-L|-P] [dir]

cd ./-MGMTDB ==>> this will work as "./" is specified

more -MGMTDB_m000_9912.trc
more: unknown option "-M"
usage: more [-dflpcsu] [+linenum | +/pattern] name1 name2 ...

more ./-MGMTDB_m000_9912.trc
Trace file /home/grid/app/grid/diag/rdbms/_mgmtdb/-MGMTDB/trace/-MGMTDB_m000_9912.trc
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Automatic Storage Management, Advanced Analytics and Management Database options

有没有必要去手动备份或优化资料库?

目前没有必要。

在Oracle Restart环境下,GIMR会被默认创建吗?

不。在Oracle Restart环境下GIMR默认不会被创建。

在Exadata环境下,GIMR是必需的吗?

只有在用到Rapid Host Provisioning, Cluster Health Monitor, Cluster Health Advisor, 和 Cluster Activity Log时,GIMR(MGMTDB)才是必需的。

需要分配多少磁盘空间给资料库?

OCR 和管理资料库在外部冗余的情况下:

至少 5.2GB 的空间的 OCR 用来存储资料库(4.5GB+300MB Voting files+400MB OCR),如果节点数超过 4,则每个多出的节点多分配 500MB 的空间。 如:一个六节点的集群应该使用 6.2GB 空间。

Oracle 的文档说明:

参考

NOTE:1589394.1 - How to Move/Recreate GI Management Repository (GIMR / MGMTDB) to Different Shared Storage (Diskgroup, CFS or NFS etc)
NOTE:2065175.1 - MDBUtil: GI Management Repository configuration tool

12.2:如何创建 GI Management Repository (文档 ID 2364214.1)

适用于:

Oracle Database - Enterprise Edition - 版本 12.2.0.1 和更高版本
本文档所含信息适用于所有平台

目标

本文概括了创建 12.2 GIMR (GridInfrastructure Management Repository) Database (MGMTDB) 的步骤。

解决方案

\1. 发出 DBCA 命令来创建 MGMTDB 的 container。

以 grid 用户,

$ /bin/dbca -silent -createDatabase -createAsContainerDatabase true -templateName MGMTSeed_Database.dbc
-sid -MGMTDB
-gdbName _mgmtdb
-storageType ASM
-diskGroupName
-datafileJarLocation /assistants/dbca/templates
-characterset AL32UTF8
-autoGeneratePasswords
-skipUserTemplateCheck

注意,根据需要修改 (比如 +DATA, +REDO, ...)

\2. 创建 pluggable GIMR 库。

以 grid 用户,

$ /bin/mgmtca -local

注意,为了避免使用上述的手工步骤,您可以利用自动化工具 : mdbutil.pl ,请参阅 Note: 2065175.1

举例如下:
(oracle)$ ./mdbutil.pl --addmdb --target=+DATAC1
2017-04-04 14:47:48: I Starting To Configure MGMTDB at +DATAC1...
2017-04-04 14:47:57: I Container database creation in progress...
2017-04-04 14:55:20: I Plugable database creation in progress...
2017-04-04 14:57:03: I Executing "/tmp/mdbutil.pl --addchm" on xxxadm01 as root to configure CHM.
root@ xxxadm01 password:
2017-04-04 15:01:36: I MGMTDB & CHM configuration done!

参考

NOTE:2065175.1 - MDBUtil: GI Management Repository configuration tool

如何在不同的共享存储(磁盘组、CFS、NFS 等)上移动/重建 GIMR (MGMTDB) (文档 ID 2225754.1)

适用于:

Oracle Database - Enterprise Edition - 版本 12.1.0.1 到 12.2.0.1 [发行版 12.1 到 12.2]
本文档所含信息适用于所有平台

目标

本文目的给出转移 12c 的 GIMR(Grid Infrastructure Management Repository)到其它共享存储的概要步骤。

对于12.2 请参考 note 2065175.1 - MDBUtil: GI Management Repository configuration tool 来创建GIMR或者移动数据文件到不同的磁盘组上。这篇文档的内容同样适用于在12.2 上删除已经存在的mgmtdb和创建新的mgmtdb

这个过程执行时GIMR 管理数据库中原有的数据无法保留。请通过 grid 用户,在任何节点执行下面命令,以手动方式备份“管理数据库”:

本人提供Oracle、MySQL、PG等数据库的培训和考证业务,私聊QQ646634621或微信db_bao,谢谢!

$ /bin/oclumon dumpnodeview -allnodes -v >

解决方案

\1. 停止并禁用 ora.crf 资源

需要使用 root 用户,在每一个节点执行命令:

# /bin/crsctl stop res ora.crf -init
# /bin/crsctl modify res ora.crf -attr ENABLED=0 -init

不要停止 ora.mgmtlsnr 资源 ora.mgmtdb,否则第二步会遇到下面错误:

Oracle Grid Management database is running on node "". Run dbca on node "" to delete the database.

\2. 执行 DBCA 命令删除管理数据库

使用 grid 用户执行下面命令,来确定 MGMTDB 运行的节点:

$ /bin/srvctl status mgmtdb

在MGMTDB运行的节点上,执行以下命令:

$ /bin/dbca -silent -deleteDatabase -sourceDB -MGMTDB
Connecting to database
4% complete
9% complete
14% complete
19% complete
23% complete
28% complete
47% complete
Updating network configuration files
48% complete
52% complete
Deleting instance and datafiles
76% complete
100% complete
Look at the log file "/home/grid/app/grid/cfgtoollogs/dbca/_mgmtdb.log" for further details.

注意:

如果管理MGMTDB库没有运行,DBCA 会遇到下面错误:

Oracle Grid Management database is running on node "". Run dbca on node "" to delete the database.

解决该问题的办法是通过下面方式手动删除:

- 在文件系统层面,删除管理数据库的相关文件。并删除 oratab 的相关条目

- 使用 srvctl 删除 mgmtdb 资源:srvctl remove mgmtdb

\3. 重建管理数据库(MGMTDB)

3A. 针对 12.1.0.1 版本

在任一节点使用 grid 用户执行 DBCA 命令:

$ /bin/dbca -silent -createDatabase -templateName MGMTSeed_Database.dbc -sid -MGMTDB -gdbName _mgmtdb -storageType ASM -diskGroupName <+NEW_DG> -datafileJarLocation /assistants/dbca/templates -characterset AL32UTF8 -autoGeneratePasswords -oui_internal
Copying database files
1% complete
3% complete
10% complete
17% complete
24% complete
31% complete
35% complete
Creating and starting Oracle instance
37% complete
42% complete
47% complete
52% complete
53% complete
56% complete
58% complete
Registering database with Oracle Grid Infrastructure
64% complete
Completing Database Creation
68% complete
78% complete
89% complete
100% complete
Look at the log file "/home/grid/app/grid/cfgtoollogs/dbca/_mgmtdb/_mgmtdb1.log" for further details.

注意:无论是新创建还是修改磁盘组的过程,我们都建议把磁盘组的参数 compatible.asm 和 compatible.rdbms 设置成 12.1。

以上例子是创建了管理数据库到一个新的磁盘组,如果是使用共享的 NFS/CFS, 请参考以下例子:

/bin/dbca -silent -createDatabase -templateName MGMTSeed_Database.dbc -sid -MGMTDB -gdbName _mgmtdb -storageType FS -datafileDestination -datafileJarLocation /assistants/dbca/templates -characterset AL32UTF8 -autoGeneratePasswords -oui_internal

**3B. 针对 12.1.0.2 版本
**

a. 在任一节点使用 grid 用户执行 DBCA 命令,并指定好期望使用的磁盘组名:

$ /bin/dbca -silent -createDatabase -sid -MGMTDB -createAsContainerDatabase true -templateName MGMTSeed_Database.dbc -gdbName _mgmtdb -storageType ASM -diskGroupName -datafileJarLocation $GI_HOME/assistants/dbca/templates -characterset AL32UTF8 -autoGeneratePasswords -skipUserTemplateCheck

Copying database files
1% complete
3% complete
10% complete
17% complete
24% complete
31% complete
35% complete
Creating and starting Oracle instance
37% complete
42% complete
47% complete
52% complete
53% complete
56% complete
58% complete
Registering database with Oracle Grid Infrastructure
64% complete
Completing Database Creation
68% complete
78% complete
89% complete
100% complete
Look at the log file "/cfgtoollogs/dbca/_mgmtdb/_mgmtdb1.log" for further details.

**注意:无论是新创建还是修改磁盘组的过程,我们都建议把磁盘组的参数 compatible.asm 和 compatible.rdbms 设置成12.1。**

Ex: CREATE DISKGROUP … ATTRIBUTE 'compatible.rdbms' = '12.1', 'compatible.asm' = '12.1';

管理数据库可以通过下面命令,从 NFS/CFS 迁移到 ASM 磁盘组:

$ /bin/dbca -silent -createDatabase -sid -MGMTDB -createAsContainerDatabase true -templateName MGMTSeed_Database.dbc -gdbName _mgmtdb -storageType FS -datafileDestination -datafileJarLocation $GI_HOME/assistants/dbca/templates -characterset AL32UTF8 -autoGeneratePasswords -skipUserTemplateCheck

b. 使用 DBCA 再创建一个 PDB:

使用 grid 用户执行下面 DBCA 命令:

**注意:命令中的 CLUSTER_NAME 中不可以有中横线(“-“),需要使用下划线替代(“_”)。**

$ /bin/dbca -silent -createPluggableDatabase -sourceDB -MGMTDB -pdbName -createPDBFrom RMANBACKUP -PDBBackUpfile /assistants/dbca/templates/mgmtseed_pdb.dfb -PDBMetadataFile /assistants/dbca/templates/mgmtseed_pdb.xml -createAsClone true
Creating Pluggable Database
4% complete
12% complete
21% complete
38% complete
55% complete
85% complete
Completing Pluggable Database Creation
100% complete
Look at the log file "/cfgtoollogs/dbca/_mgmtdb//_mgmtdb2.log" for further details.

\4. 确保管理数据库创建成功

使用grid 用户,检查管理数据库运行在哪个节点:

$ /bin/srvctl status MGMTDB
Database is enabled
Instance -MGMTDB is running on node

On :

$ /bin/mgmtca

\5. 启用并启动 ora.crf 资源

使用root 用户在每一个节点执行:

\# /bin/crsctl modify res ora.crf -attr ENABLED=1 -init
\# /bin/crsctl start res ora.crf -init

### 参考

[NOTE:2168379.1](https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=2225754.1&id=2168379.1) - Mgmtca MGTCA-1101 : Failure in Oracle Grid Infrastructure Management Repository Operation
[NOTE:2246123.1](https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=2225754.1&id=2246123.1) - 12.2: How to Create GI Management Repository
MGTCA-1101: FAILURE IN ORACLE GRID INFRASTRUCTURE MANAGEMENT REPOSITORY OPERATI

## 12.1.0.2 GI GIMR/MGMTDB SYSMGMTDATA Tablespace Increasing Rapidly (文档 ID 2177879.1)

### APPLIES TO:

Oracle Database - Enterprise Edition - Version 12.1.0.2 and later
Information in this document applies to any platform.

### SYMPTOMS

12.1.0.2 GIMR database (-MGMTDB) SYSMGMTDATA tablespace keeps increasing with the same retention size:

$ oclumon manage -get reppath

CHM Repository Path = +CRS/_MGMTDB/FD9B43BF6A646F8CE043B6A9E80A2815/DATAFILE/sysmgmtdata. **269.917710623**

Tablespace Name File Name Size (M) Used (M) Free (M) % Used
-------------------- -------------------------------------------------------------------------------- ---------- ---------- ---------- ----------
SYSMGMTDATA +CRS/_MGMTDB/FD9B43BF6A646F8CE043B6A9E80A2815/DATAFILE/sysmgmtdata. **269.917710623** 16894 **16032** 521 95

Expired CHM data are not purged:

SQL> select trunc(BEGINTIME), count(*) from chm.CHMOS_PROCESS_INT_TBL group by trunc(BEGINTIME) order by trunc(BEGINTIME);

TRUNC(BEG COUNT(*)
--------- ----------
25-JUL-16 1824587
26-JUL-16 3019039
27-JUL-16 3236612
28-JUL-16 3559627
29-JUL-16 3687053
....
09-AUG-16 3626059
10-AUG-16 3638210
11-AUG-16 3665800
12-AUG-16 3565969
13-AUG-16 3650727
14-AUG-16 3638103
15-AUG-16 3622208
16-AUG-16 3680251
17-AUG-16 2321889

### CAUSE

Issue was investigated in:

\- -MGMTDB SYSMGMTDATA IS FILLING UP WHICH CAUSES GRID1 DISK TO REACH 100%.

\- OCR_VOTE DISK GROUP IS 99% FULL, HIGH UNDO USED BY MGMTDB

The cause is due to autoextend for the tablespace being set to on.

### SOLUTION

Solution 1:

Recreate GIMR which will drop the existing database and set autoextend back to off.

[note 1589394.1](https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=2177879.1&id=1589394.1) - How to Move/Recreate GI Management Repository to Different Shared Storage (Diskgroup, CFS or NFS etc)

Or

Solution 2:

Manually perform the following steps to shrink:

\1. Stop and disable ora.crf resource.

On each node, as root user:

\# /bin/crsctl stop res ora.crf -init
\# /bin/crsctl modify res ora.crf -attr ENABLED=0 -init

\2. Identify huge objects from dba_segments and truncate them:

Connect to MGMTDB:

export ORACLE_HOME=
export ORACLE_SID=-MGMTDB
$ORACLE_HOME/bin/sqlplus / as sysdba
SQL> select pdb_name from dba_pdbs where pdb_name!='PDB$SEED';

PDB_NAME
\--------------------------------------------------------------------------------------------------------------------------------
CEHAOVMSP1CLU68 ====>>>> this is your PDB name, use it in next command

SQL> alter session set container=CEHAOVMSP1CLU68;

Session altered.

SQL> col obj format a50
SQL> select owner||'.'||SEGMENT_NAME obj, BYTES from dba_segments where owner='CHM' order by 2 asc

Likely you are going to see the following as the biggest table:

CHM.CHMOS_PROCESS_INT_TBL
CHM.CHMOS_DEVICE_INT_TBL

Truncate the table, i.e.:

SQL> truncate table CHM.CHMOS_PROCESS_INT_TBL;
SQL> truncate table CHM.CHMOS_DEVICE_INT_TBL;
..

\3. Shrink the tablespace:

\4. Enable and start ora.crf resource.

On each node, as root user:

\# /bin/crsctl modify res ora.crf -attr ENABLED=1 -init
\# /bin/crsctl start res ora.crf -init

### REFERENCES

[NOTE:1589394.1](https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=2177879.1&id=1589394.1) - How to Move/Recreate GI Management Repository to Different Shared Storage (Diskgroup, CFS or NFS etc)
\- -MGMTDB SYSMGMTDATA IS FILLING UP WHICH CAUSES GRID1 DISK TO REACH 100%.

## MDBUtil: GI Management Repository configuration tool (文档 ID 2065175.1)

### APPLIES TO:

Oracle Database - Enterprise Edition - Version 12.1.0.1 to 12.2.0.1 [Release 12.1 to 12.2]
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Linux x86-64

### ABSTRACT

This document explains how to use " ", a tool used to create the Grid Infrastructure Management Repository (GIMR) database MGMTDB or move its database files to a different disk group in one simple command

### HISTORY

Author: Ruggero Citton (ruggero.citton@oracle.com) - RACPack Team
Create Date 2014
Update Date June-2018
Latest " " Version: 20180614 $Revision: 1.95 $

### DETAILS

### Grid Infrastructure Management Repository (GIMR) database MGMTDB

The Grid Infrastructure Management Repository enables such features as Cluster Health Monitor, Oracle Database QoS Management, and Rapid Home Provisioning, and provides a historical metric repository that simplifies viewing of past performance and diagnosis of issues.
During the installation of Oracle Grid Infrastructure 12.1.0.1 you've had the option to install the Grid Infrastructure Management Repository (GIMR) database MGMTDB. Starting with Oracle Grid Infrastructure 12.1.0.2 the GIMR database has become mandatory and is automatically installed.

#### MDBUtil: GI Management Repository configuration tool

If you need to create or re-create the Grid Infrastructure Management Repository (GIMR) database MGMTDB after the installation, specific knowledge and many manual steps are required. (see [Note 1589394.1](https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=2065175.1&id=1589394.1) for details). You also may desire to move the MGMTDB database files to a different disk group from your Clusterware files. has been created to provide this functionality in one simple command.

Note:
This script is provided for educational purposes only.
It is NOT supported by Oracle World Wide Technical Support.
The script has been tested and appears to work as intended.
You should always run new scripts on a test instance initially.

#### MDBUtil usage

\# ./mdbutil.pl -h
Usage:
Create/Enable MGMTDB & CHM
mdbutil.pl --addmdb --target=
Move MGMTDB to another location
mdbutil.pl --mvmgmtdb --target=
Check MGMTDB status
mdbutil.pl --status

mdbutil.pl OPTIONS
--addmdb Create MGMTDB/CHM and reconfigure related functions
--mvmgmtdb Migrate MGMTDB to another location
--target='+DATA' MGMTDB Disk Group location
--status Check the CHM & MGMTDB status
--help Display this help and exit
--debug Verbose commands output/trace

Example:
Create/Enable MGMTDB:
mdbutil.pl --addmdb --target=+DATA
Move MGMTDB to another location:
mdbutil.pl --mvmgmtdb --target=+REDO
Check CHM:
mdbutil.pl --status

##### Create MGMTDB/CHM and reconfigure related functions

You can create MGMTDB and configure the related functions such mgmtlsnr, chm issuing (as 'grid' user). PLEASE NOTE: You will also need root user credentials if the CHM resource (ora.crf) has not been previously created.

**mdbutil --addmdb --target=**

example:

[grid@rwsdb1 tmp]$ ./mdbutil.pl --addmdb --target=+DATA
2015-10-12 09:11:17: **I** Starting To Configure MGMTDB at +DATA...
2015-10-12 09:11:19: **I** Container database creation in progress...
2015-10-12 09:17:35: **I** Plugable database creation in progress...
2015-10-12 09:19:00: **I** Executing "/tmp/mdbutil.pl --addchm" on rwsdb1 as root to configure CHM.
root@rwsdb1's password:
2015-10-12 09:20:17: **I** Executing "/tmp/mdbutil.pl --addchm" on rwsdb2 as root to configure CHM.
root@rwsdb2's password:
2015-10-12 09:20:22: **I** MGMTDB & CHM configuration done!

##### Migrate MGMTDB database files to another disk group

You can move MGMTDB database files to another ASM disk group issuing the following command as GI software owner (ex: ‘grid') user:

**mdbutil.pl --mvmgmtdb --target=**

example:
[grid@rwsdb1 tmp]$ /tmp/mdbutil.pl --mvmgmtdb --target=+REDO
Moving MGMTDB, it will be stopped, are you sure (Y/N)? y
2015-10-12 09:24:53: **I** Checking for the required paths under +REDO
2015-10-12 09:24:54: **I** Creating new path +REDO/_MGMTDB/PARAMETERFILE
2015-10-12 09:24:56: **I** Creating new path +REDO/_MGMTDB/CONTROLFILE
2015-10-12 09:24:59: **I** Creating new path +REDO/_MGMTDB/ONLINELOG
2015-10-12 09:25:01: **I** Creating new path +REDO/_MGMTDB/DATAFILES
2015-10-12 09:25:04: **I** Creating new path +REDO/_MGMTDB/TEMPFILE
2015-10-12 09:25:06: **I** Creating new path +REDO/_MGMTDB/DATAFILES/rwsdb_c
2015-10-12 09:25:08: **I** Creating new path +REDO/_MGMTDB/TEMPFILE/rwsdb_c
2015-10-12 09:25:08: **I** Getting MGMTDB Database files location
2015-10-12 09:25:09: **I** Getting MGMTDB Temp files location
2015-10-12 09:25:09: **I** Getting MGMTDB PDB rwsdb_c files location
2015-10-12 09:25:09: **I** Getting MGMTDB PDB rwsdb_c Temp files location
2015-10-12 09:25:10: **I** Creating temporary PFILE
2015-10-12 09:25:10: **I** Creating target SPFILE
2015-10-12 09:25:16: **I** Stopping mgmtdb
2015-10-12 09:25:36: **I** Copying MGMTDB DBFiles to +REDO
2015-10-12 09:25:52: **I** Copying MGMTDB rwsdb_c PDB DBFiles to +REDO
2015-10-12 09:26:33: **I** Creating the CTRL File
2015-10-12 09:26:59: **I** The CTRL File has been created and MGMTDB is now running from +REDO
2015-10-12 09:26:59: **I** Setting MGMTDB SPFile location
2015-10-12 09:27:00: **I** Modifing the init parameter
2015-10-12 09:27:00: **I** Removing old MGMTDB
2015-10-12 09:27:02: **I** Restarting MGMTDB using target SPFile
2015-10-12 09:27:47: **I** MGMTDB Successfully moved to +REDO!

##### Check the CHM & MGMTDB status

If for any reason, MDBUtil is failing, you can get diagnostics information running mdbutil again using the “-debug” option, example:

**mdbutil.pl --status**

example:
[grid@rwsdb1 tmp]$ ./mdbutil.pl --status
2015-10-12 09:30:37: **I** Checking CHM status...
2015-10-12 09:30:38: **I** Listener MGMTLSNR is configured and running on rwsdb1
2015-10-12 09:30:39: **I** Database MGMTDB is configured and running on rwsdb1
2015-10-12 09:30:39: **I** Cluster Health Monitor (CHM) is configured and running
\--------------------------------------------------------------------------------
CHM Repository Path = +RECO/_MGMTDB/DATAFILES/rwsdb_c/sysmgmtdata.20151012092509.dbf
MGMTDB space used on DG +RECO = 504 Mb
\--------------------------------------------------------------------------------

#### MDBUtil: troubleshooting

If for any reason, MDBUtil is failing, you could get diagnostics information running mdbutil again using " ***-debug\***" option, example:

[grid@rwsdb1 tmp]$ ./mdbutil.pl --addmdb --target=+REDO
2015-10-12 09:09:31: **I** Starting To Configure MGMTDB at +REDO...
2015-10-12 09:09:52: **I** Container database creation in progress...
2015-10-12 09:09:59: **E** Cannot create CDB MGMTDB on rwsdb1, exiting...

[grid@rwsdb1 tmp]$ ./mdbutil.pl --addmdb --target=+REDO ***-debug***
2015-10-12 09:10:18: **D** Executing: /u01/app/12.1.0.2/grid/bin/srvctl status diskgroup -g REDO
2015-10-12 09:10:19: **D** Exit code: 0
2015-10-12 09:10:19: **D** Output of last command execution:
Disk Group REDO is running on rwsdb1,rwsdb1
2015-10-12 09:10:19: **I** Starting To Configure MGMTDB at +REDO...
2015-10-12 09:10:19: **D** Executing: /u01/app/12.1.0.2/grid/bin/srvctl status mgmtlsnr
2015-10-12 09:10:19: **D** Exit code: 0
2015-10-12 09:10:19: **D** Output of last command execution:
Listener MGMTLSNR is enabled
2015-10-12 09:10:19: **D** Executing: /u01/app/12.1.0.2/grid/bin/srvctl status mgmtdb
2015-10-12 09:10:20: **D** Exit code: 1
2015-10-12 09:10:20: **D** Output of last command execution:
PRCD-1120 : The resource for database _mgmtdb could not be found.
2015-10-12 09:10:20: **D** Executing: /u01/app/12.1.0.2/grid/bin/srvctl status mgmtdb
2015-10-12 09:10:20: **D** Exit code: 1
2015-10-12 09:10:20: **D** Output of last command execution:
PRCD-1120 : The resource for database _mgmtdb could not be found.
2015-10-12 09:10:20: **D** Executing: /u01/app/12.1.0.2/grid/bin/srvctl stop mgmtlsnr
2015-10-12 09:10:21: **D** Exit code: 2
2015-10-12 09:10:21: **D** Output of last command execution:
PRCC-1016 : MGMTLSNR was already stopped
2015-10-12 09:10:21: **D** Executing: /u01/app/12.1.0.2/grid/bin/srvctl enable oc4j
2015-10-12 09:10:21: **D** Exit code: 2
2015-10-12 09:10:21: **D** Output of last command execution:
PRKO-2116 : OC4J is already enabled
2015-10-12 09:10:21: **D** Executing: /u01/app/12.1.0.2/grid/bin/srvctl start oc4j
2015-10-12 09:10:21: **D** Exit code: 2
2015-10-12 09:10:21: **D** Output of last command execution:
PRCC-1014 : oc4j was already running
2015-10-12 09:10:21: **D** Executing: /u01/app/12.1.0.2/grid/bin/crsctl query crs activeversion
2015-10-12 09:10:21: **D** Exit code: 0
2015-10-12 09:10:21: **D** Output of last command execution:
Oracle Clusterware active version on the cluster is [12.1.0.2.0]
2015-10-12 09:10:21: **I** Container database creation in progress...
2015-10-12 09:10:21: **D** Executing: /u01/app/12.1.0.2/grid/bin/dbca -silent -createDatabase -createAsContainerDatabase true -templateName MGMTSeed_Database.dbc -sid -MGMTDB -gdbName _mgmtdb -storageType ASM -diskGroupName REDO -datafileJarLocation /u01/app/12.1.0.2/grid/assistants/dbca/templates -characterset AL32UTF8 -autoGeneratePasswords -skipUserTemplateCheck
2015-10-12 09:10:26: **D** Exit code: 1
2015-10-12 09:10:26: **D** Output of last command execution:
Look at the log file "/u01/app/grid/cfgtoollogs/dbca/_mgmtdb1.log" for further details.
2015-10-12 09:10:26: **E** Cannot create CDB MGMTDB on rwsdb1, exiting...

-->
[grid@rwsdb1 tmp]$ cat /u01/app/grid/cfgtoollogs/dbca/_mgmtdb1.log

+REDO does not have enough space. Required space is 1566 MB , available space is 1305 MB.

### REFERENCES

[NOTE:1589394.1](https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=2065175.1&id=1589394.1) - How to Move/Recreate GI Management Repository (GIMR / MGMTDB) to Different Shared Storage (Diskgroup, CFS or NFS etc)
[NOTE:1568402.1](https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=2065175.1&id=1568402.1) - FAQ: 12c Grid Infrastructure Management Repository (GIMR)
[NOTE:2062234.1](https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=2065175.1&id=2062234.1) - How to Relocate Cluster Health Monitor (CHM) Repository and Increase Retention Time

## MGMTDB说明

Every Oracle Standalone Cluster and Oracle Domain Services Cluster contains a Grid Infrastructure Management Repository (GIMR), or the Management Database (MGMTDB).

The Grid Infrastructure Management Repository (GIMR) is a multitenant database with a pluggable database (PDB) for the GIMR of each cluster. The GIMR stores the following information about the cluster:

?Real time performance data the Cluster Health Monitor collects

?Fault, diagnosis, and metric data the Cluster Health Advisor collects

?Cluster-wide events about all resources that Oracle Clusterware collects

?CPU architecture data for Quality of Service Management (QoS)

?Metadata required for Rapid Home Provisioning

The Oracle Standalone Cluster locally hosts the GIMR on an Oracle ASM disk group; this GIMR is a multitenant database with a single pluggable database (PDB).

The global GIMR runs in an Oracle Domain Services Cluster. Oracle Domain Services Cluster locally hosts the GIMR in a separate Oracle ASM disk group. Client clusters, such as Oracle Member Cluster for Database, use the remote GIMR located on the Domain Services Cluster. For two-node or four-node clusters, hosting the GIMR for a cluster on a remote cluster reduces the overhead of running an extra infrastructure repository on a cluster. The GIMR for an Oracle Domain Services Cluster is a multitenant database with one PDB, and additional PDB for each member cluster that is added.

When you configure an Oracle Domain Services Cluster, the installer prompts to configure a separate Oracle ASM disk group for the GIMR, with the default name as MGMT.

### 常用命令示例

必须使用grid用户进行登录:

[**grid**@raclhr-12cR1-N1 ~]$ export ORACLE_SID=-MGMTDB

[grid@raclhr-12cR1-N1 ~]$ sqlplus / as sysdba

MGMTDB数据库的信息:

Database unique name: _mgmtdb

Database name: _mgmtdb

Oracle user: grid

Database instance: -MGMTDB

service_names:_mgmtdb

[root@raclhr-12cR1-N1 ~]# crsctl stat res -t

\--------------------------------------------------------------------------------

Name Target State Server State details

\--------------------------------------------------------------------------------

Local Resources

\--------------------------------------------------------------------------------

ora.DATA.dg

​ ONLINE ONLINE raclhr-12cr1-n1 STABLE

​ ONLINE ONLINE raclhr-12cr1-n2 STABLE

ora.FRA.dg

​ ONLINE ONLINE raclhr-12cr1-n1 STABLE

​ ONLINE ONLINE raclhr-12cr1-n2 STABLE

ora.LISTENER.lsnr

​ ONLINE ONLINE raclhr-12cr1-n1 STABLE

​ ONLINE ONLINE raclhr-12cr1-n2 STABLE

ora.OCR.dg

​ ONLINE ONLINE raclhr-12cr1-n1 STABLE

​ ONLINE ONLINE raclhr-12cr1-n2 STABLE

ora.asm

​ ONLINE ONLINE raclhr-12cr1-n1 Started,STABLE

​ ONLINE ONLINE raclhr-12cr1-n2 Started,STABLE

ora.net1.network

​ ONLINE ONLINE raclhr-12cr1-n1 STABLE

​ ONLINE ONLINE raclhr-12cr1-n2 STABLE

ora.ons

​ ONLINE ONLINE raclhr-12cr1-n1 STABLE

​ ONLINE ONLINE raclhr-12cr1-n2 STABLE

\--------------------------------------------------------------------------------

Cluster Resources

\--------------------------------------------------------------------------------

ora.LISTENER_SCAN1.lsnr

1 ONLINE ONLINE raclhr-12cr1-n1 STABLE

ora.MGMTLSNR

1 ONLINE ONLINE raclhr-12cr1-n1 169.254.20.104 192.1

​ 68.2.100,STABLE

ora.cvu

1 ONLINE ONLINE raclhr-12cr1-n1 STABLE

ora.lhrrac.db

1 ONLINE ONLINE raclhr-12cr1-n1 Open,STABLE

2 ONLINE ONLINE raclhr-12cr1-n2 Open,STABLE

ora.mgmtdb

1 ONLINE ONLINE raclhr-12cr1-n1 Open,STABLE

ora.oc4j

1 ONLINE ONLINE raclhr-12cr1-n1 STABLE

ora.raclhr-12cr1-n1.vip

1 ONLINE ONLINE raclhr-12cr1-n1 STABLE

ora.raclhr-12cr1-n2.vip

1 ONLINE ONLINE raclhr-12cr1-n2 STABLE

ora.scan1.vip

1 ONLINE ONLINE raclhr-12cr1-n1 STABLE

\--------------------------------------------------------------------------------

[root@raclhr-12cR1-N1 ~]#

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

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

[root@raclhr-12cR1-N1 ~]# ps -ef| grep pmon_-MGMTDB

grid 36338 1 0 16:50 ? 00:00:00 mdb_pmon_-MGMTDB

root 38490 46150 0 16:58 pts/0 00:00:00 grep pmon_-MGMTDB

[root@raclhr-12cR1-N1 ~]# ps -ef| grep MGMTLSNR

grid 729 1 0 06:11 ? 00:00:01 /u01/app/12.1.0/grid/bin/tnslsnr MGMTLSNR -no_crs_notify -inherit

root 38779 46150 0 16:58 pts/0 00:00:00 grep MGMTLSNR

[root@raclhr-12cR1-N1 ~]#

------

## MGMTDB 说明

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

![](https://pic.xmmup.com/i/2022/11/16/202211161844075-3.jpeg)

在Grid Infrastructure 12.1.0.2 中,已经没有改选项,MIMR 数据库已经变成了强制选项。

在Oracle 12c 中Management Database 用来Cluster Health Monitor(CHM/OS,ora.crf) ,Oracle Database QoS Management,Rapid Home Provisioning和其他的数据。

Management Repository 是受12c Clusterware 管理的一个单实例,在Cluster 启动的时会启动MGMTDG并在其中一个节点上运行,并受GI 管理,如果运行MGMTDG的节点宕机了,GI 会自动把MGMTDB 转移到其他的节点上。

​ 默认情况,MGMTDB 数据库的数据文件存放在共享的设备,如OCR/Voting 的磁盘组中,但后期可以移动位置。

在12.1.0.1 中,GIMR 是可选的,如果在安装GI的时候,没有选择Management Database 数据库,那么所有依赖的特性,如Cluster Health Monitor (CHM/OS) 就会被禁用。

当然,在12.1.0.2 中,可以忽略这个问题,因为是强制安装GIMR了。

另外,对于MGMT 数据库,在目前的版本中,也不需要手工对其进行备份。

## 查看Management DB 相关的资源:

```
[root@rac1 ~]# crsctl stat res -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
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
……
[root@rac1 ~]#
```

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

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

```
[root@rac2 ~]# 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

[root@rac2 ~]# ps -ef| grep MGMTLSNR
grid 7411 1 0 14: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
[root@rac2 ~]#
```

## 启动和关闭MGMT

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

Usage: [-startoption ] [-node ]

Usage: srvctl start mgmtlsnr [-node ]

## 查看Management Database 的log 和trace 文件

```sql
查看Management Database 的log 和trace 文件
一般情况下,是不需要查看MGMT DB的trace的,如果要查看,用如下命令:

[grid@rac2 _mgmtdb]$ pwd
/u01/gridbase/diag/rdbms/_mgmtdb
[grid@rac2 _mgmtdb]$ ls
i_1.mif -MGMTDB
[grid@rac2 _mgmtdb]$

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

[grid@rac2 _mgmtdb]$ cd -MGMTDB
-bash: cd: -M: invalid option
cd: usage: cd [-L|-P] [dir]
[grid@rac2 _mgmtdb]$

必须使用./-MGMTDB,如:

[grid@rac2 _mgmtdb]$ cd ./-MGMTDB
[grid@rac2 -MGMTDB]$ ls
alert hm incpkg lck metadata metadata_pv sweep
cdump incident ir log metadata_dgif stage trace
[grid@rac2 -MGMTDB]$

[grid@rac2 trace]$ pwd
/u01/gridbase/diag/rdbms/_mgmtdb/-MGMTDB/trace

[grid@rac2 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 都在这个里。
```

## MGMTDB是带一个PDB的CDB实例

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

```
--启动MGMTDB:
[root@rac1 ~]# srvctl status mgmtdb
Database is enabled
Database is not running.
[root@rac1 ~]# srvctl start mgmtdb

[root@rac1 ~]#
[root@rac1 ~]# srvctl status mgmtdb
Database is enabled
Instance -MGMTDB is running on node rac1
[root@rac1 ~]#

--查看MGMTDB当前节点:
[grid@rac2 /]$ oclumon manage -get master
Master = rac1

--查看状态:
[grid@rac2 /]$ srvctl status mgmtdb
Database is enabled
Instance -MGMTDB is running on node rac2

--查看配置信息:
[grid@rac2 /]$ srvctl config mgmtdb
Database unique name: _mgmtdb
Database name:
Oracle 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实例
[grid@rac2 /]$ export ORACLE_SID=-MGMTDB
[grid@rac2 /]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Mon Dec 8 15:24:37 2014

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Automatic Storage Management and Advanced Analytics options

SQL> select file_name from dba_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的路径,也可以直接用如下命令查询:
[grid@rac2 /]$ oclumon manage -get reppath
CHM Repository Path = +OCR_VOTING/_MGMTDB/DATAFILE/sysmgmtdata.260.854939737
[grid@rac2 /]$

--查询MGMTDB用户:
SQL> select username,account_status from dba_users where username like &#039;CH%&#039;;

USERNAME ACCOUNT_STATUS
------------- ----------------
CHM OPEN
CHA OPEN
```

## 移动MGMTDB 数据文件位置

默认情况下,MGMTDB 的数据文件是存放在OCR voting disk的磁盘组里的,为了节省OCR 磁盘组空间,我们也可以把MGMTDB 转移走。

当然,这里的移动位置,也是从一个共享位置移动到另一个共享位置。

具体操作如下。

在12.1.0.1 版本中有有问题,升级到12.1.0.2 解决。

### 停止并禁用ora.crf 资源

这里的ora.crf就是CHM。

在所有节点使用root用户执行如下命令:

```
[root@rac1 ~]# crsctl stop res ora.crf -init
CRS-2673: Attempting to stop &#039;ora.crf&#039; on &#039;rac1&#039;
CRS-2677: Stop of &#039;ora.crf&#039; on &#039;rac1&#039; succeeded

[root@rac1 ~]# crsctl modify res ora.crf -attr ENABLED=0 -init
[root@rac1 ~]#

[root@rac2 ~]# crsctl stop res ora.crf -init
CRS-2673: Attempting to stop &#039;ora.crf&#039; on &#039;rac2&#039;
CRS-2677: Stop of &#039;ora.crf&#039; on &#039;rac2&#039; succeeded

[root@rac2 ~]# crsctl modify res ora.crf -attr ENABLED=0 -init
[root@rac2 ~]#

注意:ora.mgmtlsnr 和 ora.mgmtdb 资源不能停,否则DBCA 时会报错。
```

### 执行DBCA 删除management database

--查看MGMTDB的运行节点:

```
[root@rac1 ~]# srvctl status mgmtdb
Database is enabled
Instance -MGMTDB is running on node rac2
```

这里显示在节点2上运行,那么在节点2上,用grid用户,执行dbca 命令,删除MGMTDB。

```
[grid@rac2 ~]$ dbca -silent -deleteDatabase -sourceDB -MGMTDB
Connecting to database
4% complete
9% complete
14% complete
19% complete
23% complete
28% complete
47% complete
Updating network configuration files
48% complete
52% complete
Deleting instance and datafiles
76% complete
100% complete
Look at the log file "/u01/gridbase/cfgtoollogs/dbca/_mgmtdb.log" for further details.
[grid@rac2 ~]$
```

注意:

如果是使用DBCA 手工创建的MGMTDB,则可能出现不能删除的情况,具体处理过程可以参考MOS: 1631336.1。

### 重建MGMTDB的CDB

#### 12.1.0.1执行如下命令

用grid用户,在任意节点,执行如下命令,重建CDB。

$ /bin/dbca -silent -createDatabase -templateName MGMTSeed_Database.dbc -sid -MGMTDB -gdbName _mgmtdb -storageType ASM -diskGroupName -datafileJarLocation /assistants/dbca/templates -characterset AL32UTF8 -autoGeneratePasswords -oui_internal

注意:

这里新的磁盘组,建议compatible.asm 和 compatible.rdbms 属性都设置为12.1。

上面的命令使用的是磁盘组,如果是使用共享的NFS/CFS, 则使用如下命令:

/bin/dbca -silent -createDatabase -templateName MGMTSeed_Database.dbc -sid -MGMTDB -gdbName _mgmtdb -storageType FS -datafileDestination -datafileJarLocation /assistants/dbca/templates -characterset AL32UTF8 -autoGeneratePasswords -oui_internal

我们这里数据库版本是12.1.0.1,并且使用的是磁盘组,所以执行第一个命令:

```
[grid@rac1 /]$ dbca -silent -createDatabase -templateName MGMTSeed_Database.dbc -sid -MGMTDB -gdbName _mgmtdb -storageType ASM -diskGroupName OCR -datafileJarLocation /u01/gridsoft/12.1.0/assistants/dbca/templates -characterset AL32UTF8 -autoGeneratePasswords -oui_internal
Copying database files
1% complete
3% complete
10% complete
17% complete
24% complete
31% complete
35% complete
Creating and starting Oracle instance
37% complete
42% complete
47% complete
52% complete
53% complete
56% complete
58% complete
Registering database with Oracle Grid Infrastructure
64% complete
Completing Database Creation
68% complete
78% complete
89% complete
100% complete
Look at the log file "/u01/gridbase/cfgtoollogs/dbca/_mgmtdb/_mgmtdb0.log" for further details.
[grid@rac1 /]$
```

#### 12.1.0.2执行如下命令

在任意节点,用grid用户执行如下命令:

```
--ASM 磁盘组:
$ /bin/dbca -silent -createDatabase -sid -MGMTDB -createAsContainerDatabase true -templateName MGMTSeed_Database.dbc -gdbName _mgmtdb -storageType ASM -diskGroupName <+NEW_DG> -datafileJarLocation $GRID_HOME/assistants/dbca/templates -characterset AL32UTF8 -autoGeneratePasswords -skipUserTemplateCheck

--共享的NFS/CFS :
$/bin/dbca -silent -createDatabase -templateName MGMTSeed_Database.dbc -sid -MGMTDB -gdbName _mgmtdb -storageType FS -datafileDestination -datafileJarLocation /assistants/dbca/templates -characterset AL32UTF8 -autoGeneratePasswords -oui_internal

--示例:
[grid@rac1 templates]$ dbca -silent -createDatabase -sid -MGMTDB -createAsContainerDatabase true -templateName MGMTSeed_Database.dbc -gdbName _mgmtdb -storageType ASM -diskGroupName +OCR -datafileJarLocation /u01/gridsoft/12.1.0.2/assistants/dbca/templates -characterset AL32UTF8 -autoGeneratePasswords -skipUserTemplateCheck
Registering database with Oracle Grid Infrastructure
5% complete
Copying database files
7% complete
9% complete
16% complete
23% complete
30% complete
41% complete
Creating and starting Oracle instance
43% complete
48% complete
49% complete
50% complete
55% complete
60% complete
61% complete
64% complete
Completing Database Creation
68% complete
79% complete
89% complete
100% complete
Look at the log file "/u01/gridbase/cfgtoollogs/dbca/_mgmtdb/_mgmtdb0.log" for further details.
[grid@rac1 templates]$
```

## 使用DBCA 创建PDB

```
[grid@rac1 templates]$ srvctl status mgmtdb
Database is enabled
Instance -MGMTDB is running on node rac1
[grid@rac1 templates]$
```

在任意节点,用grid用户执行dbca 创建PDB,命令如下:

$ /bin/dbca -silent -createPluggableDatabase -sourceDB -MGMTDB -pdbName -createPDBFrom RMANBACKUP -PDBBackUpfile /assistants/dbca/templates/mgmtseed_pdb.dfb -PDBMetadataFile /assistants/dbca/templates/mgmtseed_pdb.xml -createAsClone true –internalSkipGIHomeCheck

--查询集群的名称:

[grid@rac1 /]$ cemutlo -n

rac-scan

[grid@rac1 /]$

注意:默认情况CLUSTER_NAME 都是-,这里比如换成_

我们这里就要换成rac_scan

```
[grid@rac1 templates]$ dbca -silent -createPluggableDatabase -sourceDB -MGMTDB -pdbName rac_scan -createPDBFrom RMANBACKUP -PDBBackUpfile /u01/gridsoft/12.1.0.2/assistants/dbca/templates/mgmtseed_pdb.dfb -PDBMetadataFile /u01/gridsoft/12.1.0.2/assistants/dbca/templates/mgmtseed_pdb.xml -createAsClone true -internalSkipGIHomeCheck
Creating Pluggable Database
4% complete
12% complete
21% complete
38% complete
55% complete
85% complete
Completing Pluggable Database Creation
100% complete
Look at the log file "/u01/gridbase/cfgtoollogs/dbca/_mgmtdb/rac_scan/_mgmtdb0.log" for further details.
[grid@rac1 templates]$
```

## 验证MGMTDB

用grid用户执行如下命令,验证MGMTDB 运行情况:

[grid@rac1 ~]$ srvctl status MGMTDB

Database is enabled

Instance -MGMTDB is running on node rac1

这里显示的是节点1,那么在节点1上在执行:

```
[grid@rac1 ~]$ mgmtca
[grid@rac1 ~]$ crsctl stat res -t
……
ora.MGMTLSNR
1 ONLINE ONLINE rac1 169.254.193.105 192.
168.57.5,STABLE
ora.mgmtdb
1 ONLINE ONLINE rac1 Open,STABLE
……
[grid@rac1 ~]$

[grid@rac1 templates]$ srvctl config mgmtdb
Database unique name: _mgmtdb
Database name:
Oracle home:
Oracle user: grid
Spfile: +OCR/_MGMTDB/PARAMETERFILE/spfile.268.865977817
Password file:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Type: Management
PDB name: rac_scan
PDB service: rac_scan
Cluster name: rac-scan
Database instance: -MGMTDB
[grid@rac1 templates]$

[grid@rac1 templates]$ export ORACLE_SID=-MGMTDB
[grid@rac1 templates]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed Dec 10 21:39:13 2014

Copyright (c) 1982, 2014, Oracle. All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management and Advanced Analytics options

SQL> select file_name from dba_data_files union select member file_name from V$logfile;

FILE_NAME
--------------------------------------------------------------------------------
+OCR/_MGMTDB/DATAFILE/sysaux.257.865977463
+OCR/_MGMTDB/DATAFILE/system.258.865977473
+OCR/_MGMTDB/DATAFILE/undotbs1.259.865977489
+OCR/_MGMTDB/ONLINELOG/group_1.261.865977635
+OCR/_MGMTDB/ONLINELOG/group_2.262.865977635
+OCR/_MGMTDB/ONLINELOG/group_3.263.865977635

6 rows selected.

SQL>
```

数据文件已经转移到OCR 磁盘组了。

## 启用并启动ora.crf 资源

在所有节点,用root用户执行:

```
[root@rac1 u01]# crsctl modify res ora.crf -attr ENABLED=1 -init

[root@rac1 u01]# crsctl start res ora.crf -init
CRS-2672: Attempting to start &#039;ora.crf&#039; on &#039;rac1&#039;
CRS-2676: Start of &#039;ora.crf&#039; on &#039;rac1&#039; succeeded

[root@rac1 u01]# oclumon manage -get master

Master = rac1
[root@rac1 u01]#
```

## How to Move/Recreate GI Management Repository to Different Shared Storage (Diskgroup, CFS or NFS etc) (文档 ID 1589394.1)

\**In this Document\**[Goal](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=393041586397249&id=1589394.1&_adf.ctrl-state=9bq2tjfcq_65#GOAL)[Solution](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=393041586397249&id=1589394.1&_adf.ctrl-state=9bq2tjfcq_65#FIX)
APPLIES TO:Oracle Database - Enterprise Edition - Version 12.1.0.1 and later
Information in this document applies to any platform.
GOALThis note outlines the steps to move 12c GIMR (Grid Infrastructure Management Repository) to a different shared storage. This procedure will \**NOT\** preserve Management Database contents. To back up manually in text format, as grid user on any node: $ /bin/oclumon dumpnodeview -allnodes -v > SOLUTION 1. Stop and disable ora.crf resource.On each node, as root user:# /bin/crsctl stop res ora.crf -init
\# /bin/crsctl modify res ora.crf -attr ENABLED=0 -init\**Do not stop ora.mgmtlsnr or ora.mgmtdb resource or Step 2 will fail with the following:\**Oracle Grid Management database is running on node "". Run dbca on node "" to delete the database.
\2. Issue the DBCA command to delete the management databaseAs Grid User, locate the node that the Management Database is running by executing: $ /bin/srvctl status mgmtdb
As Grid User on the node where ora.mgmtdb resource is running execute:$ \**/bin/dbca -silent -deleteDatabase -sourceDB -MGMTDB\**
Connecting to database
4% complete
9% complete
14% complete
19% complete
23% complete
28% complete
47% complete
Updating network configuration files
48% complete
52% complete
Deleting instance and datafiles
76% complete
100% complete
Look at the log file "/home/grid/app/grid/cfgtoollogs/dbca/_mgmtdb.log" for further details. \**Note:\**If MGMTDB is not starting for any reason, dbca will fail:Oracle Grid Management database is running on node "". Run dbca on node "" to delete the database.The solution is to delete it manually by:- remove the MGMTDB related files manually with OS command and remove the oratab entry- remove the resource with srvctl: srvctl remove mgmtdb 3. Recreate the MGMTDB\**3A. For 12.1.0.1 only:\**As grid user, on any node execute the following dbca command:$ \**/bin/dbca -silent -createDatabase -templateName MGMTSeed_Database.dbc -sid -MGMTDB -gdbName _mgmtdb -storageType ASM -diskGroupName -datafileJarLocation /assistants/dbca/templates -characterset AL32UTF8 -autoGeneratePasswords -oui_internal\**
Copying database files
1% complete
3% complete
10% complete
17% complete
24% complete
31% complete
35% complete
Creating and starting Oracle instance
37% complete
42% complete
47% complete
52% complete
53% complete
56% complete
58% complete
Registering database with Oracle Grid Infrastructure
64% complete
Completing Database Creation
68% complete
78% complete
89% complete
100% complete
Look at the log file "/home/grid/app/grid/cfgtoollogs/dbca/_mgmtdb/_mgmtdb1.log" for further details.
\**NOTE: It's recommended to set both compatible.asm and compatible.rdbms to 12.1 for the new ASM diskgroup when creating or altering and existing diskgroup.\** Also, this example created the Management Database in a new ASM Diskgroup, to create the database in shared NFS/CFS location:/bin/dbca -silent -createDatabase -templateName MGMTSeed_Database.dbc -sid -MGMTDB -gdbName _mgmtdb -storageType FS -datafileDestination -datafileJarLocation /assistants/dbca/templates -characterset AL32UTF8 -autoGeneratePasswords -oui_internal \**3B. For 12.1.0.2 only:\**a. As Grid User on any node execute the following DBCA command with the desired :$ /bin/dbca -silent -createDatabase -sid -MGMTDB -createAsContainerDatabase true -templateName MGMTSeed_Database.dbc -gdbName _mgmtdb -storageType ASM -diskGroupName -datafileJarLocation $GI_HOME/assistants/dbca/templates -characterset AL32UTF8 -autoGeneratePasswords -skipUserTemplateCheckCopying database files
1% complete
3% complete
10% complete
17% complete
24% complete
31% complete
35% complete
Creating and starting Oracle instance
37% complete
42% complete
47% complete
52% complete
53% complete
56% complete
58% complete
Registering database with Oracle Grid Infrastructure
64% complete
Completing Database Creation
68% complete
78% complete
89% complete
100% complete
Look at the log file "/cfgtoollogs/dbca/_mgmtdb/_mgmtdb1.log" for further details.\**NOTE: It's recommended to set both compatible.asm and compatible.rdbms to 12.1 for the new ASM diskgroup when creating or altering and existing diskgroup.\**
Ex: CREATE DISKGROUP … ATTRIBUTE 'compatible.rdbms' = '12.1', 'compatible.asm' = '12.1';
The Management Database may be moved to an ASM Diskgroup, in a shared NFS/CFS location with the following command line:$ /bin/dbca -silent -createDatabase -sid -MGMTDB -createAsContainerDatabase true -templateName MGMTSeed_Database.dbc -gdbName _mgmtdb -storageType FS -datafileDestination -datafileJarLocation $GI_HOME/assistants/dbca/templates -characterset AL32UTF8 -autoGeneratePasswords -skipUserTemplateCheck
b. Create a PDB within the MGMTDB using DBCA.
As Grid User on any node execute the following DBCA command:\**NOTE: The CLUSTER_NAME needs to have any hyphens (“-“) replaced with underscores (“_”)\**$ /bin/dbca -silent -createPluggableDatabase -sourceDB -MGMTDB -pdbName -createPDBFrom RMANBACKUP -PDBBackUpfile /assistants/dbca/templates/mgmtseed_pdb.dfb -PDBMetadataFile /assistants/dbca/templates/mgmtseed_pdb.xml -createAsClone true
Creating Pluggable Database
4% complete
12% complete
21% complete
38% complete
55% complete
85% complete
Completing Pluggable Database Creation
100% complete
Look at the log file "/cfgtoollogs/dbca/_mgmtdb//_mgmtdb2.log" for further details.
\4. Secure that the Management Database credential:As Grid User, confirm the node on which MGMTDB is running by executing.$ /bin/srvctl status MGMTDB
Database is enabled
Instance -MGMTDB is running on nodeOn :$ /bin/mgmtca 5. Enable and start ora.crf resource.On each node, as root user:# /bin/crsctl modify res ora.crf -attr ENABLED=1 -init
\# /bin/crsctl start res ora.crf -init
2、12.1.0.2 GI GIMR/MGMTDB SYSMGMTDATA Tablespace Increasing Rapidly (文档 ID 2177879.1)

\**In this Document\**[Symptoms](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=393387770968242&id=2177879.1&displayIndex=3&_afrWindowMode=0&_adf.ctrl-state=9bq2tjfcq_589#SYMPTOM)[Cause](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=393387770968242&id=2177879.1&displayIndex=3&_afrWindowMode=0&_adf.ctrl-state=9bq2tjfcq_589#CAUSE)[Solution](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=393387770968242&id=2177879.1&displayIndex=3&_afrWindowMode=0&_adf.ctrl-state=9bq2tjfcq_589#FIX)[References](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=393387770968242&id=2177879.1&displayIndex=3&_afrWindowMode=0&_adf.ctrl-state=9bq2tjfcq_589#REF)
APPLIES TO:Oracle Database - Enterprise Edition - Version 12.1.0.2 and later
Information in this document applies to any platform.
SYMPTOMS12.1.0.2 GIMR database (-MGMTDB) SYSMGMTDATA tablespace keeps increasing with the same retention size:$ oclumon manage -get reppath

CHM Repository Path = +CRS/_MGMTDB/FD9B43BF6A646F8CE043B6A9E80A2815/DATAFILE/sysmgmtdata.\**269.917710623\**
Tablespace Name File Name Size (M) Used (M) Free (M) % Used
-------------------- -------------------------------------------------------------------------------- ---------- ---------- ---------- ----------
SYSMGMTDATA +CRS/_MGMTDB/FD9B43BF6A646F8CE043B6A9E80A2815/DATAFILE/sysmgmtdata.\**269.917710623\** 16894 \**16032\** 521 95 Expired CHM data are not purged: SQL> select trunc(BEGINTIME), count(\*) from chm.CHMOS_PROCESS_INT_TBL group by trunc(BEGINTIME) order by trunc(BEGINTIME);TRUNC(BEG COUNT(\*)
--------- ----------
25-JUL-16 1824587
26-JUL-16 3019039
27-JUL-16 3236612
28-JUL-16 3559627
29-JUL-16 3687053
....
09-AUG-16 3626059
10-AUG-16 3638210
11-AUG-16 3665800
12-AUG-16 3565969
13-AUG-16 3650727
14-AUG-16 3638103
15-AUG-16 3622208
16-AUG-16 3680251
17-AUG-16 2321889 CAUSEIssue was investigated in: - -MGMTDB SYSMGMTDATA IS FILLING UP WHICH CAUSES GRID1 DISK TO REACH 100%. - OCR_VOTE DISK GROUP IS 99% FULL, HIGH UNDO USED BY MGMTDB The cause is due to autoextend for the tablespace being set to on. SOLUTIONSolution 1:Recreate GIMR which will drop the existing database and set autoextend back to off.[note 1589394.1](https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=2177879.1&id=1589394.1) - How to Move/Recreate GI Management Repository to Different Shared Storage (Diskgroup, CFS or NFS etc) OrSolution 2: Manually perform the following steps to shrink: 1. Stop and disable ora.crf resource.

On each node, as root user:# /bin/crsctl stop res ora.crf -init
\# /bin/crsctl modify res ora.crf -attr ENABLED=0 -init

\2. Identify huge objects from dba_segments and truncate them:

Connect to MGMTDB:export ORACLE_HOME=
export ORACLE_SID=-MGMTDB
$ORACLE_HOME/bin/sqlplus / as sysdba
SQL> select pdb_name from dba_pdbs where pdb_name!='PDB$SEED';

PDB_NAME
\--------------------------------------------------------------------------------------------------------------------------------
CEHAOVMSP1CLU68 ====>>>> this is your PDB name, use it in next command

SQL> alter session set container=CEHAOVMSP1CLU68;

Session altered.

SQL> col obj format a50
SQL> select owner||'.'||SEGMENT_NAME obj, BYTES from dba_segments where owner='CHM' order by 2 asc

Likely you are going to see the following as the biggest table:

CHM.CHMOS_PROCESS_INT_TBL
CHM.CHMOS_DEVICE_INT_TBL

Truncate the table, i.e.:

SQL> truncate table CHM.CHMOS_PROCESS_INT_TBL;
SQL> truncate table CHM.CHMOS_DEVICE_INT_TBL;
..
\3. Shrink the tablespace:

\4. Enable and start ora.crf resource.

On each node, as root user:# /bin/crsctl modify res ora.crf -attr ENABLED=1 -init
\# /bin/crsctl start res ora.crf -init**

标签:

头像

小麦苗

学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

您可能还喜欢...

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

20 − 11 =

 

嘿,我是小麦,需要帮助随时找我哦
  • 18509239930
  • 个人微信

  • 麦老师QQ聊天
  • 个人邮箱
  • 点击加入QQ群
  • 个人微店

  • 回到顶部
返回顶部