ORACLE RAC資料庫的備份與恢復(5)
5、單例項備份集恢復到RAC
要將單例項資料庫恢復到RAC資料庫,要做的工作更多。目標庫的軟硬體準備工作就不提了,還有不明白的可以參考三思系列筆記:手把手教你用vmware安裝ORACLE10g RAC。
先描述下大致步驟如下:
- 源端建立備份集;
- 目標端安裝資料庫軟體和叢集件,並配置好共享儲存;
- 複製源端備份集到目標端;
- 目錄端任意節點執行正常恢復,恢復時注意要將spfile,controlfile,datafile,redofile等路徑改到共享儲存上,恢復完後這會兒仍然是個單例項資料庫;
- 修改初始化引數、增加UNDO表空間、增加REDOLOG執行緒組,重建金鑰檔案,目標端任意節點執行;
- 目標端各個節點配置監聽及網路服務名;
- 將新建的資料庫配置到crs,目標端任意節點執行即可。
這回目標庫選擇192.168.10.11(12),該組伺服器已安裝好CRS,並且還跑著一個名為jssdb的資料庫,實際上我們們現在操作的這臺單例項就是從那套RAC庫中恢復過來的,現在好,再恢復回去,哈哈。
5.1 資料庫更名
考慮到目標資料庫已經存在名為jssdb的資料庫,為了簡化在目標端的工作,這裡先在源端給資料庫改個名兒吧,改名推薦一個好工具,dbnewid,只需一行命令,即可輕鬆搞定,操作如下(注意nid執行時資料庫必須處於mount狀態):
[oracle@jssnode1 data1]$ nid target=/ dbname=repdb
DBNEWID: Release 10.2.0.4.0 - Production on Thu Mar 25 10:46:26 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to database JSSDB (DBID=953576437)
Connected to server version 10.2.0
Control Files in database:
/data1/jssdb/control01.ctl
/data1/jssdb/control02.ctl
/data1/jssdb/control03.ctl
Change database ID and database name JSSDB to REPDB? (Y/[N]) => y
Proceeding with operation
Changing database ID from 953576437 to 822106115
Changing database name from JSSDB to REPDB
Control File /data1/jssdb/control01.ctl - modified
Control File /data1/jssdb/control02.ctl - modified
Control File /data1/jssdb/control03.ctl - modified
Datafile /data1/jssdb/system01.dbf - dbid changed, wrote new name
Datafile /data1/jssdb/undoa01.dbf - dbid changed, wrote new name
Datafile /data1/jssdb/sysaux01.dbf - dbid changed, wrote new name
Datafile /data1/jssdb/users01.dbf - dbid changed, wrote new name
Datafile /data1/jssdb/jsstbs01.dbf - dbid changed, wrote new name
Datafile /data1/jssdb/temp01.dbf - dbid changed, wrote new name
Control File /data1/jssdb/control01.ctl - dbid changed, wrote new name
Control File /data1/jssdb/control02.ctl - dbid changed, wrote new name
Control File /data1/jssdb/control03.ctl - dbid changed, wrote new name
Instance shut down
Database name changed to REPDB.
Modify parameter file and generate a new password file before restarting.
Database ID for database REPDB changed to 822106115.
All previous backups and archived redo logs for this database are unusable.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.資料庫被自動關閉,重啟資料庫到nomount模式,修改初始化引數db_name
[oracle@jssnode1 data1]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Thu Mar 25 10:54:03 2010
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 2083368 bytes
Variable Size 125830616 bytes
Database Buffers 150994944 bytes
Redo Buffers 6303744 bytes
SQL> alter system set db_name=¨repdb¨ scope=spfile;
System altered.
SQL> alter system set instance_name=¨repdb¨ scope=spfile;
System altered.
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@jssnode1 data1]$ mv /data/ora10g/product/10.2.0/db_1/dbs/spfilejssdb.ora /data/ora10g/product/10.2.0/db_1/dbs/spfilerepdb.ora重啟資料庫到mount模式,並以open resetlogs方式開啟資料庫:
[oracle@jssnode1 data1]$ export ORACLE_SID=repdb
[oracle@jssnode1 data1]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Thu Mar 25 10:59:58 2010
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup mount
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 2083368 bytes
Variable Size 88081880 bytes
Database Buffers 188743680 bytes
Redo Buffers 6303744 bytes
Database mounted.
SQL> alter database open resetlogs;
Database altered.驗證一下吧:
SQL> select dbid, name from v$database;
DBID NAME
---------- ---------
822106115 REPDB
SQL> select global_name from global_name;
GLOBAL_NAME
--------------------------------------
REPDB搞定。
5.2 恢復成單例項資料庫
先要恢復出初始化引數檔案,操作步驟繁瑣一點點,其實很簡單,操作如下:
[oracle@jssdbn2 ~]$ export ORACLE_SID=repdb
[oracle@jssdbn2 ~]$ rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Thu Mar 25 11:25:03 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database (not started)
RMAN> set dbid=822106115
executing command: SET DBID
RMAN> startup nomount
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file ¨/data/ora10g/product/10.2.0/db_1/dbs/initrepdb.ora¨
starting Oracle instance without parameter file for retrival of spfile
Oracle instance started
Total System Global Area 159383552 bytes
Fixed Size 2082400 bytes
Variable Size 71305632 bytes
Database Buffers 79691776 bytes
Redo Buffers 6303744 bytes
RMAN> restore spfile to pfile ¨/data/ora10g/admin/repdb/pfile/initrepdb.ora¨ from ¨/data/backup/09l9esg4_1_1¨;
Starting restore at 25-MAR-10
using channel ORA_DISK_1
channel ORA_DISK_1: autobackup found: /data/backup/09l9esg4_1_1
channel ORA_DISK_1: PFILE restore from autobackup complete
Finished restore at 25-MAR-10開啟 initrepdb.ora 檔案,對一些檔案路徑相關的引數進行修改,本例中需要修改的引數有:audit_file_dest,background_dump_dest,control_files,core_dump_dest,log_archive_dest_1,user_dump_dest等。按例項情況進行修改並儲存,而後再通過該pfile建立spfile,注意喲,建立的spfile可是要放到共享儲存上去的:
SQL> create spfile=¨+ASMDISK2/repdb/spfile/spfilerepdb.ora¨ from pfile=¨/data/ora10g/admin/repdb/pfile/initrepdb.ora¨;
File created.- 提示:上述修改尤其要注意control_files指定的路徑,務必放在共享儲存上,這裡是修改到ASM中。另外如果情況允許,log_archive_dest_n相關路徑也建議放在共享儲存上。
修改客戶端初始化引數檔案,內容指向到asm共享盤中的SPFILE,命令如下:
- [oracle@jssdbn2 oradata]$ echo "SPFILE=¨+ASMDISK2/repdb/spfile/spfilerepdb.ora¨" > /data/ora10g/product/10.2.0/db_1/dbs/initrepdb.ora
重新啟動資料庫到nomount狀態:
SQL> startup nomount
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 2083368 bytes
Variable Size 88081880 bytes
Database Buffers 188743680 bytes
Redo Buffers 6303744 bytes
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +ASMDISK2/repdb/spfile/spfiler
epdb.oraRMAN 執行對控制檔案的恢復:
RMAN> connect target /
connected to target database: (not mounted)
using target database control file instead of recovery catalog
RMAN> set dbid = 822106115
executing command: SET DBID
RMAN> restore controlfile from ¨/data/backup/09l9esg4_1_1¨;
Starting restore at 25-MAR-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=152 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
output filename=+ASMDISK2/repdb/control01.ctl
output filename=+ASMDISK2/repdb/control02.ctl
output filename=+ASMDISK2/repdb/control03.ctl
Finished restore at 25-MAR-10然後就可以將資料庫啟動到MOUNT狀態了:
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1將複製過來的資料檔案備份集註冊到備份資料庫中,操作如下:
RMAN> catalog backuppiece ¨/data/backup/08l9esfa_1_1¨;
cataloged backuppiece
backup piece handle=/data/backup/08l9esfa_1_1 recid=6 stamp=714575911
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size
------- ---- -- ----------
5 Full 710.99M
List of Datafiles in backup set 5
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 16365338 25-MAR-10 /data1/jssdb/system01.dbf
2 Full 16365338 25-MAR-10 /data1/jssdb/undoa01.dbf
3 Full 16365338 25-MAR-10 /data1/jssdb/sysaux01.dbf
5 Full 16365338 25-MAR-10 /data1/jssdb/users01.dbf
6 Full 16365338 25-MAR-10 /data1/jssdb/jsstbs01.dbf
Backup Set Copy #1 of backup set 5
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:00:22 25-MAR-10 NO TAG20100325T110930
List of Backup Pieces for backup set 5 Copy #1
BP Key Pc# Status Piece Name
------- --- ----------- ----------
5 1 AVAILABLE /data1/backup/08l9esfa_1_1
Backup Set Copy #2 of backup set 5
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:00:22 25-MAR-10 NO TAG20100325T110930
List of Backup Pieces for backup set 5 Copy #2
BP Key Pc# Status Piece Name
------- --- ----------- ----------
6 1 AVAILABLE /data/backup/08l9esfa_1_1接下來要恢復資料檔案,直接執行RESTORE命令顯然是不行的,因為原檔案路徑並沒被放在共享儲存,因此我們還需要在恢復前,對相關檔案的路徑進行重定義,操作如下:
RMAN> RUN {
2> SET NEWNAME FOR DATAFILE 1 to ¨+ASMDISK2/repdb/datafile/system01.dbf¨;
3> SET NEWNAME FOR DATAFILE 2 to ¨+ASMDISK2/repdb/datafile/undoa01.dbf¨;
4> SET NEWNAME FOR DATAFILE 3 to ¨+ASMDISK2/repdb/datafile/sysaux01.dbf¨;
5> SET NEWNAME FOR DATAFILE 5 to ¨+ASMDISK2/repdb/datafile/users01.dbf¨;
6> SET NEWNAME FOR DATAFILE 6 to ¨+ASMDISK2/repdb/datafile/jsstbs01.dbf¨;
7> SET NEWNAME FOR TEMPFILE 1 to ¨+ASMDISK2/repdb/datafile/temp01.dbf¨;
8> RESTORE DATABASE;
9> SWITCH DATAFILE ALL;
10> SWITCH TEMPFILE ALL;
11> }
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 25-MAR-10
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 +ASMDISK2/repdb/datafile/system01.dbf
restoring datafile 00002 to +ASMDISK2/repdb/datafile/undoa01.dbf
restoring datafile 00003 to +ASMDISK2/repdb/datafile/sysaux01.dbf
restoring datafile 00005 to +ASMDISK2/repdb/datafile/users01.dbf
restoring datafile 00006 to +ASMDISK2/repdb/datafile/jsstbs01.dbf
channel ORA_DISK_1: reading from backup piece /data1/backup/08l9esfa_1_1
channel ORA_DISK_1: restored backup piece 1
failover to piece handle=/data/backup/08l9esfa_1_1 tag=TAG20100325T110930
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
Finished restore at 25-MAR-10
datafile 1 switched to datafile copy
input datafile copy recid=6 stamp=714576020 filename=+ASMDISK2/repdb/datafile/system01.dbf
datafile 2 switched to datafile copy
input datafile copy recid=7 stamp=714576021 filename=+ASMDISK2/repdb/datafile/undoa01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=8 stamp=714576021 filename=+ASMDISK2/repdb/datafile/sysaux01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=9 stamp=714576021 filename=+ASMDISK2/repdb/datafile/users01.dbf
datafile 6 switched to datafile copy
input datafile copy recid=10 stamp=714576021 filename=+ASMDISK2/repdb/datafile/jsstbs01.dbf
renamed temporary file 1 to +ASMDISK2/repdb/datafile/temp01.dbf in control file恢復工作基本竣工。你是否想說還沒recover呢,這裡呢並不需要,因為之前建立備份集時資料庫處理mount狀態,也就是一致性狀態,因此並不需要進行recover,下面再對redo檔案的路徑進行重定義,將其也移至共享儲存,操作如下:
SQL> select * from v$Logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- ------------------------------ ---
2 ONLINE /data1/jssdb/redo02.dbf NO
1 ONLINE /data1/jssdb/redo01.dbf NO
SQL> alter database rename file ¨/data1/jssdb/redo01.dbf¨ to ¨+ASMDISK2/repdb/redofile/redoa01.dbf¨;
Database altered.
SQL> alter database rename file ¨/data1/jssdb/redo02.dbf¨ to ¨+ASMDISK2/repdb/redofile/redob01.dbf¨;
Database altered.然後直接open resetlogs即可:
RMAN> alter database open resetlogs;
database opened來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7607759/viewspace-660195/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ORACLE RAC資料庫的備份與恢復(6)Oracle資料庫
- ORACLE RAC資料庫的備份與恢復(4)Oracle資料庫
- ORACLE RAC資料庫的備份與恢復(3)Oracle資料庫
- ORACLE RAC資料庫的備份與恢復(2)Oracle資料庫
- ORACLE RAC資料庫的備份與恢復(1)Oracle資料庫
- oracle資料庫的備份與恢復Oracle資料庫
- Oracle RAC備份與恢復Oracle
- Oracle資料庫的備份與恢復(轉)Oracle資料庫
- Oracle 資料庫的備份與恢復(轉)Oracle資料庫
- 備份與恢復:polardb資料庫備份與恢復資料庫
- Oracle資料庫備份與恢復之三:OS備份/使用者管理的備份與恢復Oracle資料庫
- 資料庫的備份與恢復資料庫
- Oracle資料庫備份與恢復之RMANOracle資料庫
- 【備份恢復】Oracle 資料備份與恢復微實踐Oracle
- RMAN備份恢復——RAC環境資料庫的備份(zt)資料庫
- RMAN備份恢復--RAC環境資料庫的備份(十)資料庫
- RMAN備份恢復——RAC環境資料庫的備份(一)資料庫
- 【備份恢復】從備份恢復資料庫資料庫
- Oracle資料庫的備份與恢復方式比較Oracle資料庫
- Oracle資料庫備份與恢復的三種方法Oracle資料庫
- mysql的資料庫備份與恢復MySql資料庫
- RAC環境利用備份恢復RAC資料庫(五)資料庫
- RAC環境利用備份恢復RAC資料庫(四)資料庫
- RAC環境利用備份恢復RAC資料庫(三)資料庫
- RAC環境利用備份恢復RAC資料庫(二)資料庫
- RAC環境利用備份恢復RAC資料庫(一)資料庫
- Oracle資料泵的備份與恢復Oracle
- postgresql備份與恢復資料庫SQL資料庫
- mongo資料庫備份與恢復Go資料庫
- Informix資料庫備份與恢復ORM資料庫
- oracle rac 在asm下的備份與恢復OracleASM
- 完全攻略Oracle資料庫的備份與恢復Oracle資料庫
- Oracle資料庫備份與恢復的三種方法(轉)Oracle資料庫
- 第5章:從開啟的資料庫備份與恢復之從開啟的資料庫備份中完全恢復資料庫
- 成功恢復無備份RAC環境資料庫資料庫
- Oracle資料庫備份與恢復之RMAN2Oracle資料庫
- oracle資料庫備份與恢復 a piece of cake (4)(轉)Oracle資料庫
- 關閉資料庫的備份與恢復資料庫