RMAN異地恢復實戰

jolly10發表於2008-07-04
目的:用RMAN將61.106的database恢復到61.99
OS: both rhel u4
ORACLE: both 10.2.0.4[@more@]

步驟:
1.full backup 61.106的資料
RMAN> backup database;

Starting backup at 04-JUL-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=235 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00008 name=/u01/oradata/orcl/office01.dbf
input datafile fno=00011 name=/u01/oradata/orcl/cmrspace01.dbf
input datafile fno=00013 name=/u01/oradata/orcl/pbrspace01.dbf
input datafile fno=00014 name=/u01/oradata/orcl/q01_arbspace01.dbf
input datafile fno=00017 name=/u01/oradata/orcl/c202_vipspace01.dbf
input datafile fno=00018 name=/u01/oradata/orcl/c202_vipspace02.dbf
input datafile fno=00019 name=/u01/oradata/orcl/c202_vipspace03.dbf
input datafile fno=00020 name=/u01/oradata/orcl/c202_vipspace04.dbf
input datafile fno=00021 name=/u01/oradata/orcl/c202_vipspace05.dbf
input datafile fno=00022 name=/u01/oradata/orcl/c202_vipspace06.dbf
input datafile fno=00023 name=/u01/oradata/orcl/c202_vipspace07.dbf
input datafile fno=00024 name=/u01/oradata/orcl/c202_vipspace08.dbf
input datafile fno=00012 name=/u01/oradata/orcl/MPSPACE_001.dbf
input datafile fno=00002 name=/u01/oradata/orcl/undotbs01.dbf
input datafile fno=00005 name=/u01/oradata/orcl/qhtdata01.dbf
input datafile fno=00006 name=/u01/oradata/orcl/l5mspace01.dbf
input datafile fno=00015 name=/u01/oradata/orcl/q01_l5mspace01.dbf
input datafile fno=00009 name=/u01/oradata/orcl/mtrxspace01.dbf
input datafile fno=00010 name=/u01/oradata/orcl/magspace01.dbf
input datafile fno=00003 name=/u01/oradata/orcl/sysaux01.dbf
input datafile fno=00001 name=/u01/oradata/orcl/system01.dbf
input datafile fno=00007 name=/u01/oradata/orcl/clt_stats01.dbf
input datafile fno=00016 name=/u01/oradata/orcl/q01_brdspace01.dbf
input datafile fno=00004 name=/u01/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 04-JUL-08
channel ORA_DISK_1: finished piece 1 at 04-JUL-08
piece handle=/u01/backup/rman_106/ORCL_1_1.bak tag=TAG20080704T091759 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:07:56
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 04-JUL-08
channel ORA_DISK_1: finished piece 1 at 04-JUL-08
piece handle=/u01/backup/rman_106/ORCL_2_1.bak tag=TAG20080704T091759 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 04-JUL-08


2.將兩個backupset複製到61.99:/u01/backup/rman_106

3.建立或恢復pfile.
直接將61.106的pfile複製過來或者從backupset恢復,恢復時需先指定dbid,用無引數檔案的方式

啟動到nomount狀態.後recover spfile to pfile 'XXX' from '[backupset] XXX'.恢復過來後用恢

復的pfile重新啟動的mount狀態.

4.恢復控制檔案

RMAN> restore controlfile from '/u01/backup/ORCL_2_1.bak';

Starting restore at 04-JUL-08
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output filename=/u01/oradata/orcl/control01.ctl
output filename=/u01/oradata/orcl/control02.ctl
output filename=/u01/oradata/orcl/control03.ctl
Finished restore at 04-JUL-08


RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

5.恢復資料檔案
這裡出現了點問題,剛開始恢復時,錯誤如下:
RMAN> restore database;

Starting restore at 04-JUL-08
Starting implicit crosscheck backup at 04-JUL-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=321 devtype=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 04-JUL-08

Starting implicit crosscheck copy at 04-JUL-08
using channel ORA_DISK_1
Finished implicit crosscheck copy at 04-JUL-08

searching for all files in the recovery area
cataloging files...
no files cataloged

using channel ORA_DISK_1

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 07/04/2008 10:31:56
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 24 found to restore
RMAN-06023: no backup or copy of datafile 23 found to restore
RMAN-06023: no backup or copy of datafile 22 found to restore
RMAN-06023: no backup or copy of datafile 21 found to restore
RMAN-06023: no backup or copy of datafile 20 found to restore
RMAN-06023: no backup or copy of datafile 19 found to restore
RMAN-06023: no backup or copy of datafile 18 found to restore
RMAN-06023: no backup or copy of datafile 17 found to restore
RMAN-06023: no backup or copy of datafile 16 found to restore
RMAN-06023: no backup or copy of datafile 15 found to restore
RMAN-06023: no backup or copy of datafile 14 found to restore
RMAN-06023: no backup or copy of datafile 13 found to restore
RMAN-06023: no backup or copy of datafile 12 found to restore
RMAN-06023: no backup or copy of datafile 11 found to restore
RMAN-06023: no backup or copy of datafile 10 found to restore
RMAN-06023: no backup or copy of datafile 9 found to restore
RMAN-06023: no backup or copy of datafile 8 found to restore
RMAN-06023: no backup or copy of datafile 7 found to restore
RMAN-06023: no backup or copy of datafile 6 found to restore
RMAN-06023: no backup or copy of datafile 5 found to 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

