恢復rac db(raw)到單例項下

warehouse發表於2011-06-16

os:redhat as 4

oracle:oracle10gR2

客戶提出了這樣一個要求,演示一下rac db到單例項的恢復,他們的目的是檢驗生產環境的備份有效性

[@more@]

下面是思路和主要步驟:

1、先在rac db下生成一個init引數檔案

2、修改引數,cluster_database為false以及遮蔽local_listener等和叢集相關的引數

3、透過rman備份rac db(為了簡單我使用了catalog)

4、複製引數檔案和rac db備份到單例項機器上

5、在單例項機器上建立bdump以及資料檔案等所在的目錄

6、修改引數檔案中control_files的路徑和名字

7、在單例項機器上嘗試啟動例項到nomount狀態

8、透過rman恢復controlfile(restore controlfile to 新路徑)

9、alter database mount

10、主要恢復過程如下

RMAN> restore controlfile to '/app/oracle/oradata/rawdb/control01.ctl';

啟動 restore 於 2011-06-16 21:51:43
使用通道 ORA_DISK_1

通道 ORA_DISK_1: 正在開始恢復資料檔案備份集
通道 ORA_DISK_1: 正在復原控制檔案
輸出檔名=/app/oracle/oradata/rawdb/control01.ctl
通道 ORA_DISK_1: 正在讀取備份段 /app/dbbak/rawdb_20110616_03mf10gp_1_1.bak
通道 ORA_DISK_1: 已恢復備份段 1
段控制程式碼 = /app/dbbak/rawdb_20110616_03mf10gp_1_1.bak 標記 = TAG20110616T090953
通道 ORA_DISK_1: 恢復完成, 用時: 00:00:03
完成 restore 於 2011-06-16 21:51:50

RMAN> restore controlfile to '/app/oracle/oradata/rawdb/control02.ctl';

啟動 restore 於 2011-06-16 21:51:55
使用通道 ORA_DISK_1

通道 ORA_DISK_1: 正在開始恢復資料檔案備份集
通道 ORA_DISK_1: 正在復原控制檔案
輸出檔名=/app/oracle/oradata/rawdb/control02.ctl
通道 ORA_DISK_1: 正在讀取備份段 /app/dbbak/rawdb_20110616_03mf10gp_1_1.bak
通道 ORA_DISK_1: 已恢復備份段 1
段控制程式碼 = /app/dbbak/rawdb_20110616_03mf10gp_1_1.bak 標記 = TAG20110616T090953
通道 ORA_DISK_1: 恢復完成, 用時: 00:00:06
完成 restore 於 2011-06-16 21:52:05

RMAN>

startup mount

RMAN> run {
2> set newname for datafile 1 to '/app/oracle/oradata/rawdb/system01.dbf';
3> set newname for datafile 2 to '/app/oracle/oradata/rawdb/undotbs01.dbf';
4> set newname for datafile 3 to '/app/oracle/oradata/rawdb/sysaux01.dbf';
5> set newname for datafile 4 to '/app/oracle/oradata/rawdb/undotbs02.dbf';
6> set newname for datafile 5 to '/app/oracle/oradata/rawdb/users01.dbf';
7> restore database;
8> switch datafile all;
9> }

正在執行命令: SET NEWNAME

正在執行命令: SET NEWNAME

正在執行命令: SET NEWNAME

正在執行命令: SET NEWNAME

正在執行命令: SET NEWNAME

啟動 restore 於 2011-06-16 22:21:41
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=155 devtype=DISK

