模拟故障
SQL> alter session set container=pdb4;
Session altered.
SQL> select systimestamp from dual;
SYSTIMESTAMP
---------------------------------------------------------------------------
11-JUN-17 10.32.42.670589 PM +08:00
SQL> drop user test cascade;
User dropped.
恢复
RMAN> run
2> {
3> set until time "to_date('2017-06-11 22:32:42','YYYY-MM-DD HH24:MI:SS')";
4> restore pluggable database pdb4;
5> recover pluggable database pdb4;
6> }
executing command: SET until clause
Starting restore at 11-JUN-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=26 device type=DISK
creating datafile file number=41 name=/u01/app/oracle/oradata/zylong/pdb4/pdb4/users01.dbf
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/11/2017 22:39:06
ORA-01182: cannot create database file 41 - file is in use or recovery
ORA-01110: data file 41: '/u01/app/oracle/oradata/zylong/pdb4/pdb4/users01.dbf'
需要关闭PDB
SQL> conn / as sysdba
Connected.
SQL> alter pluggable database pdb4 close;
Pluggable database altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 SEED_PDB MOUNTED
4 NONCDB_PDP MOUNTED
5 CLON_PDB MOUNTED
6 TEST_PDB READ WRITE NO
7 PDB4 MOUNTED
再次恢复
RMAN> run
2> {
3> set until time "to_date('2017-06-11 22:32:42','YYYY-MM-DD HH24:MI:SS')";
4> restore pluggable database pdb4;
5> recover pluggable database pdb4;
6> }
executing command: SET until clause
Starting restore at 11-JUN-17
using channel ORA_DISK_1
creating datafile file number=41 name=/u01/app/oracle/oradata/zylong/pdb4/pdb4/users01.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 00038 to /u01/app/oracle/oradata/zylong/pdb4/pdb4/system01.dbf
channel ORA_DISK_1: restoring datafile 00039 to /u01/app/oracle/oradata/zylong/pdb4/pdb4/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00040 to /u01/app/oracle/oradata/zylong/pdb4/pdb4/undotbs01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/12.2.0/db_1/dbs/06s6i7hv_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/product/12.2.0/db_1/dbs/06s6i7hv_1_1 tag=TAG20170611T202849
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 11-JUN-17
Starting recover at 11-JUN-17
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/11/2017 22:41:19
RMAN-05107: AUXILIARY DESTINATION option is not specified
需要指定AUXILIARY DESTINATION
RMAN> run
2> {
3> set until time "to_date('2017-06-11 22:30:42','YYYY-MM-DD HH24:MI:SS')";
4> restore pluggable database pdb4;
5> recover pluggable database pdb4 AUXILIARY DESTINATION '/tmp';
6> }
executing command: SET until clause
Starting restore at 11-JUN-17
using channel ORA_DISK_1
creating datafile file number=41 name=/u01/app/oracle/oradata/zylong/pdb4/pdb4/users01.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 00038 to /u01/app/oracle/oradata/zylong/pdb4/pdb4/system01.dbf
channel ORA_DISK_1: restoring datafile 00039 to /u01/app/oracle/oradata/zylong/pdb4/pdb4/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00040 to /u01/app/oracle/oradata/zylong/pdb4/pdb4/undotbs01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/12.2.0/db_1/dbs/06s6i7hv_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/product/12.2.0/db_1/dbs/06s6i7hv_1_1 tag=TAG20170611T202849
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 11-JUN-17
Starting recover at 11-JUN-17
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 11-JUN-17
启动PDB测试
RMAN> Alter pluggable database pdb4 open resetlogs;
Statement processed
测试
SQL> conn test/oracle@192.168.16.81:1521/pdb4
Connected.
SQL> select count(*) from test;
COUNT(*)
----------
396