12C的PDB使用RMAN不完全恢复drop user场景

来源:互联网 发布:男性保健药品 知乎 编辑:程序博客网 时间:2024/06/09 01:12


模拟故障

SQL> alter session set container=pdb4;Session altered.SQL> select systimestamp from dual;SYSTIMESTAMP---------------------------------------------------------------------------11-JUN-17 10.32.42.670589 PM +08:00SQL> drop user test cascade;User dropped.

恢复

RMAN> run2> {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 clauseStarting restore at 11-JUN-17using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=26 device type=DISKcreating datafile file number=41 name=/u01/app/oracle/oradata/zylong/pdb4/pdb4/users01.dbfRMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of restore command at 06/11/2017 22:39:06ORA-01182: cannot create database file 41 - file is in use or recoveryORA-01110: data file 41: '/u01/app/oracle/oradata/zylong/pdb4/pdb4/users01.dbf'

需要关闭PDB

SQL> conn / as sysdbaConnected.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> run2> {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 clauseStarting restore at 11-JUN-17using channel ORA_DISK_1creating datafile file number=41 name=/u01/app/oracle/oradata/zylong/pdb4/pdb4/users01.dbfchannel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00038 to /u01/app/oracle/oradata/zylong/pdb4/pdb4/system01.dbfchannel ORA_DISK_1: restoring datafile 00039 to /u01/app/oracle/oradata/zylong/pdb4/pdb4/sysaux01.dbfchannel ORA_DISK_1: restoring datafile 00040 to /u01/app/oracle/oradata/zylong/pdb4/pdb4/undotbs01.dbfchannel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/12.2.0/db_1/dbs/06s6i7hv_1_1channel ORA_DISK_1: piece handle=/u01/app/oracle/product/12.2.0/db_1/dbs/06s6i7hv_1_1 tag=TAG20170611T202849channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:07Finished restore at 11-JUN-17Starting recover at 11-JUN-17RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of recover command at 06/11/2017 22:41:19RMAN-05107: AUXILIARY DESTINATION option is not specified

需要指定AUXILIARY DESTINATION

RMAN> run2> {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 clauseStarting restore at 11-JUN-17using channel ORA_DISK_1creating datafile file number=41 name=/u01/app/oracle/oradata/zylong/pdb4/pdb4/users01.dbfchannel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00038 to /u01/app/oracle/oradata/zylong/pdb4/pdb4/system01.dbfchannel ORA_DISK_1: restoring datafile 00039 to /u01/app/oracle/oradata/zylong/pdb4/pdb4/sysaux01.dbfchannel ORA_DISK_1: restoring datafile 00040 to /u01/app/oracle/oradata/zylong/pdb4/pdb4/undotbs01.dbfchannel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/12.2.0/db_1/dbs/06s6i7hv_1_1channel ORA_DISK_1: piece handle=/u01/app/oracle/product/12.2.0/db_1/dbs/06s6i7hv_1_1 tag=TAG20170611T202849channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:07Finished restore at 11-JUN-17Starting recover at 11-JUN-17using channel ORA_DISK_1starting media recoverymedia recovery complete, elapsed time: 00:00:01Finished recover at 11-JUN-17

启动PDB测试

RMAN> Alter pluggable database pdb4 open resetlogs;Statement processed测试SQL> conn test/oracle@192.168.16.81:1521/pdb4Connected.SQL> select count(*) from test;  COUNT(*)----------       396

原创粉丝点击