戴明明(Dave)
Oracle ACE-A,ACOUG核心成员,宝存科技数据库方案架构师
Dave也是CSDN 认证专家,超过7年的DBA经验,擅长Oracle数据库诊断、性能调优,热衷于Oracle 技术的研究与分享。从14年开始研究基于PCIe闪存卡的数据库高可用,高性能解决方案。
编辑手记:感谢Dave授权我们转载其技术文章,他在博客时代书写的大量文章影响了DBA领域的很多朋友,现在我们精选他的文章,让更多读者受益。
MGMTDB 的数据文件是存放在OCR voting disk的磁盘组里的,为了节省OCR 磁盘组空间,我们也可以把MGMTDB 转移走。而有时候如果不了解12c的这一特性,可能会遇到OCR空间紧张的情况。当然,这里的移动位置,也是从一个共享位置移动到另一个共享位置。
相关阅读:
12c特性解读:RAC MGMTDB资料库新特性说明及初相识
监控工具:Oracle 12c Cluster Health Monitor 详解
以下测试说明这个转移的过程和步骤。
1 停止并禁用ora.crf 资源
这里的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 时会报错。
2 执行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 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。
3 重建MGMTDB的CDB
12.1.0.1 执行如下命令
用grid用户,在任意节点,执行如下命令,重建CDB。
$ <GI_HOME>/bin/dbca -silent-createDatabase -templateName MGMTSeed_Database.dbc -sid -MGMTDB -gdbName_mgmtdb -storageType ASM -diskGroupName <+NEW_DG> -datafileJarLocation<GI_HOME>/assistants/dbca/templates -characterset AL32UTF8-autoGeneratePasswords -oui_internal
注意:这里新的磁盘组,建议compatible.asm和 compatible.rdbms 属性都设置为12.1。
上面的命令使用的是磁盘组,如果是使用共享的NFS/CFS, 则使用如下命令:
<GI_HOME>/bin/dbca -silent-createDatabase -templateName MGMTSeed_Database.dbc -sid -MGMTDB -gdbName_mgmtdb -storageType FS -datafileDestination <NFS_Location>-datafileJarLocation <GI_HOME>/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 -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 ]$
12.1.0.2 执行如下命令
在任意节点,用grid用户执行如下命令:
--ASM 磁盘组:
$ <GI_HOME>/bin/dbca -silent-createDatabase -sid -MGMTDB -createAsContainerDatabasetrue -templateName MGMTSeed_Database.dbc -gdbName _mgmtdb -storageType ASM-diskGroupName <+NEW_DG> -datafileJarLocation$GRID_HOME/assistants/dbca/templates-characterset AL32UTF8 -autoGeneratePasswords -skipUserTemplateCheck
--共享的NFS/CFS :
$<GI_HOME>/bin/dbca -silent-createDatabase -templateName MGMTSeed_Database.dbc -sid -MGMTDB -gdbName_mgmtdb -storageType FS -datafileDestination <NFS_Location>-datafileJarLocation <GI_HOME>/assistants/dbca/templates -charactersetAL32UTF8 -autoGeneratePasswords -oui_internal
--示例:
[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]$
使用DBCA 创建PDB
[grid@rac1 templates]$ srvctl status mgmtdb
Database is enabled
Instance -MGMTDB is running on node rac1
[grid@rac1 templates]$
在任意节点,用grid用户执行dbca创建PDB,命令如下:
$ <GI_HOME>/bin/dbca -silent-createPluggableDatabase -sourceDB -MGMTDB -pdbName <CLUSTER_NAME>-createPDBFrom RMANBACKUP -PDBBackUpfile<GI_HOME>/assistants/dbca/templates/mgmtseed_pdb.dfb -PDBMetadataFile<GI_HOME>/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 -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.
验证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@rac1templates]$ srvctl config mgmtdb
Database unique name:_mgmtdb
Database name:
Oracle home: <CRShome>
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.
数据文件已经转移到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 '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]#
搜索 盖国强(Eygle) :eeygle,或者扫描下面二维码,备注:云和恩墨大讲堂,即可入群。每周与千人共享免费技术分享,与讲师在线讨论。
(OraNews)回复关键字获取
2016DTCC, 2016数据库大会PPT;
DBALife,"DBA的一天"精品海报大图;
12cArch,“Oracle 12c体系结构”精品海报;
DBA01,《Oracle DBA手记》第一本下载;
YunHe,“云和恩墨大讲堂”案例文档下载;