Skip to content

Using RMAN Catalog in Data Guard Architecture (1/4) - GRANT CATALOG FOR DATABASE Clause

  • by
Go Back to Overview Page -Using RMAN Catalog in Data Guard Architecture (0/4) - An Overview
Here we demonstrate the first clause GRANT CATALOG FOR DATABASE.
  1. Create the catalog owner in the third database other than the primary and standby database.
  2. [oracle@primary01 ~]$ export ORACLE_SID=smalldb
    [oracle@primary01 ~]$ sqlplus / as sysdba
    ...
    SQL> create user catowner identified by password quota unlimited on users;

    User created.

    SQL> create user vpcowner identified by password quota unlimited on users;

    User created.

    SQL> grant recovery_catalog_owner to catowner;

    Grant succeeded.

    SQL> grant recovery_catalog_owner to vpcowner;

    Grant succeeded.

    recovery_catalog_owner is a role that has been granted several system privileges, so don't bother to grant "create session" or others.
  3. Create the base catalog.
  4. [oracle@primary01 ~]$ rman catalog catowner/password@smalldb
    ...
    connected to recovery catalog database

    RMAN> create catalog;

    recovery catalog created

    If you have ever created a catalog, RMAN will respond recovery catalog already exists. In such case, you must drop catalog before creating a new one.
  5. Register a database on the base catalog.
  6. You must connect to both the catalog and target database in order to register a database.
    [oracle@primary01 ~]$ rman catalog catowner/password@smalldb target sys/password@primdb1
    ...
    connected to target database: COMPDB (DBID=841830157)
    connected to recovery catalog database

    RMAN> register database;

    database registered in recovery catalog
    starting full resync of recovery catalog
    full resync complete

    RMAN> list db_unique_name all;


    List of Databases
    DB Key  DB Name  DB ID            Database Role    Db_unique_name
    ------- ------- ----------------- ---------------  ------------------
    2       COMPDB   841830157        PRIMARY          PRIMDB

    The primary database has been registered like the above result, should we register the standby database? The answer is no. If you did, you will get errors because of the same DBID. Actually, you don't have to register the standby database. You can connect to the target database to resync the metadata of the standby database by the following way.
  7. Connect to the standby database, the catalog will record the db_unique_name of the standby database automatically.
  8. [oracle@primary01 ~]$ rman catalog catowner/password@smalldb target sys/password@standb1
    ...
    connected to target database: COMPDB (DBID=841830157, not open)
    connected to recovery catalog database

    RMAN> list db_unique_name all;


    List of Databases
    DB Key  DB Name  DB ID            Database Role    Db_unique_name
    ------- ------- ----------------- ---------------  ------------------
    2       COMPDB   841830157        PRIMARY          PRIMDB
    2       COMPDB   841830157        STANDBY          STANDB
    ...
    [oracle@primary01 ~]$ rman catalog catowner/password@smalldb
    ...
    connected to recovery catalog database

    RMAN> list db_unique_name all;


    List of Databases
    DB Key  DB Name  DB ID            Database Role    Db_unique_name
    ------- ------- ----------------- ---------------  ------------------
    2       COMPDB   841830157        PRIMARY          PRIMDB
    2       COMPDB   841830157        STANDBY          STANDB
    ...

    You can also use resync catalog command to get the metadata of the standby database.
  9. List all databases under vpcowner before granting catalog. Of course, we will get errors.
  10. [oracle@primary01 ~]$ rman catalog vpcowner/password@smalldb
    ...
    connected to recovery catalog database

    RMAN> list db_unique_name all;

    recovery catalog is not installed
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of list command at 12/19/2012 10:15:27
    RMAN-06428: recovery catalog is not installed

    RMAN> create virtual catalog;

    found ineligible base catalog owned by CATOWNER
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-06801: no base catalog found

  11. Grant catalog for database COMPDB to the virtual catalog owner by the base catalog owner.
  12. [oracle@primary01 ~]$ rman catalog catowner/password@smalldb
    ...
    connected to recovery catalog database

    RMAN> grant catalog for database COMPDB to vpcowner;

    Grant succeeded.
    ...

  13. List all databases under vpcowner after granting catalog.
  14. [oracle@primary01 ~]$ rman catalog vpcowner/password@smalldb
    ...
    connected to recovery catalog database

    RMAN> list db_unique_name all;

    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of list command at 12/19/2012 11:02:56
    RMAN-06428: recovery catalog is not installed

    This error notifies you that no virtual catalog is found. So, let's create it.
    RMAN> create virtual catalog;

    found eligible base catalog owned by CATOWNER
    created virtual catalog against base catalog owned by CATOWNER

    RMAN> list db_unique_name all;


    List of Databases
    DB Key  DB Name  DB ID            Database Role    Db_unique_name
    ------- ------- ----------------- ---------------  ------------------
    2       COMPDB   841830157        PRIMARY          PRIMDB
    2       COMPDB   841830157        STANDBY          STANDB
    ...

    Issuing CREATE VIRTUAL CATALOG by the virtual catalog owner must be after GRANT clauses issued by the base catalog owner.
  15. Backup the primary database by vpcowner to test the virtual private catalog.
  16. [oracle@primary01 ~]$ rman catalog vpcowner/password@smalldb target sys/password@primdb1
    ...
    connected to target database: COMPDB (DBID=841830157)
    connected to recovery catalog database

    RMAN> list db_unique_name all;


    List of Databases
    DB Key  DB Name  DB ID            Database Role    Db_unique_name
    ------- ------- ----------------- ---------------  ------------------
    2       COMPDB   841830157        PRIMARY          PRIMDB
    2       COMPDB   841830157        STANDBY          STANDB

    RMAN> list backup;


    List of Backup Sets
    ===================


    ...

    RMAN> backup database;

    Starting backup at 20-DEC-12
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=120 instance=primdb1 device type=DISK
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00001 name=+DATA/primdb/datafile/system.897.797943475
    input datafile file number=00002 name=+DATA/primdb/datafile/sysaux.898.797943569
    input datafile file number=00003 name=+DATA/primdb/datafile/undotbs1.899.797943687
    input datafile file number=00005 name=+DATA/primdb/datafile/example.900.797943711
    input datafile file number=00006 name=+DATA/primdb/datafile/undotbs2.901.797943737
    input datafile file number=00004 name=+DATA/primdb/datafile/users.902.797943753
    channel ORA_DISK_1: starting piece 1 at 20-DEC-12
    channel ORA_DISK_1: finished piece 1 at 20-DEC-12
    piece handle=+DATA/primdb/backupset/2012_12_18/nnndf0_tag20121220t112923_0.1105.802351769 tag=TAG20121220t112923 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:03:46
    Finished backup at 20-DEC-12

    Starting Control File and SPFILE Autobackup at 20-DEC-12
    piece handle=+DATA/primdb/autobackup/2012_12_18/s_802351993.1106.802351999 comment=NONE
    Finished Control File and SPFILE Autobackup at 20-DEC-12

    RMAN> list backup;


    List of Backup Sets
    ===================


    ...
    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    1674    Full    1.17G      DISK        00:03:39     20-DEC-12
            BP Key: 1677   Status: AVAILABLE  Compressed: NO  Tag: TAG20121220t112923
            Piece Name: +DATA/primdb/backupset/2012_12_18/nnndf0_tag20121220t112923_0.1105.802351769
      List of Datafiles in backup set 1674
      File LV Type Ckp SCN    Ckp Time  Name
      ---- -- ---- ---------- --------- ----
      1       Full 3049332    20-DEC-12 +DATA/primdb/datafile/system.897.797943475
      2       Full 3049332    20-DEC-12 +DATA/primdb/datafile/sysaux.898.797943569
      3       Full 3049332    20-DEC-12 +DATA/primdb/datafile/undotbs1.899.797943687
      4       Full 3049332    20-DEC-12 +DATA/primdb/datafile/users.902.797943753
      5       Full 3049332    20-DEC-12 +DATA/primdb/datafile/example.900.797943711
      6       Full 3049332    20-DEC-12 +DATA/primdb/datafile/undotbs2.901.797943737

    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    1690    Full    18.64M     DISK        00:00:06     20-DEC-12
            BP Key: 1697   Status: AVAILABLE  Compressed: NO  Tag: TAG20121220t113313
            Piece Name: +DATA/primdb/autobackup/2012_12_18/s_802351993.1106.802351999
      SPFILE Included: Modification time: 20-DEC-12
      SPFILE db_unique_name: PRIMDB
      Control File Included: Ckp SCN: 3049885      Ckp time: 20-DEC-12

    It shows the virtual private catalog is working.
  17. Backup the standby database by vpcowner to test the virtual private catalog.
  18. [oracle@primary01 ~]$ rman catalog vpcowner/password@smalldb target sys/password@standb1
    ...
    connected to target database: COMPDB (DBID=841830157, not open)
    connected to recovery catalog database

    RMAN> list backup;


    List of Backup Sets
    ===================


    ...

    RMAN> backup database;

    Starting backup at 20-DEC-12
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=76 instance=standb1 device type=DISK
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00001 name=+DATA/standb/datafile/system.273.799012455
    input datafile file number=00002 name=+DATA/standb/datafile/sysaux.272.799012459
    input datafile file number=00003 name=+DATA/standb/datafile/undotbs1.271.799012465
    input datafile file number=00005 name=+DATA/standb/datafile/example.270.799012469
    input datafile file number=00006 name=+DATA/standb/datafile/undotbs2.269.799012475
    input datafile file number=00004 name=+DATA/standb/datafile/users.268.799012479
    channel ORA_DISK_1: starting piece 1 at 20-DEC-12
    channel ORA_DISK_1: finished piece 1 at 20-DEC-12
    piece handle=+DATA/standb/backupset/2012_12_18/nnndf0_tag20121220t135847_0.1096.802360729 tag=TAG20121220t135847 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:05:15
    Finished backup at 20-DEC-12

    Starting Control File and SPFILE Autobackup at 20-DEC-12
    piece handle=+DATA/standb/autobackup/2012_12_18/s_802349257.1097.802361047 comment=NONE
    Finished Control File and SPFILE Autobackup at 20-DEC-12

    RMAN> list backup;


    List of Backup Sets
    ===================


    ...
    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    1763    Full    1.18G      DISK        00:05:13     20-DEC-12
            BP Key: 1767   Status: AVAILABLE  Compressed: NO  Tag: TAG20121220t135847
            Piece Name: +DATA/standb/backupset/2012_12_18/nnndf0_tag20121220t135847_0.1096.802360729
      List of Datafiles in backup set 1763
      File LV Type Ckp SCN    Ckp Time  Name
      ---- -- ---- ---------- --------- ----
      1       Full 3040541    20-DEC-12 +DATA/standb/datafile/system.273.799012455
      2       Full 3040541    20-DEC-12 +DATA/standb/datafile/sysaux.272.799012459
      3       Full 3040541    20-DEC-12 +DATA/standb/datafile/undotbs1.271.799012465
      4       Full 3040541    20-DEC-12 +DATA/standb/datafile/users.268.799012479
      5       Full 3040541    20-DEC-12 +DATA/standb/datafile/example.270.799012469
      6       Full 3040541    20-DEC-12 +DATA/standb/datafile/undotbs2.269.799012475

    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    1764    Full    18.64M     DISK        00:00:06     20-DEC-12
            BP Key: 1768   Status: AVAILABLE  Compressed: NO  Tag: TAG20121220t140404
            Piece Name: +DATA/standb/autobackup/2012_12_18/s_802349257.1097.802361047
      SPFILE Included: Modification time: 20-DEC-12
      SPFILE db_unique_name: STANDB
      Standby Control File Included: Ckp SCN: 3040541      Ckp time: 20-DEC-12
    ...

  19. Check the base catalog by catowner. First, we connect to the primary database.
  20. [oracle@primary01 ~]$ rman catalog catowner/password@smalldb target sys/password@primdb1
    ...
    connected to target database: COMPDB (DBID=841830157)
    connected to recovery catalog database

    RMAN> list backup;


    List of Backup Sets
    ===================


    ...
    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    1674    Full    1.17G      DISK        00:03:39     20-DEC-12
            BP Key: 1677   Status: AVAILABLE  Compressed: NO  Tag: TAG20121220t112923
            Piece Name: +DATA/primdb/backupset/2012_12_18/nnndf0_tag20121220t112923_0.1105.802351769
      List of Datafiles in backup set 1674
      File LV Type Ckp SCN    Ckp Time  Name
      ---- -- ---- ---------- --------- ----
      1       Full 3049332    20-DEC-12 +DATA/primdb/datafile/system.897.797943475
      2       Full 3049332    20-DEC-12 +DATA/primdb/datafile/sysaux.898.797943569
      3       Full 3049332    20-DEC-12 +DATA/primdb/datafile/undotbs1.899.797943687
      4       Full 3049332    20-DEC-12 +DATA/primdb/datafile/users.902.797943753
      5       Full 3049332    20-DEC-12 +DATA/primdb/datafile/example.900.797943711
      6       Full 3049332    20-DEC-12 +DATA/primdb/datafile/undotbs2.901.797943737

    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    1690    Full    18.64M     DISK        00:00:06     20-DEC-12
            BP Key: 1697   Status: AVAILABLE  Compressed: NO  Tag: TAG20121220t113313
            Piece Name: +DATA/primdb/autobackup/2012_12_18/s_802351993.1106.802351999
      SPFILE Included: Modification time: 20-DEC-12
      SPFILE db_unique_name: PRIMDB
      Control File Included: Ckp SCN: 3049885      Ckp time: 20-DEC-12

    Second, we connect to the standby database.
    [oracle@primary01 ~]$ rman catalog catowner/password@smalldb target sys/password@standb1
    ...
    connected to target database: COMPDB (DBID=841830157, not open)
    connected to recovery catalog database

    RMAN> list backup;


    List of Backup Sets
    ===================


    ...
    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    1763    Full    1.18G      DISK        00:05:13     20-DEC-12
            BP Key: 1767   Status: AVAILABLE  Compressed: NO  Tag: TAG20121220t135847
            Piece Name: +DATA/standb/backupset/2012_12_18/nnndf0_tag20121220t135847_0.1096.802360729
      List of Datafiles in backup set 1763
      File LV Type Ckp SCN    Ckp Time  Name
      ---- -- ---- ---------- --------- ----
      1       Full 3040541    20-DEC-12 +DATA/standb/datafile/system.273.799012455
      2       Full 3040541    20-DEC-12 +DATA/standb/datafile/sysaux.272.799012459
      3       Full 3040541    20-DEC-12 +DATA/standb/datafile/undotbs1.271.799012465
      4       Full 3040541    20-DEC-12 +DATA/standb/datafile/users.268.799012479
      5       Full 3040541    20-DEC-12 +DATA/standb/datafile/example.270.799012469
      6       Full 3040541    20-DEC-12 +DATA/standb/datafile/undotbs2.269.799012475

    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    1764    Full    18.64M     DISK        00:00:06     20-DEC-12
            BP Key: 1768   Status: AVAILABLE  Compressed: NO  Tag: TAG20121220t140404
            Piece Name: +DATA/standb/autobackup/2012_12_18/s_802349257.1097.802361047
      SPFILE Included: Modification time: 20-DEC-12
      SPFILE db_unique_name: STANDB
      Standby Control File Included: Ckp SCN: 3040541      Ckp time: 20-DEC-12


Using RMAN Catalog in Data Guard Architecture (2/4) - GRANT REGISTER DATABASE Clause

Leave a Reply

Your email address will not be published.