日期:2014-05-16  浏览次数:22772 次

oracle 增加日志组,日志成员的一些命令
oracle 增加日志组,日志成员的一些命令
2012-05-14 13:42

1、增加日志组:

alter database add logfile group 4 '/oradata/oracle/oradata/oracle_sid/redo04.log' size 100M;

2、改变日志组的大小(

首先看下归档状态:

SQL> select group#,thread#,members,archived,status from v$log;
 
    GROUP#    THREAD#    MEMBERS ARC STATUS
---------- ---------- ---------- --- ----------------
         1          1          1 YES INACTIVE
         2          1          1 YES INACTIVE
         3          1          1 NO  CURRENT
         4          1          1 YES UNUSED

4 rows selected.

其次DROP GROUP 1(此时最好是别DROP GROUP3,至于什么后果,我没有往这方向TEST。)

SQL> alter database drop logfile group 1;
 
Database altered.

再删除redo01.log

SQL> !rm /oradata/oracle/oradata/NC5X/redo01.log

最后增加redo01.log:

SQL> alter database add logfile group 1 '/oradata/oracle/oradata/ORACLE_SID/redo01.log' size 100M;

SQL> select group#,thread#,members,archived,status from v$log;
 
    GROUP#    THREAD#    MEMBERS ARC STATUS
---------- ---------- ---------- --- ----------------
         1          1          1 YES UNUSED
         2          1          1 YES INACTIVE
         3          1          1 NO  CURRENT
         4          1          1 YES UNUSED

4 rows selected.

此时,切换下日志:

SQL> alter system switch logfile;
 
System altered.

注意:alter system switch logfile 和alter system archive log current这两个切换的区别。

alter system switch logfile 是不等待归档完成就switch logfile。如果database尚未开启archive log mode。那用这个切换是毋庸置疑了。另外,也是对单实例database和RAC模式下当前实例执行日志切换。

而alter system archive log current则需要等待归档完成才switch logfile。会对中所有实例执行日志切换。

整体上说来,在自动归档的库里,两个命令的所产生的结果几乎一样。有区别的是alter system archive log current所用的时间会比alter system switch logfile 的长。

3、增加日志组成员:

SQL> alter database add logfile member '/oraback/logbackup/redo01_b.log' to group 1;
 
Database altered.

注意:alter 语句中不可设定redo01_b.log的大小。


SQL> alter database add logfile member '/oraback/logbackup/redo01_b.log' size 100M to group 1;
alter database add logfile member '/oraback/logbackup/redo01_b.log' size 100M to group 1
                                                                    *
ERROR at line