查看重做日志的信息,用数据字典v$log:
SQL> set line 120
SQL> select * from v$log;
GROUP# SEQUENCE# MEMBERS BYTES STATUS ARC
---------- ---------- ---------- ---------- ---------------- ---
1 5 1 52428800 CURRENT NO
2 3 1 52428800 INACTIVE NO
3 4 1 52428800 INACTIVE NO
可知该数据库中有三个重做日志组,每组有一个重做日志文件,它们的序列号分别是345(必须连续的),且都是非归档的,大小都一样。
对status的解释:
inactive:表示实例已恢复,不再需要这组联机重做日志组了
current:当前组,隐含该联机重做日志
active:表示这组联机重做日志组是活动的但不是当前组,在实例恢复时需要这组联机重做日志组
unused:表示oracle服务器从未写过该组联机重做日志组,刚刚被添加进去的
查看每个重做日志组中成员的信息,用数据字典v$logfile:
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- ------------------------------------------------------- ---
3 STALE ONLINE C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO03.LOG NO
2 STALE ONLINE C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO02.LOG NO
1 ONLINE C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01.LOG NO
可知每组重做日志组中的成员都在同一个目录下,且都是联机重做日志文件。
status解释:
空白:正在使用
stale:该文件的内容不完全
invalid:该文件不可以被访问
deleted:该文件不再有用
开始工作前先备份!(详见备份)
添加一组重做日志组:
SQL>alter database add logfile
2 ('c:\disk3\orcl\onlinelog\redo 04A.log',
3 'c:\disk6\orcl\onlinelog\redo 04B.log',
4 'c:\disk9\orcl\onlinelog\redo 04C.log')
5 size 15M;
数据库已更改。
SQL> select group#,sequence#,members,bytes,status,archived from v$log;
GROUP# SEQUENCE# MEMBERS BYTES STATUS ARC
---------- ---------- ---------- ---------- ---------------- ---
1 5 1 52428800 CURRENT NO
2 3 1 52428800 INACTIVE NO
3 4 1 52428800 INACTIVE NO
4 0 3 15728640 UNUSED YES
SQL> col member for a45
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- --------------------------------------------- ---
3 STALE ONLINE C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO03. NO
LOG
2 STALE ONLINE C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO02. NO
LOG
1 ONLINE C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01. NO
LOG
4 ONLINE C:\DISK3\ORCL\ONLINELOG\REDO 04A.LOG NO
4 ONLINE C:\DISK6\ORCL\ONLINELOG\REDO 04B.LOG NO
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- --------------------------------------------- ---
4 ONLINE C:\DISK9\ORCL\ONLINELOG\REDO 04C.LOG NO
已选择6行。
SQL> alter database drop logfile group 3;
数据库已更改。
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- --------------------------------------------- ---
2 STALE ONLINE C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO02. NO
LOG
1 ONLINE C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01. NO
LOG
4 ONLINE C:\DISK3\ORCL\ONLINELOG\REDO 04A.LOG NO
4 ONLINE C:\DISK6\ORCL\ONLINELOG\REDO 04B.LOG NO
4 ONLINE C:\DISK9\ORCL\ONLINELOG\REDO 04C.LOG NO
SQL> alter database add logfile
2 ('c:\disk3\orcl\onlinelog\redo 03A.log',
3 'c:\disk6\orcl\onlinelog\redo 03B.log',
4 'c:\disk9\orcl\onlinelog\redo 03C.log')
5 size 15M;
数据库已更改。
SQL> alter database drop logfile group 2;
数据库已更改。
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- --------------------------------------------- ---
3 ONLINE C:\DISK3\ORCL\ONLINELOG\REDO 03A.LOG NO
1 ONLINE C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01. NO
LOG
4 ONLINE C:\DISK3\ORCL\ONLINELOG\REDO 04A.LOG NO
4 ONLINE C:\DISK6\ORCL\ONLINELOG\REDO 04B.LOG NO
4 ONLINE C:\DISK9\ORCL\ONLINELOG\REDO 04C.LOG NO
3 ONLINE C:\DISK6\ORCL\ONLINELOG\REDO 03B.LOG NO
3 ONLINE C:\DISK9\ORCL\ONLINELOG\REDO 03C.LOG NO
已选择7行。
SQL> alter database add logfile
2 ('c:\disk3\orcl\onlinelog\redo 02A.log',
3 'c:\disk6\orcl\onlinelog\redo 02B.log',
4 'c:\disk9\orcl\onlinelog\redo 02C.log')
5 size 15M;
数据库已更改。
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- --------------------------------------------- ---
3 ONLINE C:\DISK3\ORCL\ONLINELOG\REDO 03A.LOG NO
2 ONLINE C:\DISK3\ORCL\ONLINELOG\REDO 02A.LOG NO
1 ONLINE C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01. NO
LOG
4 ONLINE C:\DISK3\ORCL\ONLINELOG\REDO 04A.LOG NO
4 ONLINE C:\DISK6\ORCL\ONLINELOG\REDO 04B.LOG NO
4 ONLINE C:\DISK9\ORCL\ONLINELOG\REDO 04C.LOG NO
3 ONLINE C:\DISK6\ORCL\ONLINELOG\REDO 03B.LOG NO
3 ONLINE C:\DISK9\ORCL\ONLINELOG\REDO 03C.LOG NO
2 ONLINE C:\DISK6\ORCL\ONLINELOG\REDO 02B.LOG NO
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- --------------------------------------------- ---
2 ONLINE C:\DISK9\ORCL\ONLINELOG\REDO 02C.LOG NO
已选择10行。
SQL> alter system switch logfile;
系统已更改。
SQL> select group#,sequence#,members,bytes,status,archived from v$log;
GROUP# SEQUENCE# MEMBERS BYTES STATUS ARC
---------- ---------- ---------- ---------- ---------------- ---
1 5 1 52428800 ACTIVE NO
2 6 3 15728640 CURRENT NO
3 0 3 15728640 UNUSED YES
4 0 3 15728640 UNUSED YES
SQL> alter system switch logfile;
系统已更改。
SQL> select group#,sequence#,members,bytes,status,archived from v$log;
GROUP# SEQUENCE# MEMBERS BYTES STATUS ARC
---------- ---------- ---------- ---------- ---------------- ---
1 5 1 52428800 ACTIVE NO
2 6 3 15728640 ACTIVE NO
3 7 3 15728640 CURRENT NO
4 0 3 15728640 UNUSED YES
SQL> alter system switch logfile;
系统已更改。
SQL> select group#,sequence#,members,bytes,status,archived from v$log;
GROUP# SEQUENCE# MEMBERS BYTES STATUS ARC
---------- ---------- ---------- ---------- ---------------- ---
1 5 1 52428800 ACTIVE NO
2 6 3 15728640 ACTIVE NO
3 7 3 15728640 ACTIVE NO
4 8 3 15728640 CURRENT NO
SQL> alter system switch logfile;
系统已更改。
SQL> select group#,sequence#,members,bytes,status,archived from v$log;
GROUP# SEQUENCE# MEMBERS BYTES STATUS ARC
---------- ---------- ---------- ---------- ---------------- ---
1 9 1 52428800 CURRENT NO
2 6 3 15728640 ACTIVE NO
3 7 3 15728640 ACTIVE NO
4 8 3 15728640 ACTIVE NO
SQL> alter system switch logfile;
系统已更改。
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- --------------------------------------------- ---
3 ONLINE C:\DISK3\ORCL\ONLINELOG\REDO 03A.LOG NO
2 ONLINE C:\DISK3\ORCL\ONLINELOG\REDO 02A.LOG NO
1 ONLINE C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01. NO
LOG
4 ONLINE C:\DISK3\ORCL\ONLINELOG\REDO 04A.LOG NO
4 ONLINE C:\DISK6\ORCL\ONLINELOG\REDO 04B.LOG NO
4 ONLINE C:\DISK9\ORCL\ONLINELOG\REDO 04C.LOG NO
3 ONLINE C:\DISK6\ORCL\ONLINELOG\REDO 03B.LOG NO
3 ONLINE C:\DISK9\ORCL\ONLINELOG\REDO 03C.LOG NO
2 ONLINE C:\DISK6\ORCL\ONLINELOG\REDO 02B.LOG NO
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- --------------------------------------------- ---
2 ONLINE C:\DISK9\ORCL\ONLINELOG\REDO 02C.LOG NO
已选择10行。
SQL> select group#,sequence#,members,bytes,status,archived from v$log;
GROUP# SEQUENCE# MEMBERS BYTES STATUS ARC
---------- ---------- ---------- ---------- ---------------- ---
1 9 1 52428800 ACTIVE NO
2 10 3 15728640 CURRENT NO
3 7 3 15728640 ACTIVE NO
4 8 3 15728640 ACTIVE NO
SQL>
切换来切换去,第一组重做日志组不是活动组就是当前组,暂定问题7
碰到重做日志组序列号不连续,定为问题8
到此,基本上重做日志就已完成。最后一步就是把原有的旧文件删除。