Tuesday, 9 March 2021

Multitenant : Backup and Recovery of a Container Database (CDB) and a Pluggable Database (PDB) in Oracle Database 12c Release 1 (12.1)

 

Multitenant : Backup and Recovery of a Container Database (CDB) and a Pluggable Database (PDB) in Oracle Database 12c Release 1 (12.1)

The multitenant option brings with it a number of changes to the way we approach backup and recovery. This article provides a top-level view of what is available for basic backup and recovery of CDBs and PDBs.

 

This article does not include any mention of Flashback Database or general RMAN new features, which will be covered in a separate articles.

 

Backup

·         Container Database (CDB) Backup

·         Root Container Backup

·         Pluggable Database (PDB) Backup

·         Tablespace and Datafile Backups

·         Archived Redo Log Backups

Complete Recovery

·         Container Database (CDB) Complete Recovery

·         Root Container Complete Recovery

·         Pluggable Database (PDB) Complete Recovery

·         Tablespace and Datafile Complete Recovery

Point In Time Recovery (PITR)

·         Container Database (CDB) Point In Time Recovery (PITR)

·         Pluggable Database (PDB) Point In Time Recovery (PITR)

·         Table Point In Time Recovery (PITR) in PDBs

 

RMAN Connections

Unless stated otherwise, this article assumes connections to RMAN are using OS authentication. This means you are connecting to the root container in the CDB with "AS SYSDBA" privilege.

 

$ export ORAENV_ASK=NO

$ export ORACLE_SID=cdb1

$ . oraenv

The Oracle base remains unchanged with value /u01/app/oracle

$ export ORAENV_ASK=YES

 

$ rman target=/

Recovery Manager: Release 12.1.0.1.0 - Production on Sun Dec 22 17:03:20 2013

 

Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: CDB1 (DBID=797615285)

 

RMAN>

When connecting to a PDB to perform backup and recovery operations, the RMAN connection will look like the following. Notice the password prompt as no password was entered on the command line.

 

$ rman target=sys@pdb1

Recovery Manager: Release 12.1.0.1.0 - Production on Mon Dec 23 11:08:35 2013

 

Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.

 

target database Password:

connected to target database: CDB1 (DBID=797615285)

 

RMAN>

Backup

Container Database (CDB) Backup

Backup of a Container Database (CDB) is essentially the same as a non-Container Database. The main thing to remember is, by doing a full backup of the CDB you are also doing a full backup of all PDBs.

 

Connect to RMAN using OS authentication and take a full backup using the following command. This means you are connecting to the root container with "AS SYSDBA" privilege.

 

$ rman target=/

 

RMAN> BACKUP DATABASE PLUS ARCHIVELOG;

A section of the output from the above backup command is shown below. Notice how the datafiles associated with the CBD (cdb1) and all the PDBs (pdb1, pdb2, pdb$seed) are included in the backup.

 

Starting backup at 22-DEC-13

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00003 name=/u01/app/oracle/oradata/cdb1/sysaux01.dbf

input datafile file number=00001 name=/u01/app/oracle/oradata/cdb1/system01.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/cdb1/undotbs01.dbf

input datafile file number=00006 name=/u01/app/oracle/oradata/cdb1/users01.dbf

channel ORA_DISK_1: starting piece 1 at 22-DEC-13

channel ORA_DISK_1: finished piece 1 at 22-DEC-13

piece handle=/u01/app/oracle/fast_recovery_area/CDB1/backupset/2013_12_22/o1_mf_nnndf_TAG20131222T163015_9cg4wr40_.bkp tag=TAG20131222T163015 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00009 name=/u01/app/oracle/oradata/cdb1/pdb1/sysaux01.dbf

input datafile file number=00008 name=/u01/app/oracle/oradata/cdb1/pdb1/system01.dbf

input datafile file number=00010 name=/u01/app/oracle/oradata/cdb1/pdb1/pdb1_users01.dbf

channel ORA_DISK_1: starting piece 1 at 22-DEC-13

channel ORA_DISK_1: finished piece 1 at 22-DEC-13

piece handle=/u01/app/oracle/fast_recovery_area/CDB1/E45393F0DE5F1A8AE043D200A8C00DFC/backupset/2013_12_22/o1_mf_nnndf_TAG20131222T163015_9cg4z3so_.bkp tag=TAG20131222T163015 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00030 name=/u01/app/oracle/oradata/pdb2/sysaux01.dbf

input datafile file number=00029 name=/u01/app/oracle/oradata/pdb2/system01.dbf

input datafile file number=00031 name=/u01/app/oracle/oradata/pdb2/pdb2_users01.dbf

channel ORA_DISK_1: starting piece 1 at 22-DEC-13

channel ORA_DISK_1: finished piece 1 at 22-DEC-13

piece handle=/u01/app/oracle/fast_recovery_area/CDB1/E4B0CA84B47E6183E043D200A8C0A806/backupset/2013_12_22/o1_mf_nnndf_TAG20131222T163015_9cg50766_.bkp tag=TAG20131222T163015 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00007 name=/u01/app/oracle/oradata/cdb1/pdbseed/sysaux01.dbf

input datafile file number=00005 name=/u01/app/oracle/oradata/cdb1/pdbseed/system01.dbf

channel ORA_DISK_1: starting piece 1 at 22-DEC-13

channel ORA_DISK_1: finished piece 1 at 22-DEC-13

piece handle=/u01/app/oracle/fast_recovery_area/CDB1/E453004B82C71772E043D200A8C08EC5/backupset/2013_12_22/o1_mf_nnndf_TAG20131222T163015_9cg51bmg_.bkp tag=TAG20131222T163015 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:36

Finished backup at 22-DEC-13

Root Container Backup

A backup of the root container is a backup of the CDB, excluding any of the PDBs.

 

Connect to RMAN using OS authentication and backup the root container using the following command. This means you are connecting to the root container with "AS SYSDBA" privilege.

 

$ rman target=/

 

RMAN> BACKUP DATABASE ROOT;

A section of the output from the above backup command is shown below. Notice how the datafiles associated with the CBD (cdb1) are included, but all the PDBs (pdb1, pdb2, pdb$seed) are not included in the backup.

 

Starting backup at 23-DEC-13

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00003 name=/u01/app/oracle/oradata/cdb1/sysaux01.dbf

input datafile file number=00001 name=/u01/app/oracle/oradata/cdb1/system01.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/cdb1/undotbs01.dbf

input datafile file number=00006 name=/u01/app/oracle/oradata/cdb1/users01.dbf

