Dec 27, 2015

Complete recovery of CDB, PDB and root in Oracle 12c

Here we will discuss how to restore root database, CDB ( container database) and PDB ( Plugable database) in Oracle 12c. This includes some new concepts like SYSBACKUP privilege and others. The below points are completely new in Oracle 12c. The Recovery Manager continues to enhance and extend the reliability, efficiency, and availability of Oracle Database Backup and Recovery.

Following topics are covered in this article:

1) SYSBACKUP previlege
2) Support for multitenant container and pluggable databases
3) Complete recovery of CDB, PDB and root
4) Backup of Archived redo logs
5) DUPLICATE enhancements

1) SYSBACKUP Privilege

Prior to 12c, users needed SYSDBA privilege to backup the database. The new SYSBACKUP privilege allows the user the permissions to perform only backup operations.
The SYSBACKUP privilege allows the DBA to perform RMAN backup commands without additional privileges. Using this new role in 12c, you can segregate Administration and Backup operations.
With RMAN you have same authentication options that are available with SQL*Plus, which are Operating system authentication and password file authentication.
To connect to RMAN using Operating system Authentication Authentication with the SYSBACKUP Privilege use:
$ rman target ' "/ as sysbackup" '
Authentication with the SYSDBA Privilege use:
$ rman target ' "/ as sysdba" '
You can also implicitly connect using below command
$ rman target /
To Connect to RMAN using Password file Authentication Authentication with the SYSBACKUP Privilege use:
$ rman target1 ‘ “bkpadm@DB1 as sysbackup” ‘
Where bkpadm is the user and should have SYSDBA privilege.
Authentication with the SYSDBA Privilege
$ rman target ‘ “sysadm@DB1 as sysdba” ‘
You can implicitly connect using below command. Where sysadm is the user and should have SYSDBA privilege.
$ rman target sysadm@DB1
Note that SYSBACKUP does not include data access privilege, such as SELECT ANY TABLE. When you don’t specify the role explicitly then the default used is AS SYSDBA.

2) Support for multitenant container and pluggable databases

The multitenant container database (CDB) and pluggable databases (PDB) are introduced in Oracle 12c, and RMAN provides full support for backup and recovery. Using RMAN you can back up an entire container database or individual pluggable databases and also can perform point-in-time recovery. But it is recommended that you turn on control file auto backup. Otherwise point-in-time recovery for pluggable databases may not work efficiently when you need to undo data file additions or deletions.
The multitenant architecture manages many databases as one and retains the isolation, resource control of each database. This will help to manage both infrastructure and human resources effectively.
Backing up a container database is similar to backing up a non-container database. When you back up a container database, RMAN backs up the root, pluggable databases in the container, and archive logs.  When you need to restore you can choose the whole container, one or more pluggable databases or the root only.

3) Backup the CDB, PDB, and root

You should have SYSBACKUP or SYSDBA privilege to backup any of the databases.

You can backup the Container Database (CDB) as same as non-container database using below command:

RMAN> BACKUP DATABASE plus ARCHIVELOG;
You can backup the Pluggable Database (PDB) using below command:
RMAN> BACKUP PLUGGABLE DATABASE PDB1, PDB2;
Or connect to pluggable Database in RMAN :
$ rman target sys@PDB1
RMAN> BACKUP DATABASE;
You can backup the root using below command:
RMAN> BACKUP DATABASE ROOT;

3) Complete recovery of CDB, PDB and root

