在上文中,我们讨论过Active状态下,dbwr还没有将相应的事务数据块写入到DB File中,此时Log Group的状态是Active。将Active状态转变为Inactive的方法,就是手工的进行checkpoint,强制启动dbwr一次写入动作。
--当前是group 4为当前日志;
SQL> select group#, sequence#, bytes, members, status from v$log;
GROUP# SEQUENCE# BYTES MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
1 217 52428800 2 INACTIVE
2 218 52428800 2 ACTIVE
3 216 52428800 2 INACTIVE
4 219 10485760 2 CURRENT
5 0 10485760 2 UNUSED
--手工一次切换,形成group 4为active状态;
SQL> alter system switch logfile;
System altered
SQL> select group#, sequence#, bytes, members, status from v$log;
GROUP# SEQUENCE# BYTES MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
1 217 52428800 2 INACTIVE
2 218 52428800 2 ACTIVE
3 216 52428800 2 INACTIVE
4 219 10485760 2 ACTIVE
5 220 10485760 2 CURRENT
--写入检查点;
SQL> alter system checkpoint;
System altered
SQL> select group#, sequence#, bytes, members, status from v$log;
GROUP# SEQUENCE# BYTES MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
1 217 52428800 2 INACTIVE
2 218 52428800 2 INACTIVE
3 216 52428800 2 INACTIVE
4 219 10485760 2 INACTIVE
5 220 10485760 2 CURRENT
ü删除redo log group
删除redo log group要有至少两个前提,需要注意:
首先是要保证删除日志组状态为unused或者inactive,否则不能删除。其次是删除后,系统日志组个数不能少于2个。
SQL> select group#, sequence#, bytes, members, status from v$log;
GROUP# SEQUENCE# BYTES MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
1 217 52428800 2 INACTIVE
2 218 52428800 2 INACTIVE
3 221 52428800 2 CURRENT
4 219 10485760 2 INACTIVE
5 220 10485760 2 ACTIVE
--ACTIVE状态删除报错。
SQL> alter database drop logfile group 5;
alter database drop logfile group 5
ORA-01624: 日志 5 是紧急恢复实例 wilson (线程 1) 所必需的
ORA-00312: 联机日志 5 线程 1: '/u01/oradata/WILSON/onlinelog/o1_mf_5_7vqh94p2_.log'
ORA-00312: 联机日志 5 线程 1: '/u01/flash_recovery_area/WILSON/onlinelog/o1_mf_5_7vqh94t6_.log'
SQL> select group#, sequence#, bytes, members, status from v$log;
GROUP# SEQUENCE# BYTES MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
1 217 52428800 2 INACTIVE
2 218 52428800 2 INACTIVE
3 221 52428800 2 CURRENT
4 219 10485760 2 INACTIVE
5 220 10485760 2 ACTIVE
SQL> alter system checkpoint;
System altered
SQL> select group#, sequence#, bytes, members, status from v$log;
GROUP# SEQUENCE# BYTES MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
1 217 52428800 2 INACTIVE
2 218 52428800 2 INACTIVE
3 221 52428800 2 CURRENT
4 219 10485760 2 INACTIVE
5 220 10485760 2 INACTIVE
调整好状态之后,再进行删除。