channel ORA_DISK_1: starting piece 1 at 23-DEC-13

channel ORA_DISK_1: finished piece 1 at 23-DEC-13

piece handle=/u01/app/oracle/fast_recovery_area/CDB1/backupset/2013_12_23/o1_mf_nnndf_TAG20131223T112413_9cj7bxtg_.bkp tag=TAG20131223T112413 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:01:25

Finished backup at 23-DEC-13

Pluggable Database (PDB) Backup

There are two ways to back up pluggable databases. When connected to RMAN as the root container, you can backup one or more PDBs using the following command.

 

$ rman target=/

 

RMAN> BACKUP PLUGGABLE DATABASE pdb1, pdb2;

You can see this includes the datafiles for both referenced PDBs.

 

Starting backup at 23-DEC-13

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00009 name=/u01/app/oracle/oradata/cdb1/pdb1/sysaux01.dbf

input datafile file number=00008 name=/u01/app/oracle/oradata/cdb1/pdb1/system01.dbf

input datafile file number=00010 name=/u01/app/oracle/oradata/cdb1/pdb1/pdb1_users01.dbf

channel ORA_DISK_1: starting piece 1 at 23-DEC-13

channel ORA_DISK_1: finished piece 1 at 23-DEC-13

piece handle=/u01/app/oracle/fast_recovery_area/CDB1/E45393F0DE5F1A8AE043D200A8C00DFC/backupset/2013_12_23/o1_mf_nnndf_TAG20131223T113119_9cj7r8lp_.bkp tag=TAG20131223T113119 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00030 name=/u01/app/oracle/oradata/pdb2/sysaux01.dbf

input datafile file number=00029 name=/u01/app/oracle/oradata/pdb2/system01.dbf

input datafile file number=00031 name=/u01/app/oracle/oradata/pdb2/pdb2_users01.dbf

channel ORA_DISK_1: starting piece 1 at 23-DEC-13

channel ORA_DISK_1: finished piece 1 at 23-DEC-13

piece handle=/u01/app/oracle/fast_recovery_area/CDB1/E4B0CA84B47E6183E043D200A8C0A806/backupset/2013_12_23/o1_mf_nnndf_TAG20131223T113119_9cj7sfbx_.bkp tag=TAG20131223T113119 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35

Finished backup at 23-DEC-13

Alternatively, connect to a specific PDB and issue the following command.

 

$ rman target=sys@pdb1

 

RMAN> BACKUP DATABASE;

Being connected to the PDB, this limits the scope of the backup command to the current PDB only, as shown in the output below.

 

Starting backup at 23-DEC-13

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=237 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=00009 name=/u01/app/oracle/oradata/cdb1/pdb1/sysaux01.dbf

input datafile file number=00008 name=/u01/app/oracle/oradata/cdb1/pdb1/system01.dbf

input datafile file number=00010 name=/u01/app/oracle/oradata/cdb1/pdb1/pdb1_users01.dbf

channel ORA_DISK_1: starting piece 1 at 23-DEC-13

channel ORA_DISK_1: finished piece 1 at 23-DEC-13

piece handle=/u01/app/oracle/fast_recovery_area/CDB1/E45393F0DE5F1A8AE043D200A8C00DFC/backupset/2013_12_23/o1_mf_nnndf_TAG20131223T113504_9cj7z9kb_.bkp tag=TAG20131223T113504 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25

Finished backup at 23-DEC-13

Tablespace and Datafile Backups

Multiple PDBs in the same CDB can have a tablespace with the same name, for example SYSTEM, SYSAUX and USERS. One way to remove that ambiguity is connect to the appropriate PDB. Once RMAN is connected to the PDB, the tablespace backup commands is unchanged compared to previous versions.

 

$ rman target=sys@pdb1

 

RMAN> BACKUP TABLESPACE system, sysaux, users;

Alternatively, you can remove the ambiguity by qualifying the PDB name with the tablespace name when connected to the root container.

 

$ rman target=sys@cdb1

 

RMAN> BACKUP TABLESPACE pdb1:system, pdb1:sysaux, pdb1:users, pdb2:system;

Datafiles have unique file numbers and fully qualified names, so they can be backed up from the root container or the individual PDB.

 

$ rman target=/

 

# Or

 

$ rman target=sys@pdb1

 

RMAN> BACKUP DATAFILE 8, 9, 10;

If you are connecting to a PDB, only the files belonging to that PDB can be backed up. So for example, when connected as PDB1, we get an error if we try to backup the SYSTEM datafile from the root container.

 

RMAN> BACKUP DATAFILE 1;

 

Starting backup at 23-DEC-13

using channel ORA_DISK_1

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of backup command at 12/23/2013 11:49:35

RMAN-20201: datafile not found in the recovery catalog

RMAN-06010: error while looking up datafile: 1

 

RMAN>

Control file Backup after connecting from PDB Database in 19c

C:\Users\admin>rman target=pdb1


Recovery Manager: Release 19.0.0.0.0 - Production on Wed Mar 10 11:19:54 2021

Version 19.3.0.0.0


Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.


target database Password:

connected to target database: CDB2 (DBID=806790950)


RMAN> backup current controlfile;


Starting backup at 10-MAR-21

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=25 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

channel ORA_DISK_1: starting piece 1 at 10-MAR-21

channel ORA_DISK_1: finished piece 1 at 10-MAR-21

piece handle=F:\ORACLE_DATABASE\DATABASE\01VPCQ1G_1_1 tag=TAG20210310T112120 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 10-MAR-21


Starting Control File and SPFILE Autobackup at 10-MAR-21

piece handle=F:\ORACLE_DATABASE\DATABASE\C-806790950-20210310-00 comment=NONE

Finished Control File and SPFILE Autobackup at 10-MAR-21


RMAN>


Archived Redo Log Backups

Redo is managed at the root container level. There is no concept of redo from the PDB perspective, but of course any changes in tablespaces owned by the root container or a user-defined PDB are protected by redo in the normal manner. As a result, you will never perform a PDB-level archived redo log backup, because there are no PDB-specific redo logs. Instead, you will do your archived redo log backups in the normal way from the root container. They can be done along with the database backups or as a separate operation, as shown below.

 

$ rman target=/

 

RMAN> BACKUP DATABASE PLUS ARCHIVELOG;

 

RMAN> BACKUP ARCHIVELOG ALL;

Complete Recovery

Container Database (CDB) Complete Recovery

Restoring a CDB is similar to restoring a non-CDB database, but remember restoring a whole CDB will restore not only the root container, but all the PDBs also. Likewise a Point In Time Recovery (PITR) of the whole CDB will bring all PDBs back to the same point in time.

 

