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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 測試在丟失歸檔日誌的情況下,跳過部分歸檔日誌進行資料恢復資料恢復
- oracle dg 歸檔日誌恢復情況Oracle
- 【BBED】丟失歸檔檔案情況下的恢復
- Oracle Redo丟失恢復方案Oracle
- 伺服器資料丟失了怎麼恢復/分割槽丟失恢復教程伺服器
- 硬碟資料丟失如何恢復?硬碟
- 分割槽丟失資料恢復資料恢復
- chkdsk 後資料丟失的恢復方法
- MySQL異常恢復之無主鍵情況下innodb資料恢復的方法MySql資料恢復
- Sqlserver系統資料庫和使用者資料庫日誌檔案全部丟失的恢復SQLServer資料庫
- OpenSIPS 2.4.2 高併發下,日誌丟失怎麼辦
- DBMS_BACKUP_RESTORE用於特殊情況下的恢復(轉)REST
- 丟失的隨身碟檔案如何恢復?
- oracle丟失的是所有的redo日誌組Oracle
- 剪下的檔案還能恢復嗎,恢復剪貼丟失的檔案
- 伺服器RAID資料丟失恢復伺服器AI
- OMV資料恢復NAS陣列丟失資料恢復陣列
- 電腦檔案丟失資料恢復資料恢復
- 如何恢復伺服器資料丟失伺服器
- u盤資料丟失怎麼恢復?有效的恢復方法在這裡
- 探索 PM2 Cluster 模式下 Log4js 日誌丟失模式JS
- DBMS_BACKUP_RESTORE.DBMS_BACKUP_RESTORE用於特殊情況下的恢復REST
- Oracle 目錄許可權丟失故障恢復Oracle
- Sql Server資料庫檔案丟失的恢復方法SQLServer資料庫
- Oracle閃回功能恢復偶然丟失的資料(轉)Oracle
- Omni Recover for Mac如何恢復所有丟失的iPhone資料MaciPhone
- DG歸檔日誌缺失恢復
- Oracle DataGuard歸檔日誌丟失處理方法Oracle
- MySQL重做日誌恢復資料的流程MySql
- RabbitMQ-如何保證訊息在99.99%的情況下不丟失MQ
- NetApp資料恢復—NetApp儲存池中劃分的卷丟失的資料恢復案例APP資料恢復
- 【raid資料恢復案例】raid擴容導致的資料丟失的資料恢復AI資料恢復
- 伺服器資料恢復案例之RAID資訊丟失資料恢復伺服器資料恢復AI
- 伺服器(RAID1)資料丟失恢復伺服器AI
- 伺服器(RAID)資料丟失瞭如何恢復?伺服器AI
- dg丟失歸檔,使用rman增量備份恢復
- 虛擬機器未知原因丟失的資料恢復案例虛擬機資料恢復
- DATA GUARD主庫丟失資料檔案的恢復(3)
- 如何使用Disk Drill 3為macOS恢復丟失的資料?Mac