通道 ORA_DISK_1: 正在開始恢復資料檔案備份集
通道 ORA_DISK_1: 正在指定從備份集恢復的資料檔案
正將資料檔案00001恢復到/app/oracle/oradata/rawdb/system01.dbf
正將資料檔案00002恢復到/app/oracle/oradata/rawdb/undotbs01.dbf
正將資料檔案00003恢復到/app/oracle/oradata/rawdb/sysaux01.dbf
正將資料檔案00004恢復到/app/oracle/oradata/rawdb/undotbs02.dbf
正將資料檔案00005恢復到/app/oracle/oradata/rawdb/users01.dbf
通道 ORA_DISK_1: 正在讀取備份段 /app/dbbak/rawdb_20110616_02mf10f1_1_1.bak
通道 ORA_DISK_1: 已恢復備份段 1
段控制程式碼 = /app/dbbak/rawdb_20110616_02mf10f1_1_1.bak 標記 = TAG20110616T090953
通道 ORA_DISK_1: 恢復完成, 用時: 00:02:08
完成 restore 於 2011-06-16 22:24:30

資料檔案 1 已轉換成資料檔案副本
輸入資料檔案副本 recid=6 stamp=753905541 檔名=/app/oracle/oradata/rawdb/system01.dbf
資料檔案 2 已轉換成資料檔案副本
輸入資料檔案副本 recid=7 stamp=753905542 檔名=/app/oracle/oradata/rawdb/undotbs01.dbf
資料檔案 3 已轉換成資料檔案副本
輸入資料檔案副本 recid=8 stamp=753905542 檔名=/app/oracle/oradata/rawdb/sysaux01.dbf
資料檔案 4 已轉換成資料檔案副本
輸入資料檔案副本 recid=9 stamp=753905542 檔名=/app/oracle/oradata/rawdb/undotbs02.dbf
資料檔案 5 已轉換成資料檔案副本
輸入資料檔案副本 recid=10 stamp=753905542 檔名=/app/oracle/oradata/rawdb/users01.dbf

RMAN>

--=======================
SQL> alter database rename file '/dev/raw/raw12' to '/app/oracle/oradata/rawdb/redo01.ctl';

資料庫已更改。

SQL> alter database rename file '/dev/raw/raw13' to '/app/oracle/oradata/rawdb/redo02.ctl';

資料庫已更改。

SQL> alter database rename file '/dev/raw/raw14' to '/app/oracle/oradata/rawdb/redo03.ctl';

資料庫已更改。

SQL> alter database rename file '/dev/raw/raw15' to '/app/oracle/oradata/rawdb/redo04.log';

資料庫已更改。

--命名成ctl副檔名了重新命名一下(不重新命名也無所謂)
SQL> alter database rename file '/app/oracle/oradata/rawdb/redo01.ctl' to '/app/oracle/oradata/rawdb/redo01.log';

資料庫已更改。

SQL> alter database rename file '/app/oracle/oradata/rawdb/redo02.ctl' to '/app/oracle/oradata/rawdb/redo02.log';

資料庫已更改。

SQL> alter database rename file '/app/oracle/oradata/rawdb/redo03.ctl' to '/app/oracle/oradata/rawdb/redo03.log';

資料庫已更改。

SQL>
--=======================
SQL> recover database until cancel;
ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done


SQL> recover database using backup controlfile until cancel;
ORA-00279: change 651258 generated at 06/16/2011 09:09:53 needed for thread 1
ORA-00289: suggestion : /archivelog1_22_753784440.dbf
ORA-00280: change 651258 for thread 1 is in sequence #22


指定日誌: {=suggested | filename | AUTO | CANCEL}
auto
ORA-00308: cannot open archived log '/archivelog1_22_753784440.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3


ORA-00308: cannot open archived log '/archivelog1_22_753784440.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3


SQL> recover database using backup controlfile until cancel;
ORA-00279: change 651258 generated at 06/16/2011 09:09:53 needed for thread 1
ORA-00289: suggestion : /archivelog1_22_753784440.dbf
ORA-00280: change 651258 for thread 1 is in sequence #22


指定日誌: {=suggested | filename | AUTO | CANCEL}
cancel
介質恢復已取消。
SQL> alter database open resetlogs;

資料庫已更改。

SQL>
SQL> select status from v$instance;

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

SQL>
SQL> select name from v$database;