Connect to RMAN using OS authentication and restore the whole CDB using the following restore script. This means you are connecting to the root container with "AS SYSDBA" privilege.

 

$ rman target=/

 

RUN {

  SHUTDOWN IMMEDIATE; # use abort if this fails

  STARTUP MOUNT;

  RESTORE DATABASE;

  RECOVER DATABASE;

  ALTER DATABASE OPEN;

}

A section of the output from the above restore script is shown below. Notice the datafiles from the CDB (cdb1) and all the PDBs (pdb1, pdb2 and pdb$seed) are all considered during the restore. The seed PDB is not actually restored because it is read-only and RMAN can see a restore is not necessary.

 

Starting restore at 22-DEC-13

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=11 device type=DISK

 

skipping datafile 5; already restored to file /u01/app/oracle/oradata/cdb1/pdbseed/system01.dbf

skipping datafile 7; already restored to file /u01/app/oracle/oradata/cdb1/pdbseed/sysaux01.dbf

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/cdb1/system01.dbf

channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/cdb1/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/cdb1/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/cdb1/users01.dbf

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/CDB1/backupset/2013_12_22/o1_mf_nnndf_TAG20131222T163015_9cg4wr40_.bkp

channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/CDB1/backupset/2013_12_22/o1_mf_nnndf_TAG20131222T163015_9cg4wr40_.bkp tag=TAG20131222T163015

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:56

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/cdb1/pdb1/system01.dbf

channel ORA_DISK_1: restoring datafile 00009 to /u01/app/oracle/oradata/cdb1/pdb1/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00010 to /u01/app/oracle/oradata/cdb1/pdb1/pdb1_users01.dbf

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/CDB1/E45393F0DE5F1A8AE043D200A8C00DFC/backupset/2013_12_22/o1_mf_nnndf_TAG20131222T163015_9cg4z3so_.bkp

channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/CDB1/E45393F0DE5F1A8AE043D200A8C00DFC/backupset/2013_12_22/o1_mf_nnndf_TAG20131222T163015_9cg4z3so_.bkp tag=TAG20131222T163015

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:25

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00029 to /u01/app/oracle/oradata/pdb2/system01.dbf

channel ORA_DISK_1: restoring datafile 00030 to /u01/app/oracle/oradata/pdb2/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00031 to /u01/app/oracle/oradata/pdb2/pdb2_users01.dbf

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/CDB1/E4B0CA84B47E6183E043D200A8C0A806/backupset/2013_12_22/o1_mf_nnndf_TAG20131222T163015_9cg50766_.bkp

channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/CDB1/E4B0CA84B47E6183E043D200A8C0A806/backupset/2013_12_22/o1_mf_nnndf_TAG20131222T163015_9cg50766_.bkp tag=TAG20131222T163015

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:25

Finished restore at 22-DEC-13

 

Starting recover at 22-DEC-13

using channel ORA_DISK_1

 

starting media recovery

media recovery complete, elapsed time: 00:00:10

 

Finished recover at 22-DEC-13

 

Statement processed

Root Container Complete Recovery

Rather than recovering the whole CDB, including all PDBs, the root container can be recovered in isolation.

 

Connect to RMAN using OS authentication and restore the root container using the following restore script. This means you are connecting to the root container with "AS SYSDBA" privilege.

 

$ rman target=/

 

RUN {

  SHUTDOWN IMMEDIATE; # use abort if this fails

  STARTUP MOUNT;

  RESTORE DATABASE ROOT;

  RECOVER DATABASE ROOT;

  # Consider recovering PDBs before opening.

  ALTER DATABASE OPEN;

}

The following section of the output from the restore script shows only the root container datafiles are restored and recovered.

 

Starting restore at 23-DEC-13

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=247 device type=DISK

 

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/cdb1/system01.dbf

channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/cdb1/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/cdb1/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/cdb1/users01.dbf

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/CDB1/backupset/2013_12_23/o1_mf_nnndf_TAG20131223T112413_9cj7bxtg_.bkp

channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/CDB1/backupset/2013_12_23/o1_mf_nnndf_TAG20131223T112413_9cj7bxtg_.bkp tag=TAG20131223T112413

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:01:26

Finished restore at 23-DEC-13

 

Starting recover at 23-DEC-13

using channel ORA_DISK_1

 

starting media recovery

media recovery complete, elapsed time: 00:00:04

 

Finished recover at 23-DEC-13

It is probably a very bad idea to restore and recover just the root container without doing the same for the PDBs. Any difference in metadata between the two could prove problematic.

 

Pluggable Database (PDB) Complete Recovery

There are two ways to restore and recover PDBs. From to root containers, you can restore and recover one or more PDBs using the following script.

 

$ rman target=/

 

RUN {

  ALTER PLUGGABLE DATABASE pdb1, pdb2 CLOSE;

  RESTORE PLUGGABLE DATABASE pdb1, pdb2;

  RECOVER PLUGGABLE DATABASE pdb1, pdb2;

  ALTER PLUGGABLE DATABASE pdb1, pdb2 OPEN;

}

When connected directly to a PDB, you can restore and recover the current PDB using a local user with the SYSDBA privilege, as shown in the following script.

 

$ sqlplus sys@pdb1 as sysdba

 

CREATE USER admin_user IDENTIFIED BY admin_user;

GRANT CREATE SESSION, PDB_DBA, SYSDBA TO admin_user;

EXIT;

 

$ rman target=admin_user@pdb1

 

SHUTDOWN IMMEDIATE;

RESTORE DATABASE;

RECOVER DATABASE;

STARTUP;

 In the current release, the RMAN commands will not work in a "run" script without producing errors.

 

Tablespace and Datafile Complete Recovery

Due to potential name clashes, restoring a tablespace must be done while connected to the PDB.

 

$ rman target=sys@pdb1

 

RUN {

  ALTER TABLESPACE users OFFLINE;

  RESTORE TABLESPACE users;

  RECOVER TABLESPACE users;

  ALTER TABLESPACE users ONLINE;

}

Datafile recoveries can be done while connected to the container or directly to the PDB.

 

$ rman target=/

 

# Or

 

$ rman target=sys@pdb1

 

RUN {

  ALTER DATABASE DATAFILE 10 OFFLINE;

  RESTORE DATAFILE 10;

  RECOVER DATAFILE 10;

  ALTER DATABASE DATAFILE 10 ONLINE;

}

