为保证数据库的正常操作,Oracle 服务器最少需要两个联机重做日志文件组。重做日志文件是以循环方式使用的。Oracle 服务器将对数据库所做的所有更改按顺序记录到重做日志缓冲区中。LGWR 按顺序向联机重做日志文件写入重做信息。一旦当前联机重做日志文件组被写满,LGWR 就开始写入下一个组。这称为日志切换。当最后一个可用联机重做日志文件已满时,LGWR 将返回第一个联机重做日志文件组并开始重新写入。尽管Oracle 服务器允许多元备份的组可以包含不同数量的成员,但应该尽量建立对称配置。对联机重做日志文件进行多元备份时,请将组内的成员放置在不同磁盘上。将归档日志文件和联机重做日志文件分放在不同磁盘上,以减少ARCn 和LGWR 后台进程之间的争用。
--手动执行检查点:
检查点:是把内存中的脏数据写到数据文件的过程,DBWn进程写数据。
SQL> alter system checkpoint; 系统已更改。
--查看联机重做日志文件信息:
SQL> select * from v$log; GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- -------------- 1 1 58 52428800 1 YES INACTIVE 739504 26-9月 -11 2 1 59 52428800 1 NO CURRENT 739506 26-9月 -11 3 1 57 52428800 1 YES INACTIVE 739498 26-9月 -11 SQL> select * from v$logfile; GROUP# STATUS TYPE MEMBER IS_ ---------- ------- ------- -------------------------------------------------- --- 1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log NO 2 ONLINE /u01/app/oracle/oradata/orcl/redo02.log NO 3 ONLINE /u01/app/oracle/oradata/orcl/redo03.log NO
--增加联机重做日志文件组:
SQL> alter database add logfile group 4('/u01/app/oracle/oradata/orcl/redo04.log') size 50m; 数据库已更改。 SQL> select * from v$log; GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- -------------- 1 1 58 52428800 1 YES INACTIVE 739504 26-9月 -11 2 1 59 52428800 1 NO CURRENT 739506 26-9月 -11 3 1 57 52428800 1 YES INACTIVE 739498 26-9月 -11 4 1 0 52428800 1 YES UNUSED 0 SQL> select * from v$logfile; GROUP# STATUS TYPE MEMBER IS_ ---------- ------- ------- -------------------------------------------------- --- 1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log NO 2 ONLINE /u01/app/oracle/oradata/orcl/redo02.log NO 3 ONLINE /u01/app/oracle/oradata/orcl/redo03.log NO 4 ONLINE /u01/app/oracle/oradata/orcl/redo04.log NO
--增加联机重做日志文件成员:
SQL> alter database add logfile member '/u01/app/oracle/oradata/orcl/redo04b.log' to group 4; 数据库已更改。 SQL> select * from v$log; GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- -------------- 1 1 58 52428800 1 YES INACTIVE 739504 26-9月 -11 2 1 59 52428800 1 NO CURRENT 739506 26-9月 -11 3 1 57 52428800 1 YES INACTIVE 739498 26-9月 -11 4 1 0 52428800 2 YES UNUSED 0 SQL> select * from v$logfile; GROUP# STATUS TYPE MEMBER IS_ ---------- ------- ------- -------------------------------------------------- --- 1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log NO 2 ONLINE /u01/app/oracle/oradata/orcl/redo02.log NO 3 ONLINE /u01/app/oracle/oradata/orcl/redo03.log NO 4 ONLINE /u01/app/oracle/oradata/orcl/redo04.log NO 4 INVALID ONLINE /u01/app/oracle/oradata/orcl/redo04b.log NO
--删除联机重做日志文件成员:
SQL> alter database drop logfile member '/u01/app/oracle/oradata/orcl/redo04b.log'; 数据库已更改。 SQL> select * from v$log; GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- -------------- 1 1 58 52428800 1 YES INACTIVE 739504 26-9月 -11 2 1 59 52428800 1 NO CURRENT 739506 26-9月 -11 3 1 57 52428800 1 YES INACTIVE 739498 26-9月 -11 4 1 0 52428800 1 YES UNUSED 0 SQL> select * from v$logfile; GROUP# STATUS TYPE MEMBER IS_ ---------- ------- ------- -------------------------------------------------- --- 1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log NO 2 ONLINE /u01/app/oracle/oradata/orcl/redo02.log NO 3 ONLINE /u01/app/oracle/oradata/orcl/redo03.log NO 4 ONLINE /u01/app/oracle/oradata/orcl/redo04.log NO SQL> ! rm -rf /u01/app/oracle/oradata/orcl/redo04b.log
--删除联机重做日志文件组:
SQL> alter database drop logfile group 4; 数据库已更改。 SQL> select * from v$log; GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- -------------- 1 1 58 52428800 1 YES INACTIVE 739504 26-9月 -11 2 1 59 52428800 1 NO CURRENT 739506 26-9月 -11 3 1 57 52428800 1 YES INACTIVE 739498 26-9月 -11 SQL> select * from v$logfile; GROUP# STATUS TYPE MEMBER IS_ ---------- ------- ------- -------------------------------------------------- --- 1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log NO 2 ONLINE /u01/app/oracle/oradata/orcl/redo02.log NO 3 ONLINE /u01/app/oracle/oradata/orcl/redo03.log NO SQL> ! rm -rf /u01/app/oracle/oradata/orcl/redo04.log