Oracle 12c中的MGMTDB


Oracle 12c中的MGMTDB

原創 Oracle 作者: lhrbest 時間:2017-01-20 23:07:26 7741 0

MGMTDB系列

1  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.

    常用命令

srvctl stop mgmtdb

srvctl status mgmtdb

srvctl config mgmtdb

srvctl disable mgmtdb

srvctl disable mgmtlsnr

srvctl add mgmtdb

srvctl config mgmtdb

srvctl disable mgmtdb

srvctl enable mgmtdb

srvctl getenv mgmtdb

srvctl modify mgmtdb

srvctl relocate mgmtdb

srvctl remove mgmtdb

srvctl setenv mgmtdb

srvctl start mgmtdb

srvctl status mgmtdb

srvctl stop mgmtdb

srvctl unsetenv mgmtdb

srvctl add mgmtlsnr

srvctl config mgmtlsnr

srvctl disable mgmtlsnr

srvctl enable mgmtlsnr

srvctl getenv mgmtlsnr

srvctl modify mgmtlsnr

srvctl remove mgmtlsnr

srvctl setenv mgmtlsnr

srvctl start mgmtlsnr

srvctl status mgmtlsnr

srvctl stop mgmtlsnr

srvctl unsetenv mgmtlsnr



必須使用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 ~]# 





以下內容轉載於David Dai:http://www.cndba.cn/dave/article/248


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 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 數據庫,在目前的版本中,也不需要手工對其進行備份。






2       MGMTDB 基本操作

 

2.1        查看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 ~]#

 

 

2.2             啟動和關閉MGMT

正常情況下,MGMTDB 會在GI 啟動的時候,會自動啟動,但也可以手工管理,直接使用srvctl 操作即可:

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

Usage: srvctl start mgmtlsnr [-node ]



2.3        查看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 都在這個里。


 

3       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  'CH%' ;
  
USERNAME      ACCOUNT_STATUS  
------------- ----------------
CHM           OPEN
CHA           OPEN




4       移動MGMTDB 數據文件位置


默認情況下,MGMTDB 的數據文件是存放在OCR voting disk的磁盤組里的,為了節省OCR 磁盤組空間,我們也可以把MGMTDB 轉移走。


         當然,這里的移動位置,也是從一個共享位置移動到另一個共享位置。


具體操作如下。


在12.1.0.1 版本中有有問題,升級到12.1.0.2 解決。


4.1        停止並禁用ora.crf 資源


這里的ora.crf就是CHM。


在所有節點使用root用戶執行如下命令:


[root@rac1 ~]# crsctl stop res ora.crf -init
CRS-2673: Attempting to stop  'ora.crf'  on  'rac1'
CRS-2677: Stop of  'ora.crf'  on  'rac1'  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  '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 時會報錯。


4.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 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。



4.3           重建MGMTDB的CDB

4.3.1    12.1.0.1 執行如下命令


用grid用戶,在任意節點,執行如下命令,重建CDB。

$ /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


注意:

這里新的磁盤組,建議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 /]$



4.3.2    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]$




4.4        使用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]$


4.5        驗證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 磁盤組了。


 

4.6             啟用並啟動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]#


 


 

  MOS


 

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

In this Document

  Goal
  Solution


APPLIES TO:

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

GOAL

This 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 database

As 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 <+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.


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 <+NEW_DG> -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.

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 node

On :

$ /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
  Cause
  Solution
  References


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:

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

Bug 24331121 - 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 - 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:

https://docs.oracle.com/database/121/ADMIN/schema.htm#ADMIN11600

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM