Netbackup+oracle db 異機恢復案例
本文主要就使用netbackup伺服器上的rman的備份集,在異機進行資料庫恢復進行詳細的操作說明.
- 環境描述
1.1 源資料庫資訊
Hostname: sstydb
Oracle_sid:sstydb
Oracle_version:10.2.0.4.0
DBID: 3469129877
Os:Linux 2.6.18-128.el5 #1 SMP Wed Dec 17 11:41:38 EST 2008 x86_64 x86_64 x86_64 GNU/Linux
安裝了netbackup client 和netbackup for oracle db,並在netbackup伺服器上定義了策略(並啟用)和client
資料庫在netbackup伺服器進行了全庫和歸檔日誌的備份
rman備份集沒有使用catalog資料庫進行記錄(nocatalog方式)
netbackup伺服器上設定允許異機恢復.
1.2 目標庫資訊
Hostname:ttjkdb
Oracle_sid:sstydb
Oracle_version:10.2.0.4.0
Os:Linux 2.6.18-128.el5 #1 SMP Wed Dec 17 11:41:38 EST 2008 x86_64 x86_64 x86_64 GNU/Linux
安裝了oracle資料庫環境,沒有建立資料庫例項
安裝了netbackup client 和netbackup for oracle db,並在netbackup伺服器上定義了策略(並啟用)和client
透過了sbttest,可以訪問netbackup的帶庫,rman可以訪問netbackup伺服器的介質
- 主要工作目標
在目標伺服器(ttjkdb)上,使用rman工具和netbackup伺服器上源庫的rman備份集,進行資料庫的不完整恢復(無法獲得線上執行源庫的redo檔案),即在目標伺服器上測試源庫的災難性恢復.
- 異機恢復的主要操作步驟
3.1目標機上進行資料庫例項環境的準備工作
3.1.1編輯/home/oracle/.bash_profile檔案設定ORACLE_SID引數
$more /home/oracle/.bash_profile
…...
ORACLE_SID=sstydb:export ORACLE_SID
…...
3.1.2 編輯$ORACLE_HOME/dbs/init
$more $ORACLE_HOME/dbs/initsstydb.ora
*.compatible='10.2.0.3.0'
*.control_files='/oradata/sstydb/control01.ctl','/oradata/sstydb/control02.ctl','/oradata/sstydb/control03.ctl'
*.core_dump_dest='/oracle/admin/sstydb/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='sstydb'
*.db_recovery_file_dest='/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/oradata/archivelog/'
*.open_cursors=300
*.pga_aggregate_target=384827392
*.processes=500
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=555
*.sga_target=1154482176
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/oracle/admin/sstydb/udump'
注意:
Db_name 一定要設定為源庫的資料庫名稱,dump的幾個目錄可以修改,歸檔日誌目錄和sga的設定可以修改
3.1.3 準備資料庫資料目錄和dump檔案目錄
本例中,目標資料庫與源資料庫的資料檔案的目錄和檔名稱完全相同
ttjkdb$mkdir /oradata/sstydb
ttjkdb$cd /oracle/admin
ttjkdb$mkdir sstydb
ttjkdb$cd sstydb
ttjkdb$mkdir adump bdump cdump udump
3.1.4 啟動資料庫例項到nomount狀態
Ttjkdb$export ORACLE_SID=sstydb
ttjkdb$sqlplus / as sysdba
SQL>startup nomount;
ORACLE instance started.
Total System Global Area 1157627904 bytes
Fixed Size 2083432 bytes
Variable Size 301991320 bytes
Database Buffers 838860800 bytes
Redo Buffers 14692352 bytes
SQL> exit
資料庫例項啟動到nomount狀態,為後面的控制檔案的恢復做好了準備
3.2 目標庫伺服器上恢復控制檔案,啟動資料庫到mount狀態
3.2.1 控制檔案恢復的場景與約束
Oracle 官方文件中,關於restore controlfile的應用場景的描述,起到很好的指引作用,少走了很多彎路,如下:
RESTORE CONTROLFILE; | RESTORE CONTROLFILE FROM AUTOBACKUP; | RESTORE CONTROLFILE …TO 'filename'; | RESTORE CONTROLFILE… FROM 'media_handle' or TAG 'user_tag'; | |
No catalog target started in NOMOUNT state | Error.Must specify FROM AUTOBACKUP. | First run SET DBID.Restores to CONTROL_FILES locations. | First run SET DBID. Must specify FROM AUTOBACKUP.Restores only to filename. | First run SET DBID.Restores from specified file(cannot restore from TAG).If TO 'filename' not used,restores to all CONTROL_FILES location. |
NO catalog target mounted or open | Error.Must use TO 'filename',where filename is not in CONTROL_FILE list. | Error.Must use TO 'filename',where fileame is not in CONTROL_FILES list. | Restores only to filename,where filename is not in CONTROL_FILES list. | Restores form. specified file.If TO 'filename' not used,restores to all CONTROL_FILES locations. |
Catalog,target started in NOMOUNT state | Restores to CONTROL_FILES locations,RUN SET DBID only if DB_NAME not unique in catalog. | Only use with catalog for testing purposes. | Restores only to filename,where filename is not in CONTROL_FILES list. | Restores form. specified file.If TO 'filename' not used,restores to all CONTROL_FILES locations. |
Catalog,target mounted or open | Error.Must use TO 'filename',where filename is not in CONTROL_FILE list. | Do not use with catalog. | Restores only to filename,where filename is not in CONTROL_FILES list. | Restores form. specified file.If TO 'filename' not used,restores to all CONTROL_FILES locations. |
本例我們屬於第一種情況:No catalog,target started in NOMOUNT state,所以只有3個途徑進行恢復(見上表的第2行的第3,4,5列)因為目標庫與源庫的資料檔案的目錄完全相同,controlfile也就恢復到init
第2行第5列,因為不可以使用tag,所以可以縮寫為:RESTORE CONTROLFILE FROM 'media_handle';
這樣本例就可以使用兩個方式進行controlfile恢復工作
A. RESTORE CONTROLFILE FROM AUTOBACKUP;
B. RESTORE CONTROLFILE FROM 'media_handle'
3.2.2 controlfile的恢復
先檢查一下源庫的controlfile的備份情況
sstydb$rman target /
Rman>list backup of controlfile;
…...
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1109 Full 7.00M SBT_TAPE 00:00:57 15-OCT-10
BP Key: 1109 Status: AVAILABLE Compressed: NO Tag: TAG20101015T123430
Handle: cntrl_1118_1_732458070 Media: G:
Control File Included: Ckp SCN: 13520941 Ckp time: 15-OCT-10
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1110 Full 7.00M SBT_TAPE 00:01:09 15-OCT-10
BP Key: 1110 Status: AVAILABLE Compressed: NO Tag: TAG20101015T123535
Handle: c-3469129477-20101015-02 Media: G:
Control File Included: Ckp SCN: 13520988 Ckp time: 15-OCT-10
查詢源庫的DBID
Sstydb$sqlplus / as sysdba
SQL>select dbid from v$database;
DBID
--------
3469129877
A.使用FROM AUTOBACKUP 方式進行controlfile恢復
Ttjkdb$rman target /
Rman>set DBID=3469129877
Rman>run{
allocate channel d1 type 'sbt_tape' parms="ENV=(NB_ORA_CLIENT=sstydb)";
send 'NB_ORA_SERV=netbackup';
restore controlfile from 'c-3469129477-20101015-02';
Release channel d1;}
released channel: ORA_DISK_1
allocated channel: d1
channel d1: sid=541 devtype=SBT_TAPE
channel d1: Veritas NetBackup for Oracle - Release 6.5 (2007072323)
sent command to channel: d1
Starting restore at 15-OCT-10
channel d1: restoring control file
channel d1: restore complete, elapsed time: 00:00:48
output filename=/oradata/sstydb/control01.ctl
output filename=/oradata/sstydb/control02.ctl
output filename=/oradata/sstydb/control03.ctl
Finished restore at 15-OCT-10
released channel: d1
使用from autobackup 方式進行恢復有一個前提,就是源庫的rman環境裡設定了控制檔案的自動備份
Sstydb$rman target /
Rman>show all;
RMAN configuration parameters are:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE 'TAPE' TO '%F';
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/oracle/product/10.2.0/db_1/dbs/snapcf_gcwz_web.f'; # default
…...
如果源庫沒有設定autobackup,可以透過的命令進行設定
Rman>CONFIGURE CONTROLFILE AUTOBACKUP ON;
RMAN>CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE 'TAPE' TO '%F';
B. 使用FROM 'media_handle' 方式進行controlfile恢復
Ttjkdb$rman target /
Rman>set DBID=3469129877
Rman>run{
allocate channel d1 type 'sbt_tape' parms="ENV=(NB_ORA_CLIENT=sstydb)";
send 'NB_ORA_SERV=netbackup';
restore controlfile from autobackup;
Release channel d1;}
經實際測試使用A方式進行controlfile的恢復,耗時比B方式多;A方式可能需要掃描帶庫,所以速度慢很多,B方式直接去訪問帶庫中的指定內容,時間要快一點,從速度上上比較,建議選擇B方式進行controlfile的恢復。
3.2.3 啟動目標資料庫例項到mount狀態
Ttjkdb$sqlplus / as sysdba
SQL>alter database mount;
將資料庫啟動到mount狀態後,就可以進行資料庫的restore和recovery了。
3.3 目標資料庫例項恢復,以resetlogs方式開啟資料庫例項
3.3.1 目標資料庫例項恢復
Ttjkdb$rman target /
Rman>set DBID=3469129877
Rman>run{
allocate channel d1 type 'sbt_tape' parms="ENV=(NB_ORA_CLIENT=tydb)";
send 'NB_ORA_SERV=netbackup';
Restore database;
Recover database;
Release channel d1;}
allocated channel: d1
channel d1: sid=541 devtype=SBT_TAPE
…...
channel d1: Veritas NetBackup for Oracle - Release 6.5 (2007072323)
sent command to channel: d1
channel d1: starting datafile backupset restore
channel d1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oradata/gcwz_web/system01.dbf
restoring datafile 00002 to /oradata/gcwz_web/undotbs01.dbf
…...
channel d1: reading from backup piece bk_1094_1_732284984
channel d1: restored backup piece 1
piece handle=bk_1094_1_732284984 tag=HOT_DB_BK_LEVEL0
channel d1: restore complete, elapsed time: 00:01:26
Finished restore at 15-OCT-10
Starting recover at 15-OCT-10
starting media recovery
channel d1: starting archive log restore to default destination
……
piece handle=2clqc5eg_1_1 tag=TAG20101013T180048
channel d1: restore complete, elapsed time: 00:00:56
archive log filename=/oradata/archivelog/1_665_690800133.dbf thread=1 sequence=665
archive log filename=/oradata/archivelog/1_666_690800133.dbf thread=1 sequence=666
unable to find archive log
archive log thread=1 sequence=1
released channel: d1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 10/15/2010 17:45:30
RMAN-06054: media recovery requesting unknown log: thread 1 seq 1 lowscn 13414913
這裡有rman的報錯,這個錯誤因為rman在向下應用日誌的時候,找不到下一個日誌序列=到達尾部(永遠會存在),我們可以忽略這個錯誤。
3.3.2 以resetlogs方式開啟資料庫例項
Ttjkdb$sqlplus / as sysdba
SQL> alter database open resetlogs;
Database altered.
SQL> select open_mode,name from v$database;
OPEN_MODE NAME
---------- ---------
READ WRITE SSTYDB
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/32980/viewspace-676035/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- windows下異機恢復---改變db_nameWindows
- oracle 異機恢復Oracle
- oracle10gR2之RMAN異機恢復案例Oracle
- rman恢復方案和oracle異機恢復Oracle
- windows主機兩個獨立的db做rman異機恢復--不改變db_nameWindows
- Oracle RMAN異機恢復Oracle
- oracle冷備份、恢復和異機恢復Oracle
- ORACLE RMAN異機異目錄恢復Oracle
- oracle的RMAN異機恢復Oracle
- RMAN異機恢復總結
- Oracle備份恢復之熱備份恢復及異機恢復Oracle
- 兩篇oracle異機恢復文章Oracle
- DB2恢復DB2
- oracle11gR2_64之rman異機恢復(FS->FS)完整案例Oracle
- rman之同平臺異機恢復
- Oracle 12c RMAN 異機恢復Oracle
- Oracle 11g RMAN 異機恢復Oracle
- 同平臺異機備份恢復
- 使用DP實現RAC異機恢復
- 資料庫異機冷備恢復資料庫
- 【虛擬機器資料恢復】異常斷電導致虛擬機器無法啟動的資料恢復案例虛擬機資料恢復
- solaris下透過rman工具將備份到帶庫上的db異機恢復
- solaris下通過rman工具將備份到帶庫上的db異機恢復
- 【虛擬機器資料恢復】VMware ESX SERVER資料恢復案例虛擬機資料恢復Server
- 【12c 庫異機恢復】實驗
- RMAN異機恢復:RAC到單例項單例
- 異機恢復RMAN-05517解決方法
- RMAN備份異機恢復流程總結
- 【伺服器資料恢復】ESXi虛擬機器資料恢復案例伺服器資料恢復虛擬機
- RMAN異機恢復異作業系統(Linux到Windows)作業系統LinuxWindows
- oracle 11G r2 異機恢復Oracle
- 生產系統恢復到異機測試
- 【虛擬機器資料恢復】FreeNAS+ESXi資料恢復案例虛擬機資料恢復
- 【伺服器資料恢復】VMware虛擬機器磁碟檔案恢復案例伺服器資料恢復虛擬機
- 【伺服器資料恢復】VMware esxi虛擬機器資料恢復案例伺服器資料恢復虛擬機
- [DB2]DB2備份和恢復DB2
- [DB2]db2重定向恢復DB2
- Oracle手工完全恢復案例Oracle