注:本文谢绝转载!
在之前的Blog里介绍了Oracle12c RAC 中的MGMTDB的概念,参考:
Oracle 12cRAC MGMTDB 说明
http://www.cndba.cn/dave/article/248
而在默认情况下,MGMTDB 的数据文件是存放在OCR voting disk的磁盘组里的,为了节省OCR 磁盘组空间,我们也可以把MGMTDB 转移走。
当然,这里的移动位置,也是从一个共享位置移动到另一个共享位置。
具体操作如下。
这里的ora.crf就是CHM。
在所有节点使用root用户执行如下命令:
[root@rac1 ~]# crsctlstop res ora.crf -init
CRS-2673: Attempting to stop 'ora.crf' on'rac1'
CRS-2677: Stop of 'ora.crf' on 'rac1'succeeded
[root@rac1 ~]# crsctlmodify res ora.crf -attr ENABLED=0 -init
[root@rac1 ~]#
[root@rac2 ~]# crsctl stop res ora.crf-init
CRS-2673: Attempting to stop 'ora.crf' on'rac2'
CRS-2677: Stop of 'ora.crf' on 'rac2'succeeded
[root@rac2 ~]# crsctl modify res ora.crf-attr ENABLED=0 -init
[root@rac2 ~]#
注意:ora.mgmtlsnr 和 ora.mgmtdb资源不能停,否则DBCA 时会报错。
--查看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 networkconfiguration files
48% complete
52% complete
Deleting instance anddatafiles
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。
用grid用户,在任意节点,执行如下命令,重建CDB。
$
注意:
这里新的磁盘组,建议compatible.asm和 compatible.rdbms 属性都设置为12.1。
上面的命令使用的是磁盘组,如果是使用共享的NFS/CFS, 则使用如下命令:
我们这里数据库版本是12.1.0.1,并且使用的是磁盘组,所以执行第一个命令:
[grid@rac1 /]$ dbca -silent -createDatabase-templateName MGMTSeed_Database.dbc -sid -MGMTDB -gdbName _mgmtdb -storageTypeASM -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 GridInfrastructure
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 furtherdetails.
[grid@rac1 /]$
在任意节点,用grid用户执行如下命令:
--ASM 磁盘组:
$
--共享的NFS/CFS :
$
--示例:
[grid@rac1 templates]$ dbca -silent-createDatabase -sid -MGMTDB -createAsContainerDatabase true -templateNameMGMTSeed_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 GridInfrastructure
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 furtherdetails.
[grid@rac1 templates]$
[grid@rac1 templates]$ srvctl status mgmtdb
Database is enabled
Instance -MGMTDB is running on node rac1
[grid@rac1 templates]$
在任意节点,用grid用户执行dbca创建PDB,命令如下:
$
--查询集群的名称:
[grid@rac1 /]$ cemutlo -n
rac-scan
[grid@rac1 /]$
注意:默认情况CLUSTER_NAME 都是-,这里比如换成_
我们这里就要换成rac_scan
[grid@rac1 templates]$ dbca -silent-createPluggableDatabase -sourceDB -MGMTDB -pdbName rac_scan -createPDBFromRMANBACKUP -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" forfurther details.
[grid@rac1 templates]$
用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@rac1templates]$ 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@rac1templates]$
[grid@rac1 templates]$ exportORACLE_SID=-MGMTDB
[grid@rac1 templates]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production onWed Dec 10 21:39:13 2014
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise EditionRelease 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Managementand Advanced Analytics options
SQL> select file_name fromdba_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 磁盘组了。
在所有节点,用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 'ora.crf' on'rac1'
CRS-2676: Start of 'ora.crf' on 'rac1'succeeded
[root@rac1 u01]# oclumon manage -get master
Master = rac1
[root@rac1 u01]#
--------------------------------------------------------------------------------------------
版权所有,文章禁止转载,否则追究法律责任!
AboutDave:
--------------------------------------------------------------------------------------------
QQ:492913789
Email:[email protected]
Blog: http://www.cndba.cn/dave
Weibo: http://weibo.com/tianlesoftware
Twitter: http://twitter.com/tianlesoftware
Facebook: http://www.facebook.com/tianlesoftware
Linkedin: http://cn.linkedin.com/in/tianlesoftware
Dave 的QQ群:
--------------------------------------------------------------------------------------------
注意:加群必须注明表空间和数据文件关系 | 不要重复加群
CNDBA_1: 104207940 (满) CNDBA_2: 62697716 (满) CNDBA_3: 283816689
CNDBA_4: 391125754 CNDBA_5: 62697850 CNDBA_6: 62697977 CNDBA_7: 142216823(满)