NAME
---------
RAWDB

SQL>
--================================
SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------
/app/oracle/oradata/rawdb/system01.dbf
/app/oracle/oradata/rawdb/undotbs01.dbf
/app/oracle/oradata/rawdb/sysaux01.dbf
/app/oracle/oradata/rawdb/undotbs02.dbf
/app/oracle/oradata/rawdb/users01.dbf

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/app/oracle/oradata/rawdb/control01.ctl

SQL> col member format a50
SQL> select member from v$logfile;

MEMBER
--------------------------------------------------
/app/oracle/oradata/rawdb/redo01.log
/app/oracle/oradata/rawdb/redo02.log
/app/oracle/oradata/rawdb/redo03.log
/app/oracle/oradata/rawdb/redo04.log

SQL>

--====================================

參考的文章:

Article-ID: Note 415579.1
Title: HowTo Restore RMAN Disk backups of RAC Database to Single
Instance On Another Node
Applies to:
Oracle Server - Enterprise Edition - Version: 9.2.0.0 to 10.2.0.0
Information in this document applies to any platform.
Goal
- You have a RAC database backed up by RMAN to disk locetion
- You need to restore this backup as Single Instance on another node
Solution
1) Take appropriate RMAN backup of the production RAC database. Note that you should turn on the CONTROLFILE AUTOBACKUP configuration so that we have the controlfile backed up after the database backup. When we restore the controlfile on new host from this autobackup piece, it will have the information of the latest backup.

RMAN> run{
2> allocate channel c1 type disk format '/oracle/10g/backup/%U';
3> backup database;
4> backup archivelog all;
5> }

allocated channel: c1
channel c1: sid=133 instance=racdb1 devtype=DISK

Starting backup at 12-FEB-07
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00001 name=/ocfs2/oradata/racdb/system01.dbf
input datafile fno=00002 name=/ocfs2/oradata/racdb/undotbs01.dbf
input datafile fno=00005 name=/ocfs2/oradata/racdb/undotbs02.dbf
input datafile fno=00003 name=/ocfs2/oradata/racdb/sysaux01.dbf
input datafile fno=00004 name=/ocfs2/oradata/racdb/users01.dbf
channel c1: starting piece 1 at 12-FEB-07
channel c1: finished piece 1 at 12-FEB-07
piece handle=/oracle/10g/backup/09i9sruq_1_1 tag=TAG20070212T162458 comment=NONE
channel c1: backup set complete, elapsed time: 00:01:05
Finished backup at 12-FEB-07

Starting backup at 12-FEB-07
current log archived
channel c1: starting archive log backupset
channel c1: specifying archive log(s) in backup set
input archive log thread=1 sequence=56 recid=3 stamp=613417105
input archive log thread=1 sequence=57 recid=4 stamp=613417106
input archive log thread=1 sequence=58 recid=5 stamp=614363168
input archive log thread=2 sequence=1 recid=1 stamp=613417090
input archive log thread=2 sequence=2 recid=2 stamp=613417093
input archive log thread=2 sequence=3 recid=6 stamp=614363170
channel c1: starting piece 1 at 12-FEB-07
channel c1: finished piece 1 at 12-FEB-07
piece handle=/oracle/10g/backup/0ai9ss14_1_1 tag=TAG20070212T162610 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:04
Finished backup at 12-FEB-07

Starting Control File and SPFILE Autobackup at 12-FEB-07
piece handle=/oracle/10g/backup/c-610677177-20070212-00 comment=NONE
Finished Control File and SPFILE Autobackup at 12-FEB-07
released channel: c1
2) Create a PFILE for the single instance database using the production RAC parameter file
a) don't forget to modify the following parameters depending on the directory structure of the new host: audit_file_dest, background_dump_dest, control_files, core_dump_dest, log_archive_dest_1, user_dump_dest etc
b) remove RAC specific parameters such as cluster_database_instances, cluster_database etc
c) for the parameter undo_tablespace, mention any one undo tablespace name