Point In Time Recovery (PITR)

Container Database (CDB) Point In Time Recovery (PITR)

Point In Time Recovery (PITR) of a CDB is the same as that of non-CDB instances. Just remember, you are performing a PITR on the CDB and all the PDBs at once.

 

$ rman target=/

 

RUN {

  SHUTDOWN IMMEDIATE; # use abort if this fails

  STARTUP MOUNT;

  SET UNTIL TIME "TO_DATE('23-DEC-2013 12:00:00','DD-MON-YYYY HH24:MI:SS')";

  RESTORE DATABASE;

  RECOVER DATABASE;

  # Should probably open read-only and check it out first.

  ALTER DATABASE OPEN RESETLOGS;

}

Pluggable Database (PDB) Point In Time Recovery (PITR)

Point In Time Recovery (PITR) of a PDB follows a similar pattern to that of a regular database. The PDB is closed, restored and recovered to the required point in time, then opened with the RESETLOGS option. In this case, the RESETLOGS option does nothing with the logfiles themselves, but creates a new PDB incarnation.

 

$ rman target=/

 

RUN {

  ALTER PLUGGABLE DATABASE pdb1 CLOSE;

  SET UNTIL TIME "TO_DATE('23-DEC-2013 12:00:00','DD-MON-YYYY HH24:MI:SS')";

  RESTORE PLUGGABLE DATABASE pdb1;

  RECOVER PLUGGABLE DATABASE pdb1;

  ALTER PLUGGABLE DATABASE pdb1 OPEN RESETLOGS;

}

The simplicity of PITR of PDBs hides a certain amount of complexity. For a start, a PDB shares the root container with other PDBs, so a PITR of the root container must be performed. This is done in the fast recovery area (FRA) provided it is configured. If the FRA is not configured, an AUXILIARY DESTINATION must be specified.

 

Aside from the FRA space requirement, one other important restriction is relevant. If a point in time recovery of a PDB has been done, it is not possible to directly flashback the database to a time before the PDB point in time recovery. The workaround for this is discussed in this article.

 

Table Point In Time Recovery (PITR) in PDBs

Oracle 12c includes a new RMAN feature which performs point in time recovery of tables using a single command. You can read about this feature and see examples of it's use in the following article.

 

RMAN Table Point In Time Recovery (PITR) in Oracle Database 12c Release 1 (12.1)

The same mechanism is available for recovering tables in PDBs, with a few minor changes. For the feature to work with a PDB, you must log in as a root user with SYSDBA or SYSBACKUP privilege.

 

$ rman target=/

Issue the RECOVER TABLE command in a similar way to that shown for a non-CDB database, but include the OF PLUGGABLE DATABASE clause, as well as giving a suitable AUXILIARY DESTINATION location for the auxiliary database. The following command also uses the REMAP TABLE clause to give the recovered table a new name.

 

# SCN

RECOVER TABLE 'TEST'.'T1' OF PLUGGABLE DATABASE pdb1

  UNTIL SCN 5695703

  AUXILIARY DESTINATION '/u01/aux' 

  REMAP TABLE 'TEST'.'T1':'T1_PREV';

 

# TIME

RECOVER TABLE 'TEST'.'T1' OF PLUGGABLE DATABASE pdb1

  UNTIL TIME "TO_DATE('01-JAN-2013 15:00', 'DD-MON-YYYY HH24:MI')"

  AUXILIARY DESTINATION '/u01/aux' 

  REMAP TABLE 'TEST'.'T1':'T1_PREV';

Alternatively, you can just stop at the point where the recovered table is in a data pump dump file, which you can import manually at a later time. The following example uses the DATAPUMP DESTINATION, DUMP FILE and NOTABLEIMPORT clauses to achieve this.

 

RECOVER TABLE 'TEST'.'T1' OF PLUGGABLE DATABASE pdb1

  UNTIL SCN 5695703

  AUXILIARY DESTINATION '/u01/aux'

  DATAPUMP DESTINATION '/u01/export'

  DUMP FILE 'test_t1_prev.dmp'

  NOTABLEIMPORT;

Using Flashback Drop and Managing the Recycle Bin

 

Using Flashback Drop and Managing the Recycle Bin

When you drop a table, the database does not immediately remove the space associated with the table. The database renames the table and places it and any associated objects in a recycle bin, where, in case the table was dropped in error, it can be recovered at a later time. This feature is called Flashback Drop, and the FLASHBACK TABLE statement is used to restore the table. Before discussing the use of the FLASHBACK TABLE statement for this purpose, it is important to understand how the recycle bin works, and how you manage its contents.

This section contains the following topics:

•              What Is the Recycle Bin?

•              Viewing and Querying Objects in the Recycle Bin

•              Purging Objects in the Recycle Bin

•              Restoring Tables from the Recycle Bin

What Is the Recycle Bin?

The recycle bin is actually a data dictionary table containing information about dropped objects. Dropped tables and any associated objects such as indexes, constraints, nested tables, and the likes are not removed and still occupy space. They continue to count against user space quotas, until specifically purged from the recycle bin or the unlikely situation where they must be purged by the database because of tablespace space constraints.

Each user can be thought of as having his own recycle bin, since unless a user has the SYSDBA privilege, the only objects that the user has access to in the recycle bin are those that the user owns. A user can view his objects in the recycle bin using the following statement:

SELECT * FROM RECYCLEBIN;

When you drop a tablespace including its contents, the objects in the tablespace are not placed in the recycle bin and the database purges any entries in the recycle bin for objects located in the tablespace. The database also purges any recycle bin entries for objects in a tablespace when you drop the tablespace, not including contents, and the tablespace is otherwise empty. Likewise:

•              When you drop a user, any objects belonging to the user are not placed in the recycle bin and any objects in the recycle bin are purged.

•              When you drop a cluster, its member tables are not placed in the recycle bin and any former member tables in the recycle bin are purged.

•              When you drop a type, any dependent objects such as subtypes are not placed in the recycle bin and any former dependent objects in the recycle bin are purged.

Object Naming in the Recycle Bin

When a dropped table is moved to the recycle bin, the table and its associated objects are given system-generated names. This is necessary to avoid name conflicts that may arise if multiple tables have the same name. This could occur under the following circumstances:

•              A user drops a table, re-creates it with the same name, then drops it again.

•              Two users have tables with the same name, and both users drop their tables.

The renaming convention is as follows:

BIN$unique_id$version

where:

•              unique_id is a 26-character globally unique identifier for this object, which makes the recycle bin name unique across all databases

•              version is a version number assigned by the database

