Oracle特殊恢复原理与实战_07 归档模式下缺失Redo Log后的恢复
Inactive redo log丢失或损坏的恢复
将数据库置于非归档模式
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 90
Current log sequence 91
|
INACTIVE STATUS:redo log里面的日志所对应的buffer cache里的脏块都写到datafile中了
# 模拟出丢失或损坏的INACTIVE redo log,如第2组
select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------------- ------------ -------------------
1 1 91 52428800 512 1 NO CURRENT 4256107 2018-04-02 22:06:01 2.8147E+14
2 1 89 52428800 512 1 YES INACTIVE 4227420 2018-04-02 07:00:17 4254495 2018-04-02 22:00:17
3 1 90 52428800 512 1 YES INACTIVE 4254495 2018-04-02 22:00:17 4256107 2018-04-02 22:06:01
col MEMBER for a50
select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------- ---
3 ONLINE /u01/app/oracle/oradata/orcl/redo03.log NO
2 ONLINE /u01/app/oracle/oradata/orcl/redo02.log NO # 下面模拟2损坏
1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log NO
dd if=/dev/null of=/u01/app/oracle/oradata/orcl/redo02.log bs=512 count=20
# 改后可以直接正常关闭数据库
shutdown immediate
# 但打开数据库时报错
startup
#-----------------------------------------------------------------------------------
ORACLE instance started.
Total System Global Area 4375998464 bytes
Fixed Size 2260328 bytes
Variable Size 889193112 bytes
Database Buffers 3472883712 bytes
Redo Buffers 11661312 bytes
Database mounted.
ORA-03113: end-of-file on communication channel
Process ID: 18001
Session ID: 191 Serial number: 3
#-----------------------------------------------------------------------------------
# alert日志中有如下错误信息
#-----------------------------------------------------------------------------------
Tue Apr 03 16:08:12 2018
ARC0 started with pid=20, OS id=18003
ARC0: Archival started
LGWR: STARTING ARCH PROCESSES COMPLETE
ARC0: STARTING ARCH PROCESSES
Errors in file /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_lgwr_17981.trc:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/orcl/redo02.log' # 提示打开 log group 2 失败
ORA-27047: unable to read the header block of file
Linux-x86_64 Error: 25: Inappropriate ioctl for device
Additional information: 1
Errors in file /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_lgwr_17981.trc:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/orcl/redo02.log'
ORA-27047: unable to read the header block of file
Linux-x86_64 Error: 25: Inappropriate ioctl for device
Additional information: 1
Errors in file /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_18001.trc:
ORA-00313: open failed for members of log group 1 of thread
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/orcl/redo02.log'
#-----------------------------------------------------------------------------------
# 这时,先正常打开数据库到mount状态
startup mount
# 查看log group 2状态
col MEMBER for a50
select l.STATUS,f.member,BYTES/1024/1024 size_m from v$log l, v$logfile f where l.GROUP#=2 and l.GROUP#=f.GROUP#;
STATUS MEMBER SIZE_M
---------------- -------------------------------------------------- ----------
INACTIVE /u01/app/oracle/oradata/orcl/redo02.log 50
# 在控制文件中清除logfile group 2
alter database clear logfile group 2;
alter database drop logfile group 2;
# 删除logfile group 2对应的文件
! rm -rf /u01/app/oracle/oradata/orcl/redo02.log
# 增加logfile group 2
alter database add logfile group |