3) Move the backup pieces and the modified INIT.ORA file to the new host. Starting from 10g it is NO longer compulsory to copy the RMAN backup pieces to exactly the same locetion on the new host as the production locetion.

4) Use the pfile created above to STARTUP NOMOUNT the database on the new host

oracle@test-br ractest]$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Fri Feb 16 03:14:23 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 167772160 bytes
Fixed Size 1218292 bytes
Variable Size 62916876 bytes
Database Buffers 96468992 bytes
Redo Buffers 7168000 bytes

5) Now invoke RMAN and restore the controlfile specifying the locetion where the controlfile autobackup piece is restored on this new server. You can mount the database once the controlfile is restored successfully.

[oracle@test-br ractest]$ rman target / nocatalog

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Feb 16 03:16:31 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: racdb (not mounted)
using target database control file instead of recovery catalog

RMAN> restore controlfile from '/u01/oracle/oradata/ractest/c-610677177-20070212-00';

Starting restore at 16-FEB-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
output filename=/u01/oracle/oradata/ractest/control01.ctl
Finished restore at 16-FEB-07

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1
6) You can skip this step if you have restored the RMAN backup pieces to exactly the same locetion they were backed up on production. If this is not the case then you need to catalog the RMAN backup pieces to make RMAN aware of thier new locetion on the new host. Note that CATALOG BACKUPPIECE command is available only starting from 10g.

RMAN> catalog backuppiece '/u01/oracle/oradata/ractest/09i9sruq_1_1';

cataloged backuppiece
backup piece handle=/u01/oracle/oradata/ractest/09i9sruq_1_1 recid=10 stamp=614661579

RMAN> catalog backuppiece '/u01/oracle/oradata/ractest/0ai9ss14_1_1';

cataloged backuppiece
backup piece handle=/u01/oracle/oradata/ractest/0ai9ss14_1_1 recid=11 stamp=614661599
7) Now we'll determine the point upto which media recovery should run on the restored database.

RMAN> list backup of archivelog all;

List of Archived Logs in backup set 9
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 56 214541 01-FEB-07 226238 01-FEB-07
1 57 226238 01-FEB-07 226240 01-FEB-07
1 58 226240 01-FEB-07 233107 12-FEB-07
2 1 186185 28-JAN-07 225714 01-FEB-07
2 2 225714 01-FEB-07 226037 01-FEB-07
2 3 226037 01-FEB-07 233110 12-FEB-07
Check the last archive sequence for all redo threads and select the archive sequence having LEAST "Next SCN" among them. In our case sequence 58 of thread 1 has Next SCN of 233107 while sequence 3 of thread 2 has Next SCN of 233110. Since squence 58 of thread 1 has least Next SCN we will recover upto this point. (If you are keen to have recovery run until some specific time you can always give SET UNTIL TIME)

8) Having determined the point upto which media recovery should run, start the restore/recovery using:

RMAN> run {
2> set until sequence 59 thread 1;
3> set newname for datafile 1 to '/u01/oracle/oradata/ractest/data/system01.dbf';
4> set newname for datafile 2 to '/u01/oracle/oradata/ractest/data/undotbs01.dbf';
5> set newname for datafile 3 to '/u01/oracle/oradata/ractest/data/sysaux01.dbf';
6> set newname for datafile 4 to '/u01/oracle/oradata/ractest/data/users01.dbf';
7> set newname for datafile 5 to '/u01/oracle/oradata/ractest/data/undotbs02.dbf';
8> restore database;
9> switch datafile all;
10> recover database;
11> }
Since we determined previously that media recovery should run until sequence 58 hence we use SET UNTIL SEQUENCE 59 (+1) above. You also need to use SET NEWNAME clause to restore datafiles to a locetion on the new host which is different from the production path. Finally, SWITCH DATAFILE ALL clause updates these new datafile locetions in the controlfile

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

相關文章