Enabling and Disabling the Recycle Bin

You can enable and disable the recycle bin with the recyclebin initialization parameter. When the recycle bin is enabled, dropped tables and their dependent objects are placed in the recycle bin. When the recycle bin is disabled, dropped tables and their dependent objects are not placed in the recycle bin; they are just dropped, and you must use other means to recover them (such as recovering from backup).

The recycle bin is enabled by default.

To disable the recycle bin:

•              Issue one of the following statements:

•              ALTER SESSION SET recyclebin = OFF;

•             

•              ALTER SYSTEM SET recyclebin = OFF;

To enable the recycle bin:

•              Issue one of the following statements:

•              ALTER SESSION SET recyclebin = ON;

•             

•              ALTER SYSTEM SET recyclebin = ON;

Enabling and disabling the recycle bin with an ALTER SYSTEM or ALTER SESSION statement takes effect immediately. Disabling the recycle bin does not purge or otherwise affect objects already in the recycle bin.

Like any other initialization parameter, you can set the initial value of the recyclebin parameter in the text initialization file initSID.ora:

recyclebin=on

See Also:

"About Initialization Parameters and Initialization Parameter Files" for more information on initialization parameters.

Viewing and Querying Objects in the Recycle Bin

Oracle Database provides two views for obtaining information about objects in the recycle bin:

View     Description

USER_RECYCLEBIN           This view can be used by users to see their own dropped objects in the recycle bin. It has a synonym RECYCLEBIN, for ease of use.

DBA_RECYCLEBIN             This view gives administrators visibility to all dropped objects in the recycle bin

 

One use for these views is to identify the name that the database has assigned to a dropped object, as shown in the following example:

SELECT object_name, original_name FROM dba_recyclebin

   WHERE owner = 'HR';

 

OBJECT_NAME                    ORIGINAL_NAME

------------------------------ --------------------------------

BIN$yrMKlZaLMhfgNAgAIMenRA==$0 EMPLOYEES

You can also view the contents of the recycle bin using the SQL*Plus command SHOW RECYCLEBIN.

SQL> show recyclebin

 

ORIGINAL NAME    RECYCLEBIN NAME                OBJECT TYPE  DROP TIME

---------------- ------------------------------ ------------ -------------------

EMPLOYEES        BIN$yrMKlZaVMhfgNAgAIMenRA==$0 TABLE        2003-10-27:14:00:19

You can query objects that are in the recycle bin, just as you can query other objects. However, you must specify the name of the object as it is identified in the recycle bin. For example:

SELECT * FROM "BIN$yrMKlZaVMhfgNAgAIMenRA==$0";

Purging Objects in the Recycle Bin

If you decide that you are never going to restore an item from the recycle bin, you can use the PURGE statement to remove the items and their associated objects from the recycle bin and release their storage space. You need the same privileges as if you were dropping the item.

When you use the PURGE statement to purge a table, you can use the name that the table is known by in the recycle bin or the original name of the table. The recycle bin name can be obtained from either the DBA_ or USER_RECYCLEBIN view as shown in "Viewing and Querying Objects in the Recycle Bin". The following hypothetical example purges the table hr.int_admin_emp, which was renamed to BIN$jsleilx392mk2=293$0 when it was placed in the recycle bin:

PURGE TABLE BIN$jsleilx392mk2=293$0;

You can achieve the same result with the following statement:

PURGE TABLE int_admin_emp;

You can use the PURGE statement to purge all the objects in the recycle bin that are from a specified tablespace or only the tablespace objects belonging to a specified user, as shown in the following examples:

PURGE TABLESPACE example;

PURGE TABLESPACE example USER oe;

Users can purge the recycle bin of their own objects, and release space for objects, by using the following statement:

PURGE RECYCLEBIN;

If you have the SYSDBA privilege, then you can purge the entire recycle bin by specifying DBA_RECYCLEBIN, instead of RECYCLEBIN in the previous statement.

You can also use the PURGE statement to purge an index from the recycle bin or to purge from the recycle bin all objects in a specified tablespace.

See Also:

Oracle Database SQL Language Reference for more information on the PURGE statement

Restoring Tables from the Recycle Bin

Use the FLASHBACK TABLE ... TO BEFORE DROP statement to recover objects from the recycle bin. You can specify either the name of the table in the recycle bin or the original table name. An optional RENAME TO clause lets you rename the table as you recover it. The recycle bin name can be obtained from either the DBA_ or USER_RECYCLEBIN view as shown in "Viewing and Querying Objects in the Recycle Bin". To use the FLASHBACK TABLE ... TO BEFORE DROP statement, you need the same privileges you need to drop the table.

The following example restores int_admin_emp table and assigns to it a new name:

FLASHBACK TABLE int_admin_emp TO BEFORE DROP

   RENAME TO int2_admin_emp;

The system-generated recycle bin name is very useful if you have dropped a table multiple times. For example, suppose you have three versions of the int2_admin_emp table in the recycle bin and you want to recover the second version. You can do this by issuing two FLASHBACK TABLE statements, or you can query the recycle bin and then flashback to the appropriate system-generated name, as shown in the following example. Including the create time in the query can help you verify that you are restoring the correct table.

SELECT object_name, original_name, createtime FROM recyclebin;   

 

OBJECT_NAME                    ORIGINAL_NAME   CREATETIME

------------------------------ --------------- -------------------

BIN$yrMKlZaLMhfgNAgAIMenRA==$0 INT2_ADMIN_EMP  2006-02-05:21:05:52

BIN$yrMKlZaVMhfgNAgAIMenRA==$0 INT2_ADMIN_EMP  2006-02-05:21:25:13

BIN$yrMKlZaQMhfgNAgAIMenRA==$0 INT2_ADMIN_EMP  2006-02-05:22:05:53

 

FLASHBACK TABLE BIN$yrMKlZaVMhfgNAgAIMenRA==$0 TO BEFORE DROP;

Restoring Dependent Objects

When you restore a table from the recycle bin, dependent objects such as indexes do not get their original names back; they retain their system-generated recycle bin names. You must manually rename dependent objects if you want to restore their original names. If you plan to manually restore original names for dependent objects, ensure that you make note of each dependent object's system-generated recycle bin name before you restore the table.

The following is an example of restoring the original names of some of the indexes of the dropped table JOB_HISTORY, from the HR sample schema. The example assumes that you are logged in as the HR user.

1.            After dropping JOB_HISTORY and before restoring it from the recycle bin, run the following query:

