SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> seleQct * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- -----------
1 1 20 5144576 1 YES INACTIVE 645532 2009-4-10 9
2 1 21 5144576 1 YES ACTIVE 649130 2009-4-10 1
3 1 22 5144576 1 NO CURRENT 649181 2009-4-10 1
模拟日志块的损坏:
用UE编辑这个current日志文件。继续切换:
SQL> alter system switch logfile;
System altered
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- -----------
1 1 23 5144576 1 NO CURRENT 652211 2009-4-10 1
2 1 21 5144576 1 YES INACTIVE 649130 2009-4-10 1
3 1 22 5144576 1 NO ACTIVE 649181 2009-4-10 1
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- -----------
1 1 23 5144576 1 NO CURRENT 652211 2009-4-10 1
2 1 21 5144576 1 YES INACTIVE 649130 2009-4-10 1
3 1 22 5144576 1 NO INACTIVE 649181 2009-4-10 1
--可以看到日志的状态变化,但一直没有归档。此时查看告警日志有这样的报错:
Fri Apr 10 11:33:09 2009
ARC0: Log corruption near block 523 change 649835 time ?
Fri Apr 10 11:33:09 2009
Errors in file c:\oracle\product\10.2.0\admin\orasjh\bdump\orasjh_arc0_2436.trc:
ORA-00354: 损坏重做日志块头部
ORA-00353: 日志损坏接近块 523 更改 649835 时间 04/10/2009 10:12:50
ORA-00312: 联机日志 3 线程 1: 'E:\ORACLE\ORASJH\REDO03.LOG'
ARC0: All Archive destinations made inactive due to error 354
Committing creation of archivelog 'E:\ORACLE\ORASJH\ARCHIVE\ARC00022_0682881273.001' (error 354)
ARC0: Failed to archive thread 1 sequence 22 (354)
ARCH: Archival stopped, error occurred. Will continue retrying
Fri Apr 10 11:33:09 2009
Errors in file c:\oracle\product\10.2.0\admin\orasjh\bdump\orasjh_arc0_2436.trc:
ORA-16038: 日志 3 序列号 22 无法归档
ORA-00354: 损坏重做日志块头部
ORA-00312: 联机日志 3 线程 1: 'E:\ORACLE\ORASJH\REDO03.LOG'
Fri Apr 10 11:33:27 2009
ARC1: Log corruption near block 523 change 649835 time ?
Fri Apr 10 11:33:27 2009
Errors in file c:\oracle\product\10.2.0\admin\orasjh\bdump\orasjh_arc1_2516.trc:
ORA-00354: 损坏重做日志块头部
ORA-00353: 日志损坏接近块 523 更改 649835 时间 04/10/2009 10:12:50
ORA-00312: 联机日志 3 线程 1: 'E:\ORACLE\ORASJH\REDO03.LOG'
ARC1: All Archive destinations made inactive due to error 354
Committing creation of archivelog 'E:\ORACLE\ORASJH\ARCHIVE\ARC00022_0682881273.001' (error 354)
ARC1: Failed to archive thread 1 sequence 22 (354)
Fri Apr 10 11:34:28 2009
ARC0: Log corruption near block 523 change 649835 time ?
Fri Apr 10 11:34:28 2009
Errors in file c:\oracle\product\10.2.0\admin\orasjh\bdump\orasjh_arc0_2436.trc:
ORA-00354: 损坏重做日志块头部
ORA-00353: 日志损坏接近块 523 更改 649835 时间 04/10/2009 10:12:50
ORA-00312: 联机日志 3 线程 1: 'E:\ORACLE\ORASJH\REDO03.LOG'
ARC0: All Archive destinations made inactive due to error 354
Committing creation of archivelog 'E:\ORACLE\ORASJH\ARCHIVE\ARC00022_0682881273.001' (error 354)
ARC0: Failed to archive thread 1 sequence 22 (354)
SQL> alter system switch logfile;
System altered
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- -----------
1 1 23 5144576 1 NO ACTIVE 652211 2009-4-10 1
2 1 24 5144576 1 NO CURRENT 652404 2009-4-10 1
3 1 22 5144576 1 NO INACTIVE 649181 2009-4-10 1
SQL> alter system switch logfile;
--当日志组进行第三次切换的时候数据库hung住了。因为第3个日志组还没有完成归档,数据库正等待它完成归档,所以hung住了。开启另外一个窗口进行操作。
SQL> shutdown immediate; --速度有点慢。
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup
ORACLE 例程已经启动。
Total System Global Area 167772160 bytes
Fixed Size 1247876 bytes
Variable Size 71304572 bytes
Database Buffers 88080384 bytes
Redo Buffers 7139328 bytes
数据库装载完毕。
数据库已经打开。
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIME
------------- --------------
1 1 25 5144576 1 NO CURRENT
652481 10-4月 -09
2 1 24 5144576 1 YES INACTIVE
652404 10-4月 -09
3 1 22 5144576 1 NO INACTIVE
649181 10-4月 -09
--注意数据库重新启动后,原来因为日志块损坏的日志组依然无法归档,且SEQUENCE#不变。重启之前等待归档的日志组已经归档,且当前日志跳到了日志组1。SEQUENCE#开始不连续。
SQL> alter system switch logfile;
系统已更改。
SQL> alter system switch logfile;
--通过两次切换DB又开始挂住了。打开另一个窗口继续测试。
C:\Documents and Settings\IS_SJH>sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on 星期五 4月 10 11:47:13 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn
sys/sys@orasjh as sysdba
已连接。
SQL> shutdown immediate;
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL>
SQL> startup
ORACLE 例程已经启动。
Total System Global Area 167772160 bytes
Fixed Size 1247876 bytes
Variable Size 71304572 bytes
Database Buffers 88080384 bytes
Redo Buffers 7139328 bytes
数据库装载完毕。
数据库已经打开。
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIME
------------- --------------
1 1 27 5144576 1 NO CURRENT
653254 10-4月 -09
2 1 26 5144576 1 YES INACTIVE
653224 10-4月 -09
3 1 22 5144576 1 NO INACTIVE
649181 10-4月 -09
--SEQUENCE# 还是22。
SQL> alter database clear unarchived logfile group 3;
数据库已更改。
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIME
------------- --------------
1 1 27 5144576 1 NO CURRENT
653254 10-4月 -09
--因为是inactive的redo,所以用clear还是比较好解决的。当遇到以上日志块损坏的情况导致无法归档时,我们通过查询v$archive_dest会发现当前归档的路径状态是error的。