RMAN supports backup and recovery of multitenant container databases (CDBs) and pluggable databases (PDBs), which are introduced in Oracle Database 12c. The support includes backing up CDBs and PDBs and performing both complete and point-in-time recovery of entire CDBs or individual PDBs.
You should have SYSBACKUP or SYSDBA privilege to backup any of the databases.
PDB常用打开关闭命令
alter pluggable database all open;
alter pluggable database all except pdb3 open;
alter pluggable database pdb1, pdb2 open read only;
alter pluggable database all close immediate;
备份PDB,CDB
备份Whole Container Database (CDB)
RMAN> BACKUP DATABASE plus ARCHIVELOG;
[oracle@db1 ~]$ rman target
Recovery Manager: Release 12.1.0.2.0 - Production on Mon Mar 21 17:03:16 2016
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB1 (DBID=879831934)
RMAN> backup as compressed backupset database plus archivelog;
Starting backup at 21-MAR-16
current log archived
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 compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=21 RECID=1 STAMP=906224419
input archived log thread=1 sequence=29 RECID=2 STAMP=907088637
channel ORA_DISK_1: starting piece 1 at 21-MAR-16
channel ORA_DISK_1: finished piece 1 at 21-MAR-16
piece handle=/u01/oracle/product/121/dbs/03r124nu_1_1 tag=TAG20160321T170357 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 21-MAR-16
Starting backup at 21-MAR-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/oradata/cdb1/system01.dbf
input datafile file number=00003 name=/oradata/cdb1/sysaux01.dbf
input datafile file number=00004 name=/oradata/cdb1/undotbs01.dbf
input datafile file number=00006 name=/oradata/cdb1/users01.dbf
channel ORA_DISK_1: starting piece 1 at 21-MAR-16
channel ORA_DISK_1: finished piece 1 at 21-MAR-16
piece handle=/u01/oracle/product/121/dbs/04r124o5_1_1 tag=TAG20160321T170405 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00009 name=/oradata/cdb1/pdb11/sysaux01.dbf
input datafile file number=00008 name=/oradata/cdb1/pdb11/system01.dbf
input datafile file number=00010 name=/oradata/cdb1/pdb11/pdb11_users01.dbf
channel ORA_DISK_1: starting piece 1 at 21-MAR-16
channel ORA_DISK_1: finished piece 1 at 21-MAR-16
piece handle=/u01/oracle/product/121/dbs/05r124q6_1_1 tag=TAG20160321T170405 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
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=/oradata/cdb1/pdb12/sysaux01.dbf
input datafile file number=00011 name=/oradata/cdb1/pdb12/system01.dbf
input datafile file number=00013 name=/oradata/cdb1/pdb12/pdb12_users01.dbf
channel ORA_DISK_1: starting piece 1 at 21-MAR-16
channel ORA_DISK_1: finished piece 1 at 21-MAR-16
piece handle=/u01/oracle/product/121/dbs/06r124ra_1_1 tag=TAG20160321T170405 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/oradata/cdb1/pdbseed/sysaux01.dbf
input datafile file number=00005 name=/oradata/cdb1/pdbseed/system01.dbf
channel ORA_DISK_1: starting piece 1 at 21-MAR-16
channel ORA_DISK_1: finished piece 1 at 21-MAR-16
piece handle=/u01/oracle/product/121/dbs/07r124sd_1_1 tag=TAG20160321T170405 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
Finished backup at 21-MAR-16
Starting backup at 21-MAR-16
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=30 RECID=3 STAMP=907088816
channel ORA_DISK_1: starting piece 1 at 21-MAR-16
channel ORA_DISK_1: finished piece 1 at 21-MAR-16
piece handle=/u01/oracle/product/121/dbs/08r124tg_1_1 tag=TAG20160321T170656 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 21-MAR-16
Starting Control File and SPFILE Autobackup at 21-MAR-16
piece handle=/u01/oracle/product/121/dbs/c-879831934-20160321-00 comment=NONE
Finished Control File and SPFILE Autobackup at 21-MAR-16
RMAN>
备份ROOT
RMAN> BACKUP DATABASE ROOT;
RMAN> BACKUP DATABASE ROOT;
Starting backup at 21-MAR-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=60 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=/oradata/cdb1/system01.dbf
input datafile file number=00003 name=/oradata/cdb1/sysaux01.dbf
input datafile file number=00004 name=/oradata/cdb1/undotbs01.dbf
input datafile file number=00006 name=/oradata/cdb1/users01.dbf
channel ORA_DISK_1: starting piece 1 at 21-MAR-16
channel ORA_DISK_1: finished piece 1 at 21-MAR-16
piece handle=/u01/oracle/product/121/dbs/0dr12m02_1_1 tag=TAG20160321T215826 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 21-MAR-16
Starting Control File and SPFILE Autobackup at 21-MAR-16
piece handle=/u01/oracle/product/121/dbs/c-879831934-20160321-03 comment=NONE
Finished Control File and SPFILE Autobackup at 21-MAR-16
RMAN>
备份pluggable Database
RMAN> BACKUP PLUGGABLE DATABASE PDB1, PDB2;
RMAN> backup as compressed backupset pluggable database pdb11;
Starting backup at 21-MAR-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00009 name=/oradata/cdb1/pdb11/sysaux01.dbf
input datafile file number=00008 name=/oradata/cdb1/pdb11/system01.dbf
input datafile file number=00010 name=/oradata/cdb1/pdb11/pdb11_users01.dbf
channel ORA_DISK_1: starting piece 1 at 21-MAR-16
channel ORA_DISK_1: finished piece 1 at 21-MAR-16
piece handle=/u01/oracle/product/121/dbs/0ar12520_1_1 tag=TAG20160321T170920 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
Finished backup at 21-MAR-16
Starting Control File and SPFILE Autobackup at 21-MAR-16
piece handle=/u01/oracle/product/121/dbs/c-879831934-20160321-01 comment=NONE
Finished Control File and SPFILE Autobackup at 21-MAR-16
RMAN>
备份pluggable Database
$rman target sys@PDB1
RMAN> BACKUP DATABASE;
备份归档
归档备份只能通过CDB去备份,PDB用户无法备份归档和切换日志
RMAN> backup archivelog all;
SQL> alter system switch logfile;
alter system switch logfile
*
ERROR at line 1:
ORA-65040: operation not allowed from within a pluggable database
SQL>
CDB,PDB,ROOT完全恢复
还原Whole Container Database (CDB)
RMAN> RUN {
startup mount;
restore database;
recover database;
alter database open;}
Note:还原CDB,PDB也将会被还原
只还原ROOT Database
RMAN> RUN {
startup mount;
restore database root;
recover database root;
alter database open;
}
RMAN> restore database root;
Starting restore at 21-MAR-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=21 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 oradata/cdb1/system01.dbf
channel ORA_DISK_1: restoring datafile 00003 to oradata/cdb1/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to oradata/cdb1/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00006 to oradata/cdb1/users01.dbf
channel ORA_DISK_1: reading from backup piece u01/oracle/product/121/dbs/0dr12m02_1_1
channel ORA_DISK_1: piece handle=/u01/oracle/product/121/dbs/0dr12m02_1_1 tag=TAG20160321T215826
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 21-MAR-16
RMAN> recover database root;
Starting recover at 21-MAR-16
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished recover at 21-MAR-16
RMAN> alter database open;
Statement processed
RMAN>
我们有2种方式还原PDB
1.通过cdb还原pdb
RMAN > RUN {
restore pluggable database pdb1, pdb2;
recover pluggable database pdb1, pdb2;
alter pluggable database pdb1, pdb2 open;
}
2.直接连接pdb,然后还原
$ rman target=rcadm@PDB1
RMAN> run{
restore database;
recover database;
}
文章转载自善存oracle技术社区,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




