How to manually drop/recreate MGMTDB Database - Oracle Rac One Node 12.2

Hi everyone,
Today in this article I would like to share my experience regarding drop/recreate the MGMTDB in order to purge the repository and free some space from ASM Disk Group.
I was going to perform a migration from Oracle Database 12.2 Single Instance to an Oracle Database 12.2 Rac One Node, when I found something bizarre. The “+DATA” diskgroup was 59GB of used space and it was a fresh installation (Only few weeks waiting for the “GO” to migrate without any database).
After performing the actions below, I was able free / to get back about 20GB.
Documents used in this procedure:
  • How to Move/Recreate GI Management Repository (GIMR / MGMTDB) to Different Shared Storage (Diskgroup, CFS or NFS etc) (Doc ID 1589394.1)
  • 12.2: How to Create GI Management Repository (Doc ID 2246123.1)
  • MDBUtil: GI Management Repository configuration tool (Doc ID 2065175.1)
Steps:
[oracle@lab-dev-datad1 ~]$ . oraenv

 ORACLE_SID = [+ASM1] ? +ASM1

 The Oracle base remains unchanged with value /u01/base




[oracle@lab-dev-datad1 ~]$ ps -ef | grep pmon
 oracle   19280     1  0 08:21 ?        00:00:00 asm_pmon_+ASM1
 oracle   21769     1  0 08:21 ?        00:00:00 mdb_pmon_-MGMTDB
 oracle   22655 29118  0 11:05 pts/1    00:00:00 grep --color=auto pmon

[oracle@lab-dev-datad1 ~]$ asmcmd lsdg
[oracle@lab-dev-datad1 ~]$ asmcmd -p




ASMCMD [+] > ls -l



State    Type    Rebal  Name



MOUNTED  EXTERN  N      DATA/



MOUNTED  EXTERN  N      FRA/



ASMCMD [+] >

ASMCMD [+] > du FRA




Used_MB      Mirror_used_MB




   2268                2268

ASMCMD [+] > du DATA



Used_MB      Mirror_used_MB



  59292               59292

ASMCMD [+] > cd DATA

ASMCMD [+DATA] > ls -l




Type      Redund  Striped  Time             Sys  Name




                                            Y    ASM/




                                            N    _mgmtdb/




                                            Y    dev-data-clu/




PASSWORD  UNPROT  COARSE   JUL 09 16:00:00  N    orapwasm => +DATA/ASM/PASSWORD/pwdasm.256.1013185265




PASSWORD  UNPROT  COARSE   JUL 09 16:00:00  N    orapwasm_backup => +DATA/ASM/PASSWORD/pwdasm.257.1013185629

ASMCMD [+DATA] > du ASM



Used_MB      Mirror_used_MB



      0                   0

ASMCMD [+DATA] > du _mgmtdb/



Used_MB      Mirror_used_MB



  57776               57776
 
Stopping required resources in both nodes:
As root user, from Grid Home:

 

[root@lab-dev-datad1 ~]# /u01/oracle/base/product/12.2.0/grid/bin/crsctl stop res ora.crf -init

 CRS-2673: Attempting to stop 'ora.crf' on 'lab-dev-datad1'

 CRS-2677: Stop of 'ora.crf' on 'lab-dev-datad1' succeeded




[root@lab-dev-datad2 ~]# /u01/oracle/base/product/12.2.0/grid/bin/crsctl stop res ora.crf -init

 CRS-2673: Attempting to stop 'ora.crf' on 'lab-dev-datad2'

 CRS-2677: Stop of 'ora.crf' on 'lab-dev-datad2' succeeded




[root@lab-dev-datad1 ~]# /u01/oracle/base/product/12.2.0/grid/bin/crsctl modify res ora.crf -attr ENABLED=0 -init

[root@lab-dev-datad2 ~]# /u01/oracle/base/product/12.2.0/grid/bin/crsctl modify res ora.crf -attr ENABLED=0 -init
 