2.            SELECT OBJECT_NAME, ORIGINAL_NAME, TYPE FROM RECYCLEBIN;

3.           

4.            OBJECT_NAME                    ORIGINAL_NAME             TYPE

5.            ------------------------------ ------------------------- --------

6.            BIN$DBo9UChtZSbgQFeMiAdCcQ==$0 JHIST_JOB_IX              INDEX

7.            BIN$DBo9UChuZSbgQFeMiAdCcQ==$0 JHIST_EMPLOYEE_IX         INDEX

8.            BIN$DBo9UChvZSbgQFeMiAdCcQ==$0 JHIST_DEPARTMENT_IX       INDEX

9.            BIN$DBo9UChwZSbgQFeMiAdCcQ==$0 JHIST_EMP_ID_ST_DATE_PK   INDEX

10.          BIN$DBo9UChxZSbgQFeMiAdCcQ==$0 JOB_HISTORY               TABLE

11.          Restore the table with the following command:

12.          FLASHBACK TABLE JOB_HISTORY TO BEFORE DROP;

13.          Run the following query to verify that all JOB_HISTORY indexes retained their system-generated recycle bin names:

14.          SELECT INDEX_NAME FROM USER_INDEXES WHERE TABLE_NAME = 'JOB_HISTORY';

15.         

16.          INDEX_NAME

17.          ------------------------------

18.          BIN$DBo9UChwZSbgQFeMiAdCcQ==$0

19.          BIN$DBo9UChtZSbgQFeMiAdCcQ==$0

20.          BIN$DBo9UChuZSbgQFeMiAdCcQ==$0

21.          BIN$DBo9UChvZSbgQFeMiAdCcQ==$0

22.          Restore the original names of the first two indexes as follows:

23.          ALTER INDEX "BIN$DBo9UChtZSbgQFeMiAdCcQ==$0" RENAME TO JHIST_JOB_IX;

ALTER INDEX "BIN$DBo9UChuZSbgQFeMiAdCcQ==$0" RENAME TO JHIST_EMPLOYEE_IX;

 

Oracle 12cR2 RMAN New Feature: UNTIL AVAILABLE REDO

 

Introduction

Oracle has introduced several new features in its new version Oracle Database 12.2.0.1.0 and RMAN it is not the exception. Most of the DBA would agree that one of the difficult tasks whenever a database needs to be restored is to calculate the SCN, or the Sequence to use in the “RECOVER DATABASE UNTIL (…)” operation, in order to apply as many archived logs as possible, to recover as much data as possible. Every DBA has different methods to discover the target SCN or the target Sequence.

 Some use the “PREVIEW” clause, some others the view v$log, some others the RMAN “LIST” commands, and so on. The problem is that when the calculation is not correct, and the database that is being restored is huge (let’s say 8TB), an error on the “RECOVER” phase might take us to restore the whole database from scratch. In Oracle database 12.2.0.1.0 the clause “UNTIL AVAILABLE REDO” is available. As its name indicates, this clause makes all the required calculations to recover the database up to the last available archive log. This is a really cool feature, since all the DBA has to do is catalog all the archivelogs available and use “UNTIL AVAILABLE REDO” in the “RECOVER DATABASE” phase, and Oracle will do all the work., This also lets us avoid human error in the calculations.

In order to show how this feature works I will use an empty database with the table DGOMEZ.COUNTRY; currently it has no rows.  This database is in archivelog mode.

 

Performing a backup:

RMAN> backup database;

Starting backup at 07-MAY-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=53 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=/others/db1/DB1/datafile/o1_mf_system_djyxzjxt_.dbf
input datafile file number=00003 name=/others/db1/DB1/datafile/o1_mf_sysaux_djyy0ynm_.dbf
input datafile file number=00004 name=/others/db1/DB1/datafile/o1_mf_undotbs1_djyy23sy_.dbf
input datafile file number=00007 name=/others/db1/DB1/datafile/o1_mf_users_djyy24y4_.dbf
channel ORA_DISK_1: starting piece 1 at 07-MAY-17
channel ORA_DISK_1: finished piece 1 at 07-MAY-17
piece handle=/others/db1/fra/DB1/backupset/2017_05_07/o1_mf_nnndf_TAG20170507T155509_djyywznq_.bkp tag=TAG20170507T155509 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:38
Finished backup at 07-MAY-17

Starting Control File and SPFILE Autobackup at 07-MAY-17
piece handle=/others/db1/fra/DB1/autobackup/2017_05_07/o1_mf_s_943372550_djyyy6vo_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 07-MAY-17

I will insert a row with the value ‘Guatemala’ into the table, the row will be committed and a new archived log will be generated:

SQL> insert into dgomez.country values ('Guatemala');
1 row created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.

A second row with the value ‘Canada’ will be inserted into the table, the row will be committed and a new archived log will be generated:

SQL> insert into dgomez.country values ('Canada');
1 row created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.

A last row with the value ‘Colombia’ will be inserted into the table, the row will be committed and a new archived log will be generated:

SQL> insert into dgomez.country values ('Colombia');
1 row created 
SQL> commit;
Commit complete.
SQL> alter system switch logfile; 
System altered.

You can see that there were three archived logs created. This is because for every row that was inserted we executed a switch of the log file, and that resulted in the creation of a new archived log.

[oracle@nuvola2 2017_05_07]$ ls -ltr
total 155072
-rw-r----- 1 oracle dba 158784512 May  7 15:59 o1_mf_1_1_djyz5fgk_.arc
-rw-r----- 1 oracle dba      2560 May  7 16:00 o1_mf_1_2_djyz6dyd_.arc
-rw-r----- 1 oracle dba      3072 May  7 16:00 o1_mf_1_3_djyz723j_.arc
[oracle@nuvola2 2017_05_07]$

Confirming the three rows are in the table:

SQL> select * from dgomez.country;
NAME
--------------------
Guatemala
Canada
Colombia