分析原因,應該是找不到備份集來做恢復,用list backup看看恢復集的情況,發現status是expired的.

RMAN> list backup;

using target database control file instead of recovery catalog

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

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 9.16G DISK 00:07:53 04-JUL-08
BP Key: 1 Status: EXPIRED Compressed: NO Tag: TAG20080704T091759
Piece Name: /u01/backup/rman_106/ORCL_1_1.bak
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 65089949 04-JUL-08 /u01/oradata/orcl/system01.dbf
2 Full 65089949 04-JUL-08 /u01/oradata/orcl/undotbs01.dbf
3 Full 65089949 04-JUL-08 /u01/oradata/orcl/sysaux01.dbf
4 Full 65089949 04-JUL-08 /u01/oradata/orcl/users01.dbf
5 Full 65089949 04-JUL-08 /u01/oradata/orcl/qhtdata01.dbf
6 Full 65089949 04-JUL-08 /u01/oradata/orcl/l5mspace01.dbf
7 Full 65089949 04-JUL-08 /u01/oradata/orcl/clt_stats01.dbf
8 Full 65089949 04-JUL-08 /u01/oradata/orcl/office01.dbf
9 Full 65089949 04-JUL-08 /u01/oradata/orcl/mtrxspace01.dbf
10 Full 65089949 04-JUL-08 /u01/oradata/orcl/magspace01.dbf
11 Full 65089949 04-JUL-08 /u01/oradata/orcl/cmrspace01.dbf
12 Full 65089949 04-JUL-08 /u01/oradata/orcl/MPSPACE_001.dbf
13 Full 65089949 04-JUL-08 /u01/oradata/orcl/pbrspace01.dbf
14 Full 65089949 04-JUL-08 /u01/oradata/orcl/q01_arbspace01.dbf
15 Full 65089949 04-JUL-08 /u01/oradata/orcl/q01_l5mspace01.dbf
16 Full 65089949 04-JUL-08 /u01/oradata/orcl/q01_brdspace01.dbf
17 Full 65089949 04-JUL-08 /u01/oradata/orcl/c202_vipspace01.dbf
18 Full 65089949 04-JUL-08 /u01/oradata/orcl/c202_vipspace02.dbf
19 Full 65089949 04-JUL-08 /u01/oradata/orcl/c202_vipspace03.dbf
20 Full 65089949 04-JUL-08 /u01/oradata/orcl/c202_vipspace04.dbf
21 Full 65089949 04-JUL-08 /u01/oradata/orcl/c202_vipspace05.dbf
22 Full 65089949 04-JUL-08 /u01/oradata/orcl/c202_vipspace06.dbf
23 Full 65089949 04-JUL-08 /u01/oradata/orcl/c202_vipspace07.dbf
24 Full 65089949 04-JUL-08 /u01/oradata/orcl/c202_vipspace08.dbf

用crosscheck backup後狀態改為AVAILABLE了.

RMAN> crosscheck backup;

using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/rman_106/ORCL_1_1.bak recid=1 stamp=659179079
Crosschecked 1 objects


RMAN> list backup;


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

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 9.16G DISK 00:07:53 04-JUL-08
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20080704T091759
Piece Name: /u01/backup/rman_106/ORCL_1_1.bak
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 65089949 04-JUL-08 /u01/oradata/orcl/system01.dbf
2 Full 65089949 04-JUL-08 /u01/oradata/orcl/undotbs01.dbf
3 Full 65089949 04-JUL-08 /u01/oradata/orcl/sysaux01.dbf
4 Full 65089949 04-JUL-08 /u01/oradata/orcl/users01.dbf
5 Full 65089949 04-JUL-08 /u01/oradata/orcl/qhtdata01.dbf
6 Full 65089949 04-JUL-08 /u01/oradata/orcl/l5mspace01.dbf
7 Full 65089949 04-JUL-08 /u01/oradata/orcl/clt_stats01.dbf
8 Full 65089949 04-JUL-08 /u01/oradata/orcl/office01.dbf
9 Full 65089949 04-JUL-08 /u01/oradata/orcl/mtrxspace01.dbf
10 Full 65089949 04-JUL-08 /u01/oradata/orcl/magspace01.dbf
11 Full 65089949 04-JUL-08 /u01/oradata/orcl/cmrspace01.dbf
12 Full 65089949 04-JUL-08 /u01/oradata/orcl/MPSPACE_001.dbf
13 Full 65089949 04-JUL-08 /u01/oradata/orcl/pbrspace01.dbf
14 Full 65089949 04-JUL-08 /u01/oradata/orcl/q01_arbspace01.dbf
15 Full 65089949 04-JUL-08 /u01/oradata/orcl/q01_l5mspace01.dbf
16 Full 65089949 04-JUL-08 /u01/oradata/orcl/q01_brdspace01.dbf
17 Full 65089949 04-JUL-08 /u01/oradata/orcl/c202_vipspace01.dbf
18 Full 65089949 04-JUL-08 /u01/oradata/orcl/c202_vipspace02.dbf
19 Full 65089949 04-JUL-08 /u01/oradata/orcl/c202_vipspace03.dbf
20 Full 65089949 04-JUL-08 /u01/oradata/orcl/c202_vipspace04.dbf
21 Full 65089949 04-JUL-08 /u01/oradata/orcl/c202_vipspace05.dbf
22 Full 65089949 04-JUL-08 /u01/oradata/orcl/c202_vipspace06.dbf
23 Full 65089949 04-JUL-08 /u01/oradata/orcl/c202_vipspace07.dbf
24 Full 65089949 04-JUL-08 /u01/oradata/orcl/c202_vipspace08.dbf