You should have SYSBACKUP or SYSDBA privilege to restore any of the databases.
Restoring Container Database (CDB) is similar to non-container database.
You can restore the whole CDB using below script:
RMAN> RUN { 
     STARTUP MOUNT;
     RESTORE DATABASE;
     RECOVER DATABASE;
     ALTER DATABASE OPEN;
}
Note that restoring CDB database will restore all the pluggable databases.
You can restore only ROOT Database using below script:
RMAN> RUN {
     STARTUP MOUNT;
     RESTORE DATABASE ROOT;
     RECOVER DATABASE ROOT;
     ALTER DATABASE OPEN;
}
You can restore Pluggable Databases in two ways. Either you can restore from root container and connect directly to PDB to restore.
Use below script to restore from root. Using this approach you can able to restore and recover multiple PDB’s with a single command.
RMAN > RUN {
     RESTORE PLUGGABLE DATABASE PDB1, PDB2;
     RECOVER PLUGGABLE DATABASE PDB1, PDB2;
     ALTER PLUGGABLE DATABASE PDB1, PDB2 OPEN;
}
Use below script to connect PDB, restore and recover the database. Using this approach you will be able to restore and recover only one PDB.
$ rman target=bkpadm@PDB1
     RMAN> run{
     RESTORE DATABASE;
     RECOVER DATABASE;
}
The steps for performing a point-in-time recovery of the CDB or PDB are the same as a normal database. But note that when you perform Point-in-time recovery on the CDB, it will effect on all the PDBs as well.
When you perform point-in-time recovery on a PDB, it will affect that single database.
The command to perform a point-in-time recovery is:

SET UNTIL TIME "TO_DATE(’01-Jan-2014 01:00:00’,’DD-MON-YYYY HH24:MI:SS’)";
SET UNTIL SCN 1999945; # alternatively, specify SCN
SET UNTIL SEQUENCE 100; # alternatively, specify log seq
Below are the few examples to ALTER PLUGGABLE DATABASE.
  • Use this command to open all PDBs in one command:
    ALTER PLUGGABLE DATABASE ALL OPEN;
  • Use this command to open all PDBs except PDB3:
    ALTER PLUGGABLE DATABASE ALL EXCEPT PDB3 OPEN;
  • Use this command to open PDB4,PDB5 in read only mode:
    ALTER PLUGGABLE DATABASE PDB4, PDB5 OPEN READ ONLY;
  • Use below command to shut down all PDBs in single command:
    ALTER PLUGGABLE DATABASE ALL CLOSE IMMEDIATE;

4) Backup of Archived redo logs

You can back up archive logs when they connect to root as a common user with SYSDBA or SYSBACKUP privilege, but you cannot back up or delete archive logs when you connect to PDB as a local user with SYSDBA or SYSBACKUP privilege.
You are only able to switch the archived logs when you connect to the root of a CDB, but you cannot switch archived redo logs when connected to a PDB.
If you have more than one archive log destination, when you use RMAN to backup the archive redo logs it backs up only one copy of the archived redo logs. RMAN does not include more than one copy because multiple destinations will have same log sequence number.
You can use any of the below commands to backup the archived redo logs
The command below backs up the database and all the archived redo logs:
RMAN > BACKUP DATABASE PLUS ARCHIVELOG;
The command below only backs up one copy of the sequence number for all archived redo logs.
RMAN> BACKUP ARCHIVELOG ALL;

5) DUPLICATE enhancements:

When you duplicate a database using RMAN DUPLICATE, the database is created and opened with RESETLOGS mode. With Oracle database 12c, you can specify that the database must not be opened with “NOOPEN” clause.
This NOOPEN clause useful under following situations:
  • If you need to make changes to initialization parameters such as block change tracking, flashback database settings
  • Opening the database conflict with other source database
  • If you plan to create database for upgrade and want to open in upgrade mode
The command below creates duplicate database, but it will not open.

RMAN> DUPLICATE TARGET DATABASE TO DB1 FROM ACTIVE DATABASE NOOPEN;

Click here to read more on 12c RMAN enhancements

Hope this may help you as a fundamental document.

4 comments:

  1. Hi There,
    Thank you for sharing the knowledgeable blog with us I hope that you will post many more blog with us:-
    C D B! by Steig William from Flipkart.com. Only Genuine Products. 30 Day Replacement Guarantee. Free Shipping. Cash On Delivery!
    Email:info@chembase24.com
    Click here for more information:- more info

    ReplyDelete
  2. Hi There,
    Thank you for sharing the knowledgeable blog with us I hope that you will post many more blog with us:-
    Very potent opioid! FLUONITAZENE is an analgesic drug related to etonitazene, which was first reported in 1957, and has been shown to have approximately 20 times the potency of morphine by central routes of administration, but if used orally it has been shown to have approximately 1~2times the potency of morphine…:
    Email: mackush387@gmail.com
    Click here for more information:
    Wickr: realchemsupply
    WhatsApp: +12132939141
    Telegram: @realchemsupplier_bot

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete

Translate >>