Basically what I have done is what the following picture explains.  Initially the database was empty. The row with the value ‘Guatemala’ was inserted and then I generated an archived log (#1). I repeated these steps with the value ‘Canada’ and ‘Colombia’ respectively.

 https://blog.toadworld.com/hubfs/Imported_Blog_Media/8037_d1-2.png

 

First Test – Using all the archived logs generated:

The first test that I will perform is to use these three newly generated archived logs to recover the database. For this I will simulate that all the datafiles of the existing database were deleted and we have to restore and recover the database.

 

Shutting down the existing database:

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

 

Mounting the database:

SQL> startup mount;
ORACLE instance started.
 
Total System Global Area  843055104 bytes
Fixed Size              8626288 bytes
Variable Size         322965392 bytes
Database Buffers      507510784 bytes
Redo Buffers            3952640 bytes
Database mounted.

 

Deleting datafiles and online logs in order to simulate a storage damage:

[oracle@nuvola2 2017_05_07]$ rm -rf /others/db1/DB1/datafile/*
[oracle@nuvola2 2017_05_07]$ rm -rf /others/db1/DB1/onlinelog/*
[oracle@nuvola2 2017_05_07]$ rm -rf /others/db1/fra/DB1/onlinelog/*

 

Restoring the database:

RMAN> restore database;

Starting restore at 07-MAY-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /others/db1/DB1/datafile/o1_mf_system_djyxzjxt_.dbf
channel ORA_DISK_1: restoring datafile 00003 to /others/db1/DB1/datafile/o1_mf_sysaux_djyy0ynm_.dbf
channel ORA_DISK_1: restoring datafile 00004 to /others/db1/DB1/datafile/o1_mf_undotbs1_djyy23sy_.dbf
channel ORA_DISK_1: restoring datafile 00007 to /others/db1/DB1/datafile/o1_mf_users_djyy24y4_.dbf
channel ORA_DISK_1: reading from backup piece /others/db1/fra/DB1/backupset/2017_05_07/o1_mf_nnndf_TAG20170507T155509_djyywznq_.bkp
channel ORA_DISK_1: piece handle=/others/db1/fra/DB1/backupset/2017_05_07/o1_mf_nnndf_TAG20170507T155509_djyywznq_.bkp tag=TAG20170507T155509
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 07-MAY-17

 

Recovering the database:

Here is where the magic happens. All we have to do is use the “UNTIL AVAILABLE REDO” clause and Oracle automatically will apply all the archived logs that have registered into its control file or a catalog; if a catalog is used. There is no need to perform calculations for the target SCN.

RMAN> recover database until available redo;

Starting recover at 07-MAY-17
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 1 is already on disk as file /others/db1/fra/DB1/archivelog/2017_05_07/
o1_mf_1_1_djyz5fgk_.arc
archived log for thread 1 with sequence 2 is already on disk as file /others/db1/fra/DB1/archivelog/2017_05_07/
o1_mf_1_2_djyz6dyd_.arc
archived log for thread 1 with sequence 3 is already on disk as file /others/db1/fra/DB1/archivelog/2017_05_07/
o1_mf_1_3_djyz723j_.arc
archived log file name=/others/db1/fra/DB1/archivelog/2017_05_07/o1_mf_1_1_djyz5fgk_.arc thread=1 sequence=1
archived log file name=/others/db1/fra/DB1/archivelog/2017_05_07/o1_mf_1_2_djyz6dyd_.arc thread=1 sequence=2
archived log file name=/others/db1/fra/DB1/archivelog/2017_05_07/o1_mf_1_3_djyz723j_.arc thread=1 sequence=3
warning: attempt media recovery until thread 1, sequence 4
Finished recover at 07-MAY-17

We can see that the three archived logs were applied automatically and there were no errors.

 

Opening the database in resetlogs:

SQL> alter database open resetlogs; 
Database altered.

 

Verification of the data:

SQL> select * from dgomez.country;
NAME
--------------------
Guatemala
Canada
Colombia

Since the three rows are there, we can confirm that Oracle indeed applied the three archived logs automatically, without our having to specify any target SCN or target sequence.

 

Second Test – Deleting the last two archived logs:

The test that I will perform now is with the last two archived logs deleted and only the first archived log available. I will again use the UNTIL AVAILABLE REDO clause and Oracle should be able to discover that the maximum time to which the database can be recovered is right after the first row was inserted (with the value ‘Guatemala’).  

 

Shutting down the existing database:

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

 

Mounting the database:

SQL> startup mount;
ORACLE instance started.
 
Total System Global Area  843055104 bytes
Fixed Size              8626288 bytes
Variable Size         322965392 bytes
Database Buffers      507510784 bytes
Redo Buffers            3952640 bytes
Database mounted.

 

Deleting datafiles and online logs in order to simulate a storage damage:

[oracle@nuvola2 2017_05_07]$ rm -rf /others/db1/DB1/datafile/*
[oracle@nuvola2 2017_05_07]$ rm -rf /others/db1/DB1/onlinelog/*
[oracle@nuvola2 2017_05_07]$ rm -rf /others/db1/fra/DB1/onlinelog/*

 

Confirming that our three archived logs are there:

[oracle@nuvola2 2017_05_07]$ ls -ltr  /others/db1/fra/DB1/archivelog/2017_05_07/*
-rw-r----- 1 oracle dba 158784512 May  7 15:59 /others/db1/fra/DB1/archivelog/2017_05_07/o1_mf_1_1_djyz5fgk_.arc
-rw-r----- 1 oracle dba      2560 May  7 16:00 /others/db1/fra/DB1/archivelog/2017_05_07/o1_mf_1_2_djyz6dyd_.arc
-rw-r----- 1 oracle dba      3072 May  7 16:00 /others/db1/fra/DB1/archivelog/2017_05_07/o1_mf_1_3_djyz723j_.arc

 

Deleting the last two archived logs that were generated:

[oracle@nuvola2 2017_05_07]$ rm -rf  /others/db1/fra/DB1/archivelog/2017_05_07/o1_mf_1_3_djyz723j_.arc
[oracle@nuvola2 2017_05_07]$ rm -rf /others/db1/fra/DB1/archivelog/2017_05_07/
o1_mf_1_2_djyz6dyd_.arc

 

Confirming that only the first archived log is available now:

[oracle@nuvola2 2017_05_07]$ ls -ltr  /others/db1/fra/DB1/archivelog/2017_05_07/*
-rw-r----- 1 oracle dba 158784512 May  7 15:59 /others/db1/fra/DB1/archivelog/2017_05_07/o1_mf_1_1_djyz5fgk_.arc
[oracle@nuvola2 2017_05_07]$

The following image explains what we are doing. We deleted the last two generated archived logs in order to test whether Oracle is aware of it and whether it automatically handles the situation and applies all the redo data in the first archived log. If Oracle performs its job well, at the end, we will be see only one row inserted with the value ‘Guatemala’.

https://blog.toadworld.com/hubfs/Imported_Blog_Media/2642_d2-2.png

 

 

Restoring the database:

RMAN> restore database;

Starting restore at 07-MAY-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=44 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /others/db1/DB1/datafile/o1_mf_system_djyznwbl_.dbf
channel ORA_DISK_1: restoring datafile 00003 to /others/db1/DB1/datafile/o1_mf_sysaux_djyznwby_.dbf
channel ORA_DISK_1: restoring datafile 00004 to /others/db1/DB1/datafile/o1_mf_undotbs1_djyznwc9_.dbf
channel ORA_DISK_1: restoring datafile 00007 to /others/db1/DB1/datafile/o1_mf_users_djyznwcn_.dbf
channel ORA_DISK_1: reading from backup piece /others/db1/fra/DB1/backupset/2017_05_07/o1_mf_nnndf_TAG20170507T155509_djyywznq_.bkp
channel ORA_DISK_1: piece handle=/others/db1/fra/DB1/backupset/2017_05_07/o1_mf_nnndf_TAG20170507T155509_djyywznq_.bkp tag=TAG20170507T155509
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:22
Finished restore at 07-MAY-17

 

Recovering the database:

RMAN> recover database until available redo;

Starting recover at 07-MAY-17
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 1 is already on disk as file /others/db1/fra/DB1/archivelog/2017_05_07/
o1_mf_1_1_djyz5fgk_.arc
archived log file name=/others/db1/fra/DB1/archivelog/2017_05_07/o1_mf_1_1_djyz5fgk_.arc thread=1 sequence=1
warning: attempt media recovery until thread 1, sequence 2
Finished recover at 07-MAY-17

You can see that Oracle automatically discovered that only one archived log is available and automatically calculated the target sequence for the database to be recovered.

 

The OSDBA subset job role separation privileges and groups consist of the following:

 The OSDBA subset job role separation privileges and groups consist of the following:


The OSBACKUPDBA group for Oracle Database (ORA_HOMENAME_SYSBACKUP)


Use this group if you want a separate group of operating system users to have a limited set of database backup and recovery related administrative privileges (the SYSBACKUP privilege).


The OSDGDBA group for Oracle Data Guard (ORA_HOMENAME_SYSDG)


Use this group if you want a separate group of operating system users to have a limited set of privileges to administer and monitor Oracle Data Guard (the SYSDG privilege).


The OSKMDBA group for encryption key management (ORA_HOMENAME_SYSKM)


Use this group if you want a separate group of operating system users to have a limited set of privileges for encryption key management such as Oracle Wallet Manager management (the SYSKM privilege).


The OSRACDBA group for Oracle Real Application Clusters Administration (ORA_HOMENAME_SYSRAC)


Use this group if you want a separate group of operating system users to have a limited set of Oracle Real Application Clusters (RAC) administrative privileges (the SYSRAC privilege). To use this privilege:


Add the Oracle Database installation owners as members of this group.

Oracle Database 19c Overview And New Features


Oracle Database 19c Overview And New Features


Agenda

  • Oracle Database 19c Multitenant Architecture
  • 19 New features and Advantage
  • Common and local users in Multitenant Environment
  • Startup and stop of database in Multitenant  environment
  • Backup in multitenant Environment
  • Online migration of an active data file
  • Online table partition or sub-partition migration
  • Invisible column

 Multiple indexes on the same column

 DDL logging

 Temporary undo in- and- outs

  New backup user privilege

  How to execute SQL statement in RMAN

  Table level recovery in RMAN

  Restricting PGA size


Multitenant Architecture

Every CDB has the following containers:

  • Exactly one CDB root container (also called simply the root)
  • The CDB root is a collection of schemas, schema objects, and nonschema objects to which all PDBs belong to . The root stores Oracle-supplied metadata and common users. . A common user is a database user known in every container. The root container is named CDB$ROOT.
  • Exactly one system container
  • The system container includes the root CDB and all PDBs in the CDB. Thus, the system container is the logical container for the CDB itself.
  • Zero or more application containers
  • An application container consists of exactly one application root, and the PDBs plugged in to this root. Whereas the system container contains the CDB root and all the PDBs within the CDB, an application container includes only the PDBs plugged into the application root. An application root belongs to the CDB root and no other container.
  • Zero or more user-created PDBs
  • You can define a set of application-specific PDBs as a single component, called an application container. You can then define one or more applications within this container. Each application is a named, versioned set of common metadata and data shared within this application container.

  • For example, each customer of a SaaS vendor could have its own application PDB. Each application PDB might have identically defined tables named sales_mlt, with different data in each PDB. The PDBs could share a data-linked common object named countries_olt, which has identical data in each PDB. As an application administrator, you could manage the master application definition so that every new customer gets a PDB with the same objects, and every change to existing schemas (for example, the addition of a new table, or a change in the definition of a table) applies to all PDBs that share the application definition.
  • A PDB contains the data and code required for a specific set of features ( For example, a PDB can support a specific application, such as a human resources or sales application. No PDBs exist at creation of the CDB. You add PDBs based on your business requirements.
  • A PDB belongs to exactly zero or one application container. If a PDB belongs to an application container, then it is an application PDB. For example, the cust1_pdb and cust2_pdb application PDBs might belong to the saas_sales_ac application container, in which case they belong to no other application containers. An application seed is an optional application PDB that acts as a user-created PDB template, enabling you to create new application PDBs rapidly.
  • Exactly one seed PDB
  • The seed PDB is a system-supplied template that the CDB can use to create new PDBs. The seed PDB is named PDB$SEED. You cannot add or modify objects in PDB$SEED
  • Seed:  The seed, named PDB$SEED, is a template that you can use to create new PDBs. You cannot add objects to or modify objects in the seed. A CDB has exactly one seed.
  •  PDBs:  A PDB appears to users and applications as if it were a non-CDB. For example, a PDB can contain the data and code required to support a specific application. A PDB is fully backward compatible with Oracle Database releases before Oracle Database 12c.
  • Each of these components is called a container. Therefore, the root is a container, the seed is a container, and each PDB is a container. Each container has a unique container ID and name within a CDB.
  • The multitenant architecture enables an Oracle database to function as a multitenant container database (CDB) that includes zero, one, or many customer-created Pluggable Databases (PDBs). A PDB is a portable collection of schemas, schema objects, and nonschema objects that appears to an Oracle Net client as a non-CDB. All Oracle databases before Oracle Database 12 were non-CDBs.
  • A container is logical collection of data or metadata within the multitenant architecture
  • A CDB includes the following components:
        Root: The root, named CDB$ROOT, stores Oracle-supplied metadata and common users. Exactly one         system container. The CDB root is a collection of schemas, schema objects, and nonschema objects to             which all PDBs belong. The root container is named CDB$ROOT.