閱讀422 返回首頁    go 阿裏雲 go 技術社區[雲棲]


12c特性解讀:RAC MGMTDB資料庫的轉移與維護

640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=
戴明明(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]#

 

文章轉自數據和雲公眾號,原文鏈接

最後更新:2017-07-18 11:33:34

  上一篇:go  監控工具:Oracle 12c Cluster Health Monitor 詳解
  下一篇:go  Performing Data Write Operations with MongoDB