今天測試了一下12c中的PDB還原恢複,裡面還是有不少的差别。
我就簡單模拟了一個破壞場景,是在一個未打開的PDB tcymob0從中删除了資料檔案usres01.dbf,然後嘗試備份恢複。
當然在這個操作前,我們使用RMAN來備份,使用指令backup database即可備份整個資料庫。
手工破壞的語句如下:
$ rm /U01/app/oracle/oradata/test12cs/tcymob0/pdbseed/users01.dbf這個時候的還原工作就很清晰了,直接還原對應的表空間或者資料檔案都可以。比如表空間是users,則需要指定PDB的名字。
RMAN> restore tablespace tcymob0:users;
RMAN> recovertablespace tcymob0:users;
Starting recover at 2017-06-03 22:58:31
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 2017-06-03 22:58:31
整個恢複工作做好之後,留下來的任務就是直接啟庫了,但是奇怪的是卻報了下面的錯誤。
SQL> alter pluggable database tcymob0 open;
alter pluggable database tcymob0 open
*
ERROR at line 1:
ORA-65086: cannot open/close the pluggable database
Oracle對這個錯誤的解釋如下:
oerr ora 65086
65086, 00000, "cannot open/close the pluggable database"
// *Cause: The pluggable database has been unplugged.
// *Action: The pluggable database can only be dropped.
//
這下我還真想起來了,之前測試的時候,我使用RMAN模拟跨平台的PDB備份恢複,使用了unplug的方式,根據這個錯誤,對于這個問題也有了思路。
之前unplug的語句如下:
ALTER PLUGGABLE DATABASE tcymob0 UNPLUG INTO '/tmp/tcymob0.xml';
在這個基礎上,我們可以使用plugging的方式重新挂載即可。
drop pluggable database tcymob0;
CREATE pluggable DATABASE tcymob0 USING '/tmp/tcymob0.xml' NOCOPY;
alter pluggable database tcymob0 open;
而在這個時候,需要做的第一件事情,就是重新備份了。因為有了drop pluggable database的操作之後,容器的設定會發生變化,比如con_id,原來的備份就識别不了了。
RMAN> restore tablespace tcymob0:system;
Starting restore at 2017-06-03 23:29:49
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 137 found to restore