DBA Hub

📋Steps in this guide1/3

Multitenant : Flashback of a Container Database (CDB) in Oracle Database 12c Release 1 (12.1)

Identify the restrictions when using flashback database against a container database (CDB) in Oracle 12c.

oracle 12cconfigurationintermediate
by OracleDba
11 views
1

Setup

This article assumes the following things are in place for the examples to work. - You have a container database (CDB). You can see how to create one here . - Your container database (CDB) has at least one pluggable database (PDB). You can see how to create one here . - You have the flashback database feature enabled on the CDB. You can see how to do that here . - You have backups of your CDB and PDBs. You can see how to do that here . With this in place, you can move on to the next sections.
2

Flashback of Container Database (CDB)

The basic procedure for performing a flashback database operation on a container database (CDB) is the same as that for a non-CDB database in 12c and previous versions, as described here . So for example, if we want to flashback the CDB to a point in time 5 minutes ago, we might do one the following in SQL*Plus. Or the following in RMAN. In both cases we connect to a root user with the SYSDBA or SYSBACKUP privilege. The restrictions on the use of flashback database are similar to those of a non-CDB database, with one extra restriction. If you perform a point in time recovery of a pluggable database (PDB), you can not use flashback database to return the CDB to a point in time before that PITR of the PDB took place. This issue and the workaround for it are discussed in the next section.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ sqlplus / as sysdba

SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
FLASHBACK DATABASE TO TIMESTAMP SYSDATE-(5/24/60);
ALTER DATABASE OPEN RESETLOGS;

-- Open all pluggable databases.
ALTER PLUGGABLE DATABASE ALL OPEN;

$ rman target=/

SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
FLASHBACK DATABASE TO TIME 'SYSDATE-(5/24/60)';
ALTER DATABASE OPEN RESETLOGS;

# Open all pluggable databases.
ALTER PLUGGABLE DATABASE ALL OPEN;
3

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

As mentioned previously, if you perform a point in time recovery of a pluggable database (PDB), you can not use flashback database to return the CDB to a point in time before that PITR of the PDB took place. The following example shows this. Perform a PITR of a PDB to 5 minutes ago. Then we flashback the CDB to 15 minutes ago. This results in the following error. The workaround for this is to do the following. - Take a backup of everything (CDB and PDBs). It's always a good idea to take a backup before doing anything major to your database. - Shutdown the PDB. - Offline all datafiles for the PDB. - Flashback the CDB. - Restore and recover the PDB to the point it was at before the flashback of the CDB. You can see an example of this below. For more information see: Hope this helps. Regards Tim...

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
$ rman target=/

RUN {
  ALTER PLUGGABLE DATABASE pdb1 CLOSE;
  SET UNTIL TIME "TO_DATE('30-DEC-2013 10:15:00','DD-MON-YYYY HH24:MI:SS')";
  RESTORE PLUGGABLE DATABASE pdb1;
  RECOVER PLUGGABLE DATABASE pdb1;
  ALTER PLUGGABLE DATABASE pdb1 OPEN RESETLOGS;
}

$ rman target=/

SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
SET UNTIL TIME "TO_DATE('30-DEC-2013 10:00:00','DD-MON-YYYY HH24:MI:SS')";
ALTER DATABASE OPEN RESETLOGS;

media recovery failed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of flashback command at 12/28/2013 23:20:08
ORA-39866: Data files for Pluggable Database PDB1 must be offline to flashback across PDB point-in-time recovery.

rman target=/

# Backup everything.
BACKUP DATABASE PLUS ARCHIVELOG;

# Close PDB and take the datafiles offline.
ALTER PLUGGABLE DATABASE pdb1 CLOSE;
ALTER PLUGGABLE DATABASE pdb1 DATAFILE ALL OFFLINE;

# Flashback the CDB, along with all the PDBs.
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
FLASHBACK DATABASE TO TIME "TO_DATE('30-DEC-2013 10:00:00','DD-MON-YYYY HH24:MI:SS')";
ALTER DATABASE OPEN RESETLOGS;

# Open all pluggable databases, except pdb1.
ALTER PLUGGABLE DATABASE ALL EXCEPT pdb1 OPEN;

# PITR of pdb1.
RUN {
  # PDB already closed. No SET UNTIL. We want to recover to the latest time.
  #ALTER PLUGGABLE DATABASE pdb1 CLOSE;
  #SET UNTIL TIME "TO_DATE('30-DEC-2013 10:15:00','DD-MON-YYYY HH24:MI:SS')";
  RESTORE PLUGGABLE DATABASE pdb1;
  RECOVER PLUGGABLE DATABASE pdb1;
  ALTER PLUGGABLE DATABASE pdb1 DATAFILE ALL ONLINE;
  ALTER PLUGGABLE DATABASE pdb1 OPEN;
}

Comments (0)

Please to add comments

No comments yet. Be the first to comment!