Oracle

RMAN 從標籤恢復

  • October 27, 2015

紅帽 6 上的 oracle 11.2.0.4

SERV1 是執行數據庫 MAZ 的 prod 伺服器,SERV2 是沒有數據庫的開發伺服器。

我已經記下了 dbid 和最後一個 SCN,然後使用以下命令在 SERV1 上進行了備份

run
{
backup database plus archivelog tag "first";
}

現在將所有備份文件和 pfile 的副本複製到 SERV2。

在 SERV2 上

rman target /
set dbid 2711958994
startup mount pfile=/u01/app/oracle/product/11.2.0/dbhome_2/dbs/initmaz.ora
run {
set controlfile autobackup format for device type disk to '/u03/app/oracle/fast_recovery_area/TEST/autobackup/2015_05_15/%F';
restore spfile to pfile '/u01/app/oracle/product/11.2.0/dbhome_2/dbs/initmaz.ora' from autobackup;
}

shutdown immediate
startup nomount pfile=/u01/app/oracle/product/11.2.0/dbhome_2/dbs/initmaz.ora

run {
set controlfile autobackup format for device type disk to '/u03/app/oracle/fast_recovery_area/TEST/autobackup/2015_05_15/%F';
restore controlfile from autobackup;
}

alter database mount;

catalog start with '/u03/app/oracle/fast_recovery_area/MAZ/backupset/2015_05_15';

現在我檢查了它在 SERV2 上可用的備份集

rman target /
RMAN> list backup
2> ;

using target database control file instead of recovery catalog

List of Backup Sets
===================


BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
190     6.59M      DISK        00:00:00     15-MAY-15
       BP Key: 190   Status: AVAILABLE  Compressed: YES  Tag: FIRST
       Piece Name: /u03/app/oracle/fast_recovery_area/MAZ/backupset/2015_05_15/o1_mf_annnn_FIRST_bocjlvfk_.bkp

 List of Archived Logs in backup set 190
 Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
 ---- ------- ---------- --------- ---------- ---------
 1    501     1950316    14-MAY-15 1973213    15-MAY-15
 1    502     1973213    15-MAY-15 1973254    15-MAY-15
 1    503     1973254    15-MAY-15 1974268    15-MAY-15
 1    504     1974268    15-MAY-15 1974295    15-MAY-15
 1    505     1974295    15-MAY-15 1974321    15-MAY-15
 1    506     1974321    15-MAY-15 1976213    15-MAY-15
 1    507     1976213    15-MAY-15 1976251    15-MAY-15
 1    508     1976251    15-MAY-15 1977715    15-MAY-15

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
191     Full    76.84M     DISK        00:00:30     15-MAY-15
       BP Key: 191   Status: AVAILABLE  Compressed: YES  Tag: TAG20150515T105436
       Piece Name: /u03/app/oracle/fast_recovery_area/MAZ/backupset/2015_05_15/o1_mf_nnndf_TAG20150515T105436_bocjlwr0_.bkp
 List of Datafiles in backup set 191
 File LV Type Ckp SCN    Ckp Time  Name
 ---- -- ---- ---------- --------- ----
 1       Full 1977721    15-MAY-15 /u02/app/oracle/oradata/maz/system01.dbf
 2       Full 1977721    15-MAY-15 /u02/app/oracle/oradata/maz/sysaux01.dbf
 3       Full 1977721    15-MAY-15 /u02/app/oracle/oradata/maz/undotbs01.dbf
 4       Full 1977721    15-MAY-15 /u02/app/oracle/oradata/maz/users01.dbf

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
192     3.00K      DISK        00:00:00     15-MAY-15
       BP Key: 192   Status: AVAILABLE  Compressed: YES  Tag: FIRST
       Piece Name: /u03/app/oracle/fast_recovery_area/MAZ/backupset/2015_05_15/o1_mf_annnn_FIRST_bocjmzy1_.bkp

 List of Archived Logs in backup set 192
 Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
 ---- ------- ---------- --------- ---------- ---------
 1    509     1977715    15-MAY-15 1977737    15-MAY-15

此時,如果我執行以下命令,那麼一切正常

run {
set until scn 1977737;
restore database;
recover database;
}

alter database open resetlogs;

但我想使用標籤名稱(FIRST)恢復,所以我試試這個

run {
set until scn 1977737;
restore database from TAG=FIRST;
}

我收到消息

Starting restore at 15-MAY-15
using channel ORA_DISK_1

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 05/15/2015 13:15:05
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 2 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore

關於我做錯了什麼的任何想法?

謝謝

正確的備份語法應該是:

backup database tag "first" plus archivelog tag "first";

現在,如果您查看list backup輸出,您會注意到只有帶有歸檔日誌的備份集具有標記 FIRST。包含數據文件備份的備份集具有自動生成的標籤 TAG20150515T105436。

首先像這樣關閉數據庫:

SQL>shut immediate;
SQL>startup mount;

否則,您可以使用此方法:

SQL>start mount;
SQL>alter database archivelog;
SQL>alter database open

引用自:https://dba.stackexchange.com/questions/101612