sqlplus 下恢復active 日誌丟失的情況
在sqlplus 命令列下,恢復active redo 丟失的情況,檢查如果資料檔案在
1、啟動資料庫
SQL> startup
ORACLE instance started.
1、啟動資料庫
SQL> startup
ORACLE instance started.
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
Database mounted.
Database opened.
SQL>
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
Database mounted.
Database opened.
SQL>
2、檢查redo日誌情況
SQL> select group#,sequence#,status from v$log;
SQL> select group#,sequence#,status from v$log;
GROUP# SEQUENCE# STATUS
---------- ---------- ----------------
1 4 CURRENT
2 2 INACTIVE
3 3 INACTIVE
SQL>
---------- ---------- ----------------
1 4 CURRENT
2 2 INACTIVE
3 3 INACTIVE
SQL>
3、做操作
SQL> connect haozg/haozg
Connected.
SQL>
SQL>
SQL> select * from test22;
SQL> connect haozg/haozg
Connected.
SQL>
SQL>
SQL> select * from test22;
AAB001 AAB003
--------------- --------------------
soft 0001
soft 0001
soft 0001
--------------- --------------------
soft 0001
soft 0001
soft 0001
SQL>
SQL> insert into test22 values('xxx','002');
SQL> insert into test22 values('xxx','002');
1 row created.
SQL> /
1 row created.
SQL> /
1 row created.
SQL> commit
2 ;
2 ;
Commit complete.
SQL> select * from test22;
AAB001 AAB003
--------------- --------------------
soft 0001
soft 0001
soft 0001
xxx 002
xxx 002
xxx 002
--------------- --------------------
soft 0001
soft 0001
soft 0001
xxx 002
xxx 002
xxx 002
6 rows selected.
SQL> select group#,sequence#,status from v$log;
GROUP# SEQUENCE# STATUS
---------- ---------- ----------------
1 4 CURRENT
2 2 INACTIVE
3 3 INACTIVE
---------- ---------- ----------------
1 4 CURRENT
2 2 INACTIVE
3 3 INACTIVE
SQL> alter system switch logfile;
System altered.
SQL> select group#,sequence#,status from v$log;
GROUP# SEQUENCE# STATUS
---------- ---------- ----------------
1 4 ACTIVE
2 5 CURRENT
3 3 INACTIVE
---------- ---------- ----------------
1 4 ACTIVE
2 5 CURRENT
3 3 INACTIVE
注意sequence# 為4 的日誌為ACTIVE狀態,group# 為1.
SQL> connect / as sysdba
Connected.
SQL> connect / as sysdba
Connected.
4、不一致停庫
SQL> shutdown abort;
ORACLE instance shut down.
SQL>
SQL> shutdown abort;
ORACLE instance shut down.
SQL>
SQL> SQL>
5、啟動到mount
SQL> startup mount;
ORACLE instance started.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
Database mounted.
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
Database mounted.
6、刪除active 日誌檔案,由於是在歸檔模式,所以active 日誌 已經完成了歸檔。
[oracle@haozg onlinelog]$ rm -f o1_mf_1_7z24osgo_.log
[oracle@haozg onlinelog]$ rm -f o1_mf_1_7z24osgo_.log
SQL> select checkpoint_change# from v$datafile;
CHECKPOINT_CHANGE#
------------------
1118809
1118809
1118809
1118809
1118809
------------------
1118809
1118809
1118809
1118809
1118809
7、檢查 scn 的情況
SQL> select checkpoint_change# from v$datafile_header;
SQL> select checkpoint_change# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
1118809
1118809
1118809
1118809
1118809
------------------
1118809
1118809
1118809
1118809
1118809
SQL> select first_change#,next_change#,group#,sequence#,status from v$log;
FIRST_CHANGE# NEXT_CHANGE# GROUP# SEQUENCE# STATUS
------------- ------------ ---------- ---------- ----------------
1118808 1119116 1 4 ACTIVE
1098796 1118808 3 3 INACTIVE
1119116 2.8147E+14 2 5 CURRENT
------------- ------------ ---------- ---------- ----------------
1118808 1119116 1 4 ACTIVE
1098796 1118808 3 3 INACTIVE
1119116 2.8147E+14 2 5 CURRENT
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1:
'/oracle/flash_recovery_area/ORA11/onlinelog/o1_mf_1_7z24osgo_.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
alter database open
*
ERROR at line 1:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1:
'/oracle/flash_recovery_area/ORA11/onlinelog/o1_mf_1_7z24osgo_.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
SQL> alter database add logfile group 1;
alter database add logfile group 1
*
ERROR at line 1:
ORA-01184: logfile group 1 already exists
SQL> alter database clear logfile group 1;
alter database clear logfile group 1
*
ERROR at line 1:
ORA-01624: log 1 needed for crash recovery of instance ora11 (thread 1)
ORA-00312: online log 1 thread 1:
'/oracle/flash_recovery_area/ORA11/onlinelog/o1_mf_1_7z24osgo_.log'
SQL> select first_change#,next_change#,group#,sequence#,status from v$log;
FIRST_CHANGE# NEXT_CHANGE# GROUP# SEQUENCE# STATUS
------------- ------------ ---------- ---------- ----------------
1118808 1119116 1 4 ACTIVE
1098796 1118808 3 3 INACTIVE
1119116 2.8147E+14 2 5 CURRENT
------------- ------------ ---------- ---------- ----------------
1118808 1119116 1 4 ACTIVE
1098796 1118808 3 3 INACTIVE
1119116 2.8147E+14 2 5 CURRENT
7、對資料庫做不完全恢復。切記是不完全恢復。
SQL> recover database until sequence 6;
ORA-00277: illegal option to the UNTIL recovery flag SEQUENCE
SQL> recover database until sequence 6;
ORA-00277: illegal option to the UNTIL recovery flag SEQUENCE
注意不支援上面的寫法。sqlplus 下不支援 until sequence的寫法。
SQL> recover database until cancel;
ORA-00279: change 1118809 generated at 07/06/2012 11:51:04 needed for thread 1
ORA-00289: suggestion : /oracle/archivelog/1_4_787915613.dbf
ORA-00280: change 1118809 for thread 1 is in sequence #4
ORA-00279: change 1118809 generated at 07/06/2012 11:51:04 needed for thread 1
ORA-00289: suggestion : /oracle/archivelog/1_4_787915613.dbf
ORA-00280: change 1118809 for thread 1 is in sequence #4
Specify log: {
/oracle/archivelog/1_4_787915613.dbf
ORA-00279: change 1119116 generated at 07/06/2012 11:53:27 needed for thread 1
ORA-00289: suggestion : /oracle/archivelog/1_5_787915613.dbf
ORA-00280: change 1119116 for thread 1 is in sequence #5
ORA-00278: log file '/oracle/archivelog/1_4_787915613.dbf' no longer needed for
this recovery
Specify log: {
/oracle/flash_recovery_area/ORA11/onlinelog/o1_mf_2_7zdhq0rl_.log ----手工指定當前redo日誌
Log applied.
Media recovery complete.
這裡要注意:recover databae until cancel 會自動找歸檔日誌,但是不會自動找current redo 日誌,所以需要手工指定。
SQL> select first_change#,next_change#,group#,sequence#,status from v$log;
SQL> select first_change#,next_change#,group#,sequence#,status from v$log;
FIRST_CHANGE# NEXT_CHANGE# GROUP# SEQUENCE# STATUS
------------- ------------ ---------- ---------- ----------------
1118808 1119116 1 4 ACTIVE
1098796 1118808 3 3 INACTIVE
1119116 2.8147E+14 2 5 CURRENT
------------- ------------ ---------- ---------- ----------------
1118808 1119116 1 4 ACTIVE
1098796 1118808 3 3 INACTIVE
1119116 2.8147E+14 2 5 CURRENT
SQL> select checkpoint_change# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
1119126
1119126
1119126
1119126
1119126
------------------
1119126
1119126
1119126
1119126
1119126
SQL> select checkpoint_change# from v$datafile;
CHECKPOINT_CHANGE#
------------------
1119126
1119126
1119126
1119126
1119126
------------------
1119126
1119126
1119126
1119126
1119126
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
8、不完全恢復完成,以resetlogs 方式開啟資料庫
SQL> alter database open resetlogs;
SQL> alter database open resetlogs;
Database altered.
總結:一定要注意 在sqlplus 下 recover database until cancel 恢復命令的特點。在歸檔和current redo沒有丟失的情況下。
不會丟失資料。如果有歸檔日誌或者是線上日誌丟失的時候,要用該命令做不完全恢復。
在做oracle的恢復時,一定要要找出原因,然後在確定是做完全恢復還是不完全恢復,根據問題決定採用的恢復命令。
控制檔案,資料檔案件,日誌檔案,scn的檢查等,一定要先分析原因。不要輕易的resetlogs。
不會丟失資料。如果有歸檔日誌或者是線上日誌丟失的時候,要用該命令做不完全恢復。
在做oracle的恢復時,一定要要找出原因,然後在確定是做完全恢復還是不完全恢復,根據問題決定採用的恢復命令。
控制檔案,資料檔案件,日誌檔案,scn的檢查等,一定要先分析原因。不要輕易的resetlogs。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23062014/viewspace-735595/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 測試在丟失歸檔日誌的情況下,跳過部分歸檔日誌進行資料恢復資料恢復
- 【恢復】Redo日誌檔案丟失的恢復
- oracle丟失active或current日誌檔案的恢復操作過程Oracle
- rman恢復--丟失聯機重做日誌的恢復
- 聯機重做日誌丟失的恢復
- 丟失非活動日誌組的恢復
- 在歸檔模式下丟失日誌檔案的恢復模式
- 利用incremental backup恢復丟失日誌的standbyREM
- oracle丟失日誌檔案的恢復( 轉)Oracle
- 恢復之利用備份在所有控制檔案丟失情況下恢復(四)
- 恢復之利用備份在所有控制檔案丟失情況下恢復(三)
- 恢復之利用備份在所有控制檔案丟失情況下恢復(二)
- 恢復之利用備份在所有控制檔案丟失情況下恢復(一)
- 從丟失日誌組中恢復流程
- oracle dg 歸檔日誌恢復情況Oracle
- Oracle恢復例項之三:active或current聯機日誌檔案丟失Oracle
- Oracle主庫歸檔丟失,備庫日誌有gap,在不重建備庫的情況下,恢復備庫Oracle
- 非歸檔丟失日誌檔案的恢復
- 丟失聯機重做日誌檔案的恢復
- 【BBED】丟失歸檔檔案情況下的恢復
- undo表空間檔案丟失恢復(2)--無備份有redo的情況下恢復
- undo表空間檔案丟失恢復(3)--無備份無redo的情況下恢復
- undo表空間檔案丟失恢復(4)--無備份無recover的情況下恢復
- 丟失已歸檔日誌檔案下恢復資料庫資料庫
- 沒有自動備份的情況下控制檔案全部丟失的恢復
- 【備份恢復】恢復 丟失已歸檔重做日誌檔案
- Oracle控制檔案在缺失歸檔日誌的情況下的恢復Oracle
- REDO檔案丟失的恢復__沒有任何備份的情況
- 丟失當前current重做日誌檔案下恢復資料庫資料庫
- 【DATAGUARD】物理dg在主庫丟失歸檔檔案的情況下的恢復(七)
- oracle歸檔日誌丟失後的資料庫恢復Oracle資料庫
- 模擬線上重做日誌被刪除的情況恢復
- oracle丟失inactive日誌檔案的恢復操作過程Oracle
- SQL Server 2005資料庫日誌丟失的恢復SQLServer資料庫
- Oracle重做日誌檔案損壞或丟失後的恢復Oracle
- 備份恢復之redo日誌組member成員丟失
- 非歸檔模式下,丟失日誌檔案的一次恢復過程模式
- 恢復案例:無歸檔,丟失全部控制檔案、日誌檔案恢復案例