Oracle的redo log在各场景下的恢复(4)

算法计算规则如下:Arg [c]*4得出一个数值,假设为V_Wrap,
如果Arg [d]=0,则V_Wrap值为需要的level
 Arg [d] < 1073741824,V_Wrap+1为需要的level
 Arg [d] < 2147483648,V_Wrap+2为需要的level
 Arg [d] < 3221225472,V_Wrap+3为需要的level

数据库处于mount状态下,执行:alter session set events '10015 trace name adjust_scn level 1';

再alter database open;

可以检查v$datafile与v$datafile_header的substr(checkpoint_change#,1,14)大小相同


四.归档模式下的red log恢复
1)inactive logfile损坏的情况
session 1:
 SQL> select * from v$log;
 GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
 ---------- ---------- ---------- ---------- ---------- --- ----------------
 FIRST_CHANGE# FIRST_TIM
 ------------- ---------
 1 1 4 104857600 1 NO CURRENT
 1.2792E+13 04-JUN-14

2 1 2 104857600 1 YES INACTIVE
 1.2792E+13 04-JUN-14

3 1 3 104857600 1 YES INACTIVE
 1.2792E+13 04-JUN-14


 SQL> col member for a70
 SQL> select * from v$logfile;

GROUP# STATUS TYPE
 ---------- ------- -------
 MEMBER IS_
 ---------------------------------------------------------------------- ---
 3 ONLINE
 /kttest1-1_data1/emsdev/redo03.dbf NO

1 ONLINE
 /kttest1-1_data1/emsdev/redo01.dbf NO

2 ONLINE
 /kttest1-1_data1/emsdev/redo02.dbf NO


 session 2:
 root@kttest1-1 # dd if=/dev/null of=/kttest1-1_data1/emsdev/redo03.dbf bs=512 count=10
 0+0 records in
 0+0 records out

在这一步,如果不将数据库进行shutdown,继续进行logfile的切换,那么redo03仍然是可以写的,然而存在潜在风险。

session 1:
 SQL> shutdown abort
 ORACLE instance shut down.
 SQL> startup
 ORACLE instance started.

Total System Global Area 3207790592 bytes
 Fixed Size 2119072 bytes
 Variable Size 381586016 bytes
 Database Buffers 2818572288 bytes
 Redo Buffers 5513216 bytes
 Database mounted.
 ORA-00320: cannot read file header from log 3 of thread 1
 ORA-00312: online log 3 thread 1: '/kttest1-1_data1/emsdev/redo03.dbf'

SQL> alter database clear logfile group 3;

Database altered.

SQL> alter database drop logfile group 3;

Database altered.

SQL> alter database add logfile group 3 ('/kttest1-1_data1/emsdev/redo03.dbf') size 100m reuse;

Database altered.

SQL> alter database open; ++++ 这里地方由于原来旧有的redo03被进程持有,可能句柄未释放,所以仍然报错,重启实例即可.

alter database open
 *
 ERROR at line 1:
 ORA-00320: cannot read file header from log 3 of thread 1
 ORA-00312: online log 3 thread 1: '/kttest1-1_data1/emsdev/redo03.dbf'

SQL> startup
 ORACLE instance started.

Total System Global Area 3207790592 bytes
 Fixed Size 2119072 bytes
 Variable Size 381586016 bytes
 Database Buffers 2818572288 bytes
 Redo Buffers 5513216 bytes
 Database mounted.
 Database opened.
 SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
 ---------- ---------- ---------- ---------- ---------- --- ----------------
 FIRST_CHANGE# FIRST_TIM
 ------------- ---------
 1 1 4 104857600 1 YES INACTIVE
 1.2792E+13 04-JUN-14

2 1 2 104857600 1 YES INACTIVE
 1.2792E+13 04-JUN-14

3 1 5 104857600 1 NO CURRENT
 1.2792E+13 04-JUN-14


 SQL> alter system switch logfile;

System altered.


2. 归档模式下current logfile损坏

场景一:
session 1:
 SQL> set line 200
 SQL> col member for a30
 SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
 ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
 1 1 4 104857600 1 YES INACTIVE 1.2792E+13 04-JUN-14
 2 1 6 104857600 1 NO CURRENT 1.2792E+13 04-JUN-14
 3 1 5 104857600 1 YES INACTIVE 1.2792E+13 04-JUN-14

SQL> select * from v$logfile;

GROUP# STATUS TYPE MEMBER IS_
 ---------- ------- ------- ------------------------------ ---
 3 ONLINE /kttest1-1_data1/emsdev/redo03 NO
 .dbf

1 ONLINE /kttest1-1_data1/emsdev/redo01 NO
 .dbf

2 ONLINE /kttest1-1_data1/emsdev/redo02 NO
 .dbf
 session 2:
 root@kttest1-1 # dd if=/dev/null of=/kttest1-1_data1/emsdev/redo02.dbf bs=512 count=10
 0+0 records in
 0+0 records out

session 1:

SQL> shutdown immediate
 ORA-03113: end-of-file on communication channel
 Process ID: 15430
 Session ID: 74 Serial number: 1

SQL> conn /as sysdba
 Connected to an idle instance.
 SQL> startup
 ORACLE instance started.

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/a18f509956a427c366160a3189765dc3.html