Validate MGMTDB database status:

 

[root@lab-dev-datad1 ~]# /u01/oracle/base/product/12.2.0/grid/bin/srvctl status mgmtdb
 Database is enabled
 Instance -MGMTDB is running on node lab-dev-datad1
 
Deleting MGMTDB using DBCA in silent mode:
As oracle user:

 

[oracle@lab-dev-datad1 ~]$ /u01/oracle/base/product/12.2.0/grid/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
 52% complete
 Deleting instance and datafiles
 76% complete
 100% complete
 Look at the log file "/u01/base/cfgtoollogs/dbca/_mgmtdb.log" for further details.
 
Validate the current space from “+DATA” diskgroup:

 

[oracle@lab-dev-datad1 ~]$ asmcmd lsdg
In order to recreate the MGMTDB in Oracle Database 12/R2 (12.2), is required to use a perl script (mdbutil.pl), that you can download from here:
  • MDBUtil: GI Management Repository configuration tool (Doc ID 2065175.1)
Recreating MGMTDB:
Listing options:

 

[oracle@lab-dev-datad1 ~]$ ./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
 
Launch MGMTDB creation:

 

[oracle@lab-dev-datad1 ~]$ ./mdbutil.pl --addmdb --target=+DATA

mdbutil.pl version : 1.98

 2019-10-04 11:32:18: I Starting To Configure MGMTDB at +DATA…

 2019-10-04 11:32:21: I Container database creation in progress… for GI 12.2.0.1.0

 2019-10-04 11:42:13: I Plugable database creation in progress…

 2019-10-04 11:47:20: I Executing "/tmp/mdbutil.pl --addchm" on lab-dev-datad1 as root to configure CHM.

 root@lab-dev-datad1's password:

 2019-10-04 11:49:50: I MGMTDB & CHM configuration done!

 root@lab-dev-datad2's password:

 2019-10-04 11:49:50: I MGMTDB & CHM configuration done!

 

Modifying back the resource ora.crf in both nodes:
As root user, from Grid Home:

 

[root@lab-dev-datad1 ~]# /u01/oracle/base/product/12.2.0/grid/bin/crsctl modify res ora.crf -attr ENABLED=1 -init

[root@lab-dev-datad1 ~]# /u01/oracle/base/product/12.2.0/grid/bin/crsctl start res ora.crf -init
 CRS-2672: Attempting to start 'ora.crf' on 'lab-dev-datad1'
 CRS-2676: Start of 'ora.crf' on 'lab-dev-datad1' succeeded

[root@lab-dev-datad2 ~]# /u01/oracle/base/product/12.2.0/grid/bin/crsctl modify res ora.crf -attr ENABLED=1 -init

[root@lab-dev-datad2 ~]# /u01/oracle/base/product/12.2.0/grid/bin/crsctl start res ora.crf -init
 CRS-2672: Attempting to start 'ora.crf' on 'lab-dev-datad2'
 CRS-2676: Start of 'ora.crf' on 'lab-dev-datad2' succeeded

[oracle@lab-dev-datad1 ~]$ /u01/oracle/base/product/12.2.0/grid/bin/srvctl status mgmtdb

 Database is enabled

 Instance -MGMTDB is running on node lab-dev-datad1

 

Validate the current size after MGMTDB database creation:

 

[oracle@lab-dev-datad1 ~]$ asmcmd lsdg

 

 

[oracle@lab-dev-datad1 ~]$ asmcmd -p

ASMCMD [+] > ls -l



State    Type    Rebal  Name



MOUNTED  EXTERN  N      DATA/



MOUNTED  EXTERN  N      FRA/

ASMCMD [+] > du DATA Used_MB      Mirror_used_MB   34256               34256

 

From Oracle 12.2 Standalone Cluster is required at least 37.6GB only for MGMTDB

 

Oracle Clusterware Storage Space Requirements (12.2)

 

 

 

See you in the next post!

 

Leonardo Lopes