Oracle資料庫聯機日誌檔案丟失處理方法(1)

jss001發表於2009-02-12
試驗一:用命令清空日誌組方法

 1、檢視原來表中資料SQL>; conn test/test Connected. SQL>; select * from test;

TEL

----------

1 2 3 2、插入新資料SQL>; insert into test values(4);

1 row created.

SQL>; commit;

Commit complete.

SQL>

3、 正常關閉資料庫

4、 利用os command刪除所有redo檔案

5、 啟動資料庫

SQL>; startup

ORACLE instance started.

Total System Global Area 353862792 bytes

Fixed Size 730248 bytes

Variable Size 285212672 bytes

Database Buffers 67108864 bytes

Redo Buffers 811008 bytes

Database mounted.

ORA- 00313: open failed for members of log group 1 of thread 1 ORA-00312: online log 1 thread 1: '/T3/ORACLE/oradata/ORA9/redo01.log'

6、 檢視當前日誌狀態

SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS

---------- ---------- ---------- ---------- ---------- --- ----------------

FIRST_CHANGE# FIRST_TIME

------------- ----------

1 1 2 104857600 1 YES INACTIVE 487837 01-9月 -05

2 1 4 104857600 1 NO CURRENT 487955 01-9月 -05

3 1 3 104857600 1 YES INACTIVE 487839 01-9月 -05看來redo01.log不是當前日誌,對於這類非當前日誌可以直接clear,系統會重新自動生成一個redo檔案

7、SQL>; alter database clear logfile group 1;

Database altered.

繼續啟動db

SQL>; alter database open;

alter database open * ERROR at line 1:

ORA- 00313: open failed for members of log group 2 of thread 1 ORA-00312: online log 2 thread 1: '/T3/ORACLE/oradata/ORA9/redo02.log'

8、 看來redo也得恢復,但是redo02是當前redo,直接clear是不行的

SQL>; alter database clear logfile group 2;

alter database clear logfile group 2

* ERROR at line 1:ORA-00350: log 2 of thread 1 needs to be archived

ORA-00312: online log 2 thread 1: '/T3/ORACLE/oradata/ORA9/redo02.log'嘗試clear unarchived logfile group ,報錯:

SQL>; alter database clear unarchived logfile group 2;

alter database clear unarchived logfile group 2 * ERROR at line 1:ORA-00313: open failed for members of log group 2 of thread 1 ORA-00312: online log 2 thread 1: '/T3/ORACLE/oradata/ORA9/redo02.log' ORA-27037: unable to obtain file status SVR4 Error:

2: No such file or directory Additional information:

3看來他是因為找不到這個檔案,從有效的備份中cp一個過來看看

SQL>; host cp /T3/ORACLE/oradatabak/redo02* /T3/ORACLE/oradata/ORA9

SQL>; alter database clear unarchived logfile group 2;

Database altered.搞定………。

9、 按照oracle的某些做法也是可以的SQL>; alter database clear unarchived logfile group 1 unrecoverable datafile;

Database altered.

10、但是對於非當前日誌就都可以,下面看看redo03 SQL>; alter database clear logfile group 3;

Database altered.

結論:如果資料庫是正常shutdown,非當前日誌都可以直接clear來重新生成,而且不丟失資料,因為正常關閉db,資料已經寫入dbf檔案了。唯獨當前日誌不可以,當前日誌必須首先從有效的備份中複製一個日誌檔案過來,然後用alter database clear unarchived logfile group n 或alter database clear unarchived logfile group n,除此之外,還可以用下面的方法來做[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/18921899/viewspace-1017273/,如需轉載,請註明出處,否則將追究法律責任。

相關文章