Here you can see how to take a pluggable database backup with compress mode and some restore and recover scenarios.
-- To Take pluggable database backup:
$ rman target /
RMAN>
RMAN> backup as compressed backupset pluggable
database salespdb format
'/u10/EXAM/fast_recovery_area/salespdb_full_12c_db_%U';
Starting backup at 08-OCT-2016 17:10:27
using target database control file instead of
recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=212 device type=DISK
channel ORA_DISK_1: starting compressed full
datafile backup set
channel ORA_DISK_1: specifying datafile(s) in
backup set
input datafile file number=00012
name=/u10/EXAM/ORADATA/CDB/salespdb/sysaux01.dbf
input datafile file number=00011
name=/u10/EXAM/ORADATA/CDB/salespdb/system01.dbf
input datafile file number=00013
name=/u10/EXAM/ORADATA/CDB/salespdb/sales01.dbf
channel ORA_DISK_1: starting piece 1 at
08-OCT-2016 17:10:29
channel ORA_DISK_1: finished piece 1 at
08-OCT-2016 17:11:44
piece handle=/u10/EXAM/fast_recovery_area/salespdb_full_12c_db_0krhs1k5_1_1
tag=TAG20161008T171028 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed
time: 00:01:15
Finished backup at 08-OCT-2016 17:11:44
Starting Control File and SPFILE Autobackup at
08-OCT-2016 17:11:44
piece handle=/u10/EXAM/fast_recovery_area/CDB/autobackup/2016_10_08/o1_mf_s_924714704_czkpvw5x_.bkp
comment=NONE
Finished Control File and SPFILE Autobackup at
08-OCT-2016 17:11:51
RMAN>
Verify schemas:
RMAN> report schema;
using target database control file instead of
recovery catalog
Report of database schema for database with
db_unique_name CDB
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- -------
------------------------
1
800 SYSTEM YES /u10/EXAM/ORADATA/CDB/system01.dbf
3
830 SYSAUX NO /u10/EXAM/ORADATA/CDB/sysaux01.dbf
4
225 UNDOTBS1 YES /u10/EXAM/ORADATA/CDB/undotbs01.dbf
5 250 PDB$SEED:SYSTEM NO
/u10/EXAM/ORADATA/CDB/pdbseed/system01.dbf
6 5 USERS NO /u10/EXAM/ORADATA/CDB/users01.dbf
7
570 PDB$SEED:SYSAUX NO
/u10/EXAM/ORADATA/CDB/pdbseed/sysaux01.dbf
8
260 PDB1:SYSTEM NO /u10/EXAM/ORADATA/CDB/pdb1/system01.dbf
9
590 PDB1:SYSAUX NO /u10/EXAM/ORADATA/CDB/pdb1/sysaux01.dbf
10 5 PDB1:USERS NO
/u10/EXAM/ORADATA/CDB/pdb1/pdb1_users01.dbf
11
260 SALESPDB:SYSTEM NO
/u10/EXAM/ORADATA/CDB/salespdb/system01.dbf
12
580 SALESPDB:SYSAUX NO
/u10/EXAM/ORADATA/CDB/salespdb/sysaux01.dbf
13
250 SALESPDB:SALES NO
/u10/EXAM/ORADATA/CDB/salespdb/sales01.dbf
14
260 PDB2:SYSTEM NO /u10/EXAM/ORADATA/CDB/pdb2/system01.dbf
15
580 PDB2:SYSAUX NO /u10/EXAM/ORADATA/CDB/pdb2/sysaux01.dbf
16 5 PDB2:USERS NO
/u10/EXAM/ORADATA/CDB/pdb2/pdb1_users01.dbf
17
260 HRPDB:SYSTEM NO
/u10/EXAM/ORADATA/CDB/hrpdb/system01.dbf
18
580 HRPDB:SYSAUX NO
/u10/EXAM/ORADATA/CDB/hrpdb/sysaux01.dbf
19
250 HRPDB:SALES NO /u10/EXAM/ORADATA/CDB/hrpdb/hr01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- -----------
--------------------
1
197 TEMP 32767 /u10/EXAM/ORADATA/CDB/temp01.dbf
2
100 PDB$SEED:TEMP 32767
/u10/EXAM/ORADATA/CDB/pdbseed/pdbseed_temp012016-10-04_03-18-32-PM.dbf
3 20 PDB1:TEMP 32767
/u10/EXAM/ORADATA/CDB/pdb1/temp012016-10-04_03-18-32-PM.dbf
4 20 SALESPDB:TEMP 32767 /u10/EXAM/ORADATA/CDB/salespdb/pdbseed_temp012016-10-04_03-18-32-PM.dbf
5 20 PDB2:TEMP 32767
/u10/EXAM/ORADATA/CDB/pdb2/temp012016-10-04_03-18-32-PM.dbf
6 20 HRPDB:TEMP 32767 /u10/EXAM/ORADATA/CDB/hrpdb/pdbseed_temp012016-10-04_03-18-32-PM.dbf
RMAN>
Note: You can take multiple pluggable databases using
below format script also:
rman>
run {
setlimit channel ch1 maxopenfiles 8;
backup
incremental level = 0
filesperset = 32
pluggable database pdb1, ..pdbn;
}
exit;
setlimit channel ch1 maxopenfiles 8;
backup
incremental level = 0
filesperset = 32
pluggable database pdb1, ..pdbn;
}
exit;
rman>
Now do following activity
for test:
SQL> alter pluggable
database SALESPDB close immediate;
Pluggable database
altered.
SQL>
$ cd /u10/EXAM/ORADATA/CDB/salespdb
]$ pwd
/u10/EXAM/ORADATA/CDB/salespdb
$ mv sales01.dbf
sales01.dbf_bkp
SQL> alter pluggable
database salespdb open;
alter pluggable database
salespdb open
*
ERROR at line 1:
ORA-01157: cannot
identify/lock data file 13 - see DBWR trace file
ORA-01110: data file 13:
'/u10/EXAM/ORADATA/CDB/salespdb/sales01.dbf'
SQL>
Here I am trying to open my pdb. It is clearly showing “sales01.dbf” datafile is missing. So you need to restore and recover from last valid backup.
Now start restore and
Recover:
RMAN> restore
pluggable database salespdb;
Starting restore at
10-OCT-2016 15:25:51
using channel ORA_DISK_1
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 00011 to /u10/EXAM/ORADATA/CDB/salespdb/system01.dbf
channel ORA_DISK_1:
restoring datafile 00012 to /u10/EXAM/ORADATA/CDB/salespdb/sysaux01.dbf
channel ORA_DISK_1:
restoring datafile 00013 to /u10/EXAM/ORADATA/CDB/salespdb/sales01.dbf
channel ORA_DISK_1:
reading from backup piece
/u10/EXAM/fast_recovery_area/salespdb_full_12c_db_0krhs1k5_1_1
channel ORA_DISK_1: piece
handle=/u10/EXAM/fast_recovery_area/salespdb_full_12c_db_0krhs1k5_1_1
tag=TAG20161008T171028
channel ORA_DISK_1:
restored backup piece 1
channel ORA_DISK_1:
restore complete, elapsed time: 00:00:55
Finished restore at
10-OCT-2016 15:26:46
Now Recover the pluggable database:
RMAN> recover
pluggable database salespdb;
Starting recover at
10-OCT-2016 15:26:58
using channel ORA_DISK_1
starting media recovery
archived log for thread 1
with sequence 54 is already on disk as file
/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_08/o1_mf_1_54_czkvhl14_.arc
archived log for thread 1
with sequence 55 is already on disk as file
/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_08/o1_mf_1_55_czl60bfv_.arc
archived log for thread 1
with sequence 56 is already on disk as file
/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_08/o1_mf_1_56_czlf1tko_.arc
archived log for thread 1
with sequence 57 is already on disk as file
/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_09/o1_mf_1_57_czm3ywck_.arc
archived log for thread 1
with sequence 58 is already on disk as file
/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_09/o1_mf_1_58_czm95ftg_.arc
archived log for thread 1
with sequence 59 is already on disk as file
/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_09/o1_mf_1_59_czmlktv5_.arc
archived log for thread 1
with sequence 60 is already on disk as file
/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_09/o1_mf_1_60_czn1s62o_.arc
archived log for thread 1
with sequence 61 is already on disk as file
/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_09/o1_mf_1_61_cznh65n2_.arc
archived log for thread 1
with sequence 62 is already on disk as file /u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_09/o1_mf_1_62_cznpw5wk_.arc
archived log for thread 1
with sequence 63 is already on disk as file
/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_09/o1_mf_1_63_czny6jb4_.arc
archived log for thread 1
with sequence 64 is already on disk as file
/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_10/o1_mf_1_64_czom11oo_.arc
archived log for thread 1
with sequence 65 is already on disk as file
/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_10/o1_mf_1_65_czpkzhmk_.arc
archived log file
name=/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_08/o1_mf_1_54_czkvhl14_.arc
thread=1 sequence=54
archived log file
name=/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_08/o1_mf_1_55_czl60bfv_.arc
thread=1 sequence=55
archived log file
name=/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_08/o1_mf_1_56_czlf1tko_.arc
thread=1 sequence=56
archived log file
name=/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_09/o1_mf_1_57_czm3ywck_.arc
thread=1 sequence=57
archived log file
name=/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_09/o1_mf_1_58_czm95ftg_.arc
thread=1 sequence=58
archived log file
name=/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_09/o1_mf_1_59_czmlktv5_.arc
thread=1 sequence=59
archived log file
name=/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_09/o1_mf_1_60_czn1s62o_.arc
thread=1 sequence=60
archived log file
name=/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_09/o1_mf_1_61_cznh65n2_.arc
thread=1 sequence=61
archived log file name=/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_09/o1_mf_1_62_cznpw5wk_.arc
thread=1 sequence=62
archived log file
name=/u10/EXAM/fast_recovery_area/CDB/archivelog/2016_10_09/o1_mf_1_63_czny6jb4_.arc
thread=1 sequence=63
media recovery complete,
elapsed time: 00:00:07
Finished recover at
10-OCT-2016 15:27:06
RMAN> quit
Recovery Manager
complete.
Now verify your pluggbale database datafiles. Sure it is recovered.
[oracle@eh-uatdb1
salespdb]$ ls
pdbseed_temp012016-10-04_03-18-32-PM.dbf sales01.dbf
sales01.dbf_bkp sysaux01.dbf system01.dbf
$ ls sales01.dbf
sales01.dbf
$
Now You can open the "salespdb" pluggable database.
SQL> alter pluggable
database salespdb open;
Pluggable database
altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 READ WRITE NO
4 SALESPDB READ WRITE NO
5 PDB2 READ WRITE NO
6 HRPDB READ WRITE NO
SQL>
This comment has been removed by a blog administrator.
ReplyDelete