练习增加日志组数至4组,且每组日志成员大小为50M,每组2个成员。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了练习增加日志组数至4组,且每组日志成员大小为50M,每组2个成员。相关的知识,希望对你有一定的参考价值。

1.查看日志组成员路径及日志组大小、状态

SQL> select group#,member from v$logfile;

    GROUP# MEMBER
---------- --------------------------------------------------
         3 /u01/app/oracle/oradata/ORA11GR2/redo03.log
         2 /u01/app/oracle/oradata/ORA11GR2/redo02.log
         1 /u01/app/oracle/oradata/ORA11GR2/redo01.log

SQL> select group#,bytes/1024/1024,members,status from v$log;

    GROUP# BYTES/1024/1024    MEMBERS STATUS
---------- --------------- ---------- ----------------
         1              50          1 INACTIVE
         2              50          1 INACTIVE
         3              50          1 CURRENT

2.增加group 4,group 5,group 6,group 7四组日志

SQL> alter database add logfile group 4 
  2  (/u01/app/oracle/oradata/ORA11GR2/redo04_a.log,
  3   /u01/app/oracle/oradata/ORA11GR2/redo04_b.log) size 50M;

Database altered.

SQL> alter database add logfile group 5 
  2  (/u01/app/oracle/oradata/ORA11GR2/redo05_a.log,
  3   /u01/app/oracle/oradata/ORA11GR2/redo05_b.log) size 50M;

Database altered.

SQL> alter database add logfile group 6 
  2  (/u01/app/oracle/oradata/ORA11GR2/redo06_a.log,
  3   /u01/app/oracle/oradata/ORA11GR2/redo06_b.log) size 50M;

Database altered.

SQL> alter database add logfile group 7 
  2  (/u01/app/oracle/oradata/ORA11GR2/redo07_a.log,
  3   /u01/app/oracle/oradata/ORA11GR2/redo07_b.log) size 50M;

Database altered.

3.查看日志组状态

SQL> select group#,member from v$logfile;

    GROUP# MEMBER
---------- --------------------------------------------------
         3 /u01/app/oracle/oradata/ORA11GR2/redo03.log
         2 /u01/app/oracle/oradata/ORA11GR2/redo02.log
         1 /u01/app/oracle/oradata/ORA11GR2/redo01.log
         4 /u01/app/oracle/oradata/ORA11GR2/redo04_a.log
         4 /u01/app/oracle/oradata/ORA11GR2/redo04_b.log
         5 /u01/app/oracle/oradata/ORA11GR2/redo05_a.log
         5 /u01/app/oracle/oradata/ORA11GR2/redo05_b.log
         6 /u01/app/oracle/oradata/ORA11GR2/redo06_a.log
         6 /u01/app/oracle/oradata/ORA11GR2/redo06_b.log
         7 /u01/app/oracle/oradata/ORA11GR2/redo07_a.log
         7 /u01/app/oracle/oradata/ORA11GR2/redo07_b.log

11 rows selected.

SQL> select group#,bytes/1024/1024,members,status from v$log;

    GROUP# BYTES/1024/1024    MEMBERS STATUS
---------- --------------- ---------- ----------------
         1              50          1 INACTIVE
         2              50          1 INACTIVE
         3              50          1 CURRENT
         4              50          2 UNUSED
         5              50          2 UNUSED
         6              50          2 UNUSED
         7              50          2 UNUSED

7 rows selected.

4.切换日志查看日志组状态

SQL> alter system switch logfile;

System altered.

SQL> select group#,bytes/1024/1024,members,status from v$log;

    GROUP# BYTES/1024/1024    MEMBERS STATUS
---------- --------------- ---------- ----------------
         1              50          1 INACTIVE
         2              50          1 INACTIVE
         3              50          1 ACTIVE
         4              50          2 CURRENT
         5              50          2 UNUSED
         6              50          2 UNUSED
         7              50          2 UNUSED

7 rows selected.

5.手工执行检查点事件

SQL> alter system checkpoint;

System altered.

SQL> select group#,bytes/1024/1024,members,status from v$log;

    GROUP# BYTES/1024/1024    MEMBERS STATUS
---------- --------------- ---------- ----------------
         1              50          1 INACTIVE
         2              50          1 INACTIVE
         3              50          1 INACTIVE
         4              50          2 CURRENT
         5              50          2 UNUSED
         6              50          2 UNUSED
         7              50          2 UNUSED

7 rows selected.

6.删除group 1,group 2,group 3

SQL> alter database drop logfile group 1;

Database altered.

SQL> alter database drop logfile group 2;

Database altered.

SQL> alter database drop logfile group 3;

Database altered.

SQL> select group#,bytes/1024/1024,members,status from v$log;

    GROUP# BYTES/1024/1024    MEMBERS STATUS
---------- --------------- ---------- ----------------
         4              50          2 CURRENT
         5              50          2 UNUSED
         6              50          2 UNUSED
         7              50          2 UNUSED

注释:日志组的四种状态:
unused:表明该日志组从来没有被使用过,我们可以看到重建的日志组就是这个状态。
current:是oracle当前正在使用的日志组,即后台进程LGWR正在写的日志组。
active:当发生日志切换的时候,状态为current的日志组就会变成active状态,表明记录在这个日志组的事务提交所造成的数据块改变,还没有完全从database buffer cache 写入到data file中。当数据库处于archivelog mode时,ARCn就会归档这个日志组。所以处在这个状态的日志组是不允许被覆盖的。崩溃恢复需要该状态,可用于块恢复,可能归档也可能未归档。
inactive:处于这个状态的日志组,表明记录在这个日志组的事务提交所造成的数据块的改变,已经完全从database buffer cache写入到data file中了,实例恢复不再需要这个状态的日志组了,所以这个日志组是可以被覆盖的。

 





以上是关于练习增加日志组数至4组,且每组日志成员大小为50M,每组2个成员。的主要内容,如果未能解决你的问题,请参考以下文章

实验一个修改日志文件配置调优的案例

(DFS全排列)POJ-2718 Smallest Difference

练习--日志恢复---非当前日志组所有成员丢失

Oralce增加logfile(转贴)

求一段C语言程序,主要是比较两个数据组。

算法笔记_062:蓝桥杯练习 最小乘积(基本型)(Java)