Oracle12c多租戶資料庫備份與恢復 - PDB中資料檔案的恢復

tolywang發表於2014-03-11

模擬PDB中資料檔案的恢復

SQL> alter session set container=plugdb ;
Session altered.

SQL> select count(1) from  hw.HW_PAY_GROUP_LOG ;
  COUNT(1)
----------
    330594

SQL> col name for a60
SQL> select file#,name from v$datafile;

     FILE# NAME
---------- ------------------------------------------------------------
         5 /data01/oracle12c/oradata/test12/undotbs01.dbf
         7 /data01/oracle12c/oradata/test12/plugdb/system01.dbf
         8 /data01/oracle12c/oradata/test12/plugdb/sysaux01.dbf
         9 /data01/oracle12c/oradata/test12/plugdb/plugdb_users01.dbf
        12 /data01/oracle12c/oradata/test12/plugdb/hw01.dbf


資料表在hw01.dbf上,這裡offline這個檔案進行測試

SQL> alter database datafile 12 offline; 


刪除資料檔案hw01.dbf
$ rm  /data01/oracle12c/oradata/test12/plugdb/hw01.dbf 


在CDB層級恢復PDB中的檔案

[oracle@nkgtsv2024rhl plugdb]$  rman target   /
connected to target database: TEST12 (DBID=4129983816)

RMAN> list backup of datafile 12;

.....

RMAN> restore datafile 12 ;    

Starting restore at 06-MAR-14

RMAN> recover datafile 12 ;

Finished recover at 06-MAR-14


在CDB層online恢復的資料檔案報錯

RMAN> alter database datafile 12 online ;

RMAN-03002: failure of sql statement command at 03/06/2014 17:46:59
ORA-01516: nonexistent log file, data file, or temporary file "12"

RMAN>        

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL> alter database datafile 12 online;
alter database datafile 12 online
*
ERROR at line 1:
ORA-01516: nonexistent log file, data file, or temporary file "12"

SQL> alter session set container=plugdb ;
SQL> alter database datafile 12 online ;
SQL> select count(1) from  hw.HW_PAY_GROUP_LOG ;

  COUNT(1)
----------
    330594

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/35489/viewspace-1107148/,如需轉載,請註明出處,否則將追究法律責任。

相關文章