現在再來restore.
RMAN> restore database;

Starting restore at 04-JUL-08
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/oradata/orcl/system01.dbf
restoring datafile 00002 to /u01/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /u01/oradata/orcl/sysaux01.dbf
restoring datafile 00004 to /u01/oradata/orcl/users01.dbf
restoring datafile 00005 to /u01/oradata/orcl/qhtdata01.dbf
restoring datafile 00006 to /u01/oradata/orcl/l5mspace01.dbf
restoring datafile 00007 to /u01/oradata/orcl/clt_stats01.dbf
restoring datafile 00008 to /u01/oradata/orcl/office01.dbf
restoring datafile 00009 to /u01/oradata/orcl/mtrxspace01.dbf
restoring datafile 00010 to /u01/oradata/orcl/magspace01.dbf
restoring datafile 00011 to /u01/oradata/orcl/cmrspace01.dbf
restoring datafile 00012 to /u01/oradata/orcl/MPSPACE_001.dbf
restoring datafile 00013 to /u01/oradata/orcl/pbrspace01.dbf
restoring datafile 00014 to /u01/oradata/orcl/q01_arbspace01.dbf
restoring datafile 00015 to /u01/oradata/orcl/q01_l5mspace01.dbf
restoring datafile 00016 to /u01/oradata/orcl/q01_brdspace01.dbf
restoring datafile 00017 to /u01/oradata/orcl/c202_vipspace01.dbf
restoring datafile 00018 to /u01/oradata/orcl/c202_vipspace02.dbf
restoring datafile 00019 to /u01/oradata/orcl/c202_vipspace03.dbf
restoring datafile 00020 to /u01/oradata/orcl/c202_vipspace04.dbf
restoring datafile 00021 to /u01/oradata/orcl/c202_vipspace05.dbf
restoring datafile 00022 to /u01/oradata/orcl/c202_vipspace06.dbf
restoring datafile 00023 to /u01/oradata/orcl/c202_vipspace07.dbf
restoring datafile 00024 to /u01/oradata/orcl/c202_vipspace08.dbf
channel ORA_DISK_1: reading from backup piece /u01/backup/rman_106/ORCL_1_1.bak
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/backup/rman_106/ORCL_1_1.bak tag=TAG20080704T091759
channel ORA_DISK_1: restore complete, elapsed time: 00:40:53
Finished restore at 04-JUL-08

5.recover database

RMAN> recover database;

Starting recover at 04-JUL-08
using channel ORA_DISK_1

starting media recovery

unable to find archive log
archive log thread=1 sequence=12
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 07/04/2008 11:30:16
RMAN-06054: media recovery requesting unknown log: thread 1 seq 12 lowscn 65089949

報錯了,但是沒關係,並非嚴重錯誤,只是提醒你恢復到一個未知的scn號。如果要避免這個錯誤,

可以在alter database mount之後,透過set until scn或者set until time命令設定恢復到的scn號

或時間。


6.開啟資料庫
RMAN>alter database open resetlogs;

驗證一下:

SQL> select status from v$instance;

STATUS
------------
OPEN

SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS

FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- -----------

-- ---------
1 1 1 536870912 1 NO CURRENT

65089950 04-JUL-08
2 1 0 536870912 1 YES UNUSED

0
3 1 0 536870912 1 YES UNUSED

0
4 1 0 536870912 1 YES UNUSED

0
5 1 0 536870912 1 YES UNUSED

0
6 1 0 536870912 1 YES UNUSED

0

6 rows selected.

redo log已重建.

7.最後記得用orapwd重建密碼檔案,成了.

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

相關文章