DATA GUARD主庫丟失資料檔案的恢復(1)
在DATAGUARD中,主庫丟失檔案時,有多種恢復方式可選:
1、從備庫複製相關檔案到主庫上恢復
2、複製備庫備份到主庫還原恢復
3、從主庫備份還原恢復
本文主要討論10G DATAGUARD中,主庫丟失資料檔案時,用複製備庫對應的資料檔案方式恢復主庫。
這種方法要分兩種情況討論:
一、備庫檔案SCN號比主庫控制檔案新
這種情況下需要重建控制檔案來解決。
導致這種情況一般是主庫出現故障時,備庫正處於恢復狀態。
1、模擬主庫丟失檔案
SQL> shutdown immediate
ORA-01116: error in opening database file 1
ORA-01110: data file 1: '/u01/oracle/oradata/primary/system01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1260696 bytes
Variable Size 109052776 bytes
Database Buffers 54525952 bytes
Redo Buffers 2932736 bytes
Database mounted.
2、從備庫複製相關檔案到主庫
首先關閉備庫
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
複製檔案
[oracle@standby primary]$ scp system01.dbf 10.2.98.10:`pwd`
oracle@10.2.98.10's password:
system01.dbf 100% 300MB 2.7MB/s 01:51
3、嘗試recover丟失的檔案
SQL> recover datafile 1;
ORA-00283: recovery session canceled due to errors
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/u01/oracle/oradata/primary/system01.dbf'
ORA-01207: file is more recent than control file - old control file
失敗。這時,因為沒有備份,只能透過重建主庫控制檔案的方式解決。
4、在主庫生成檔案格式的控制檔案
SQL> alter database backup controlfile to trace;
Database altered.
5、重建控制檔案
注意:必須要選擇NORESETLOGS的方式,否則備庫可能會需要重建。
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> CREATE CONTROLFILE REUSE DATABASE "PRIMARY" NORESETLOGS FORCE LOGGING ARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 '/u01/oracle/oradata/primary/redo01.log' SIZE 50M,
9 GROUP 2 '/u01/oracle/oradata/primary/redo02.log' SIZE 50M,
10 GROUP 3 '/u01/oracle/oradata/primary/redo03.log' SIZE 50M
11 --STANDBY LOGFILE
12 --GROUP 4 '/u01/oracle/oradata/primary/standbyredo04.log' SIZE 50M,
13 --GROUP 5 '/u01/oracle/oradata/primary/standbyredo5.log' SIZE 50M,
14 --GROUP 6 '/u01/oracle/oradata/primary/standbyredo6.log' SIZE 50M,
15 --GROUP 7 '/u01/oracle/oradata/primary/standbyredo7.log' SIZE 50M
16 DATAFILE
17 '/u01/oracle/oradata/primary/system01.dbf',
18 '/u01/oracle/oradata/primary/undotbs01.dbf',
19 '/u01/oracle/oradata/primary/sysaux01.dbf',
20 '/u01/oracle/oradata/primary/users01.dbf'
21 CHARACTER SET ZHS16GBK
22 ;
Control file created.
6、恢復資料庫
SQL> recover database;
ORA-00279: change 163941 generated at 06/27/2007 23:26:11 needed for thread 1
ORA-00289: suggestion : /u01/archivelog/1_41_626106231.arc
ORA-00280: change 163941 for thread 1 is in sequence #41
Specify log: {
auto
ORA-00279: change 164058 generated at 06/27/2007 23:27:13 needed for thread 1
ORA-00289: suggestion : /u01/archivelog/1_42_626106231.arc
ORA-00280: change 164058 for thread 1 is in sequence #42
ORA-00278: log file '/u01/archivelog/1_41_626106231.arc' no longer needed for
this recovery
......
......
ORA-00279: change 166472 generated at 06/30/2007 00:18:54 needed for thread 1
ORA-00289: suggestion : /u01/archivelog/1_48_626106231.arc
ORA-00280: change 166472 for thread 1 is in sequence #48
ORA-00278: log file '/u01/archivelog/1_47_626106231.arc' no longer needed for
this recovery
Log applied.
Media recovery complete.
SQL> ALTER SYSTEM ARCHIVE LOG ALL;
System altered.
7、開啟主庫
SQL> alter database open;
Database altered.
8、為主庫新增臨時檔案
SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/oracle/oradata/primary/temp01.dbf' REUSE;
Tablespace altered.
至此,主庫恢復完成。
二、備庫檔案SCN號比主庫控制檔案舊
一般情況下,如果主庫故障時,備庫正處於只讀狀態,那麼,備庫的資料檔案SCN一般會比主庫小。
這種情況比較簡單,把丟失的資料檔案從備庫複製到主庫後執行recover就可以了。
1、刪除主庫資料檔案,模擬故障
SQL> startup
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1260696 bytes
Variable Size 121635688 bytes
Database Buffers 41943040 bytes
Redo Buffers 2932736 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/oracle/oradata/primary/system01.dbf'
2、從備庫複製相關檔案到主庫
首先關閉備庫
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
複製檔案
[oracle@standby primary]$ scp system01.dbf 10.2.98.10:`pwd`
oracle@10.2.98.10's password:
system01.dbf 100% 300MB 2.7MB/s 01:51
3、返回主庫,執行recover
SQL> recover datafile 1;
Media recovery complete.
4、開啟主庫
SQL> alter database open;
Database altered.
恢復完成。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/231499/viewspace-63830/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- DATA GUARD主庫丟失資料檔案的恢復(3)
- DATA GUARD主庫丟失資料檔案的恢復(2)
- Sql Server資料庫檔案丟失的恢復方法SQLServer資料庫
- 【資料庫資料恢復】Sql Server資料庫檔案丟失的資料恢復過程資料庫資料恢復SQLServer
- 電腦檔案丟失資料恢復資料恢復
- 【資料庫資料恢復】mdb_catalog.wt檔案丟失的MongoDB資料恢復案例資料庫資料恢復MongoDB
- 資料庫資料恢復—MongoDB資料庫檔案丟失,啟動報錯的資料恢復案例資料庫資料恢復MongoDB
- MongoDB資料庫報錯,資料庫檔案丟失資料恢復案例MongoDB資料庫資料恢復
- 【北亞資料恢復】MongoDB資料遷移檔案丟失的MongoDB資料恢復案例資料恢復MongoDB
- 【伺服器資料恢復】xfs檔案系統資料丟失的資料恢復案例伺服器資料恢復
- macOS Big Sur系統如何恢復丟失的資料檔案?Mac
- 剪下的檔案還能恢復嗎,恢復剪貼丟失的檔案
- Sqlserver系統資料庫和使用者資料庫日誌檔案全部丟失的恢復SQLServer資料庫
- 寶塔資料庫恢復 mysql資料庫丟失恢復 mysql資料庫刪除庫恢復 寶塔mysql資料庫恢復資料庫MySql
- 【資料庫資料恢復】LINUX EXT3檔案系統下ORACLE資料庫誤操作導致資料丟失的資料恢復案例資料庫資料恢復LinuxOracle
- 【資料庫資料恢復】斷電導致Oracle資料庫資料丟失的資料恢復案例資料庫資料恢復Oracle
- 丟失的隨身碟檔案如何恢復?
- 【虛擬機器資料恢復】Hyper-V虛擬化檔案丟失的資料恢復案例虛擬機資料恢復
- 硬碟資料丟失如何恢復?硬碟
- 分割槽丟失資料恢復資料恢復
- 伺服器(RAID1)資料丟失恢復伺服器AI
- 檔案丟失不用怕:超實用的Mac資料恢復軟體!Mac資料恢復
- chkdsk 後資料丟失的恢復方法
- 伺服器資料丟失了怎麼恢復/分割槽丟失恢復教程伺服器
- 【資料庫資料恢復】透過恢復NDF檔案修復資料庫的資料恢復過程資料庫資料恢復
- 【伺服器資料恢復】SAN LUN對映出錯導致檔案系統資料丟失的資料恢復案例伺服器資料恢復
- 伺服器儲存金蝶資料庫丟失恢復伺服器資料庫
- 伺服器資料恢復-誤操作導致mysql資料庫資料丟失的資料恢復案例伺服器資料恢復MySql資料庫
- 【資料庫資料恢復】MongoDB資料庫檔案損壞的資料恢復案例資料庫資料恢復MongoDB
- 伺服器資料恢復—重灌系統導致XFS檔案系統分割槽丟失的資料恢復案例伺服器資料恢復
- 【Vsan資料恢復】斷電導致Vsan分散式儲存虛擬磁碟檔案丟失的資料恢復案例資料恢復分散式
- 【伺服器資料恢復】虛擬機器檔案丟失導致Hyper-V癱瘓的資料恢復伺服器資料恢復虛擬機
- 【北亞資料恢復】vmfs還原快照操作導致SqlServer資料庫資料丟失的資料恢復資料恢復SQLServer資料庫
- 【raid資料恢復案例】raid擴容導致的資料丟失的資料恢復AI資料恢復
- 伺服器RAID資料丟失恢復伺服器AI
- OMV資料恢復NAS陣列丟失資料恢復陣列
- 如何恢復伺服器資料丟失伺服器
- 【伺服器資料恢復】XFS檔案系統分割槽分割槽丟失無法訪問的資料恢復案例伺服器資料恢復