redo log file的管理

平台:

# cat /etc/release
                       Solaris 10 1/06 s10x_u1wos_19a X86
          Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
                       Use is subject to license terms.
                          Assembled 07 December 2005
数据库版本:


SQL> select * from v$version where rownum<2;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Prod


redo日志的管理

=========================================================

1.添加日志组成员


原有redo日志组的信息为:

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

   GROUP#     MEMBER                                                     STATUS
---------- --------------------------------------------           -------
        3 /u01/app/oracle/oradata/nice/redo03.log          

        2 /u01/app/oracle/oradata/nice/redo02.log          

        1 /u01/app/oracle/oradata/nice/redo01.log          

每组添加一个新的成员在不同的硬盘上:

alter database add logfile member '/u03/app/oracle/redo01b.log' to group 1;

alter database add logfile member '/u03/app/oracle/redo02b.log' to group 2;

alter database add logfile member '/u03/app/oracle/redo03b.log' to group 3;

添加后的redo日志信息:

select group#,member,status from v$logfile;

   GROUP# MEMBER                                                 STATUS
---------- --------------------------------------------- -------
        3 /u01/app/oracle/oradata/nice/redo03.log          

        2 /u01/app/oracle/oradata/nice/redo02.log          

        1 /u01/app/oracle/oradata/nice/redo01.log          

        1 /u03/app/oracle/redo01b.log                        INVALID
        2 /u03/app/oracle/redo02b.log                        INVALID
        3 /u03/app/oracle/redo03b.log                        INVALID

‘INVALID’表示还没有使用,切换手动几次日志后即为ACTIVE(空白)状态了。

============================================================

2.更改redo日志的名字(也可以更改位置)

将/u01/app/oracle/oradata/nice目录下的1,2,3组日志的redo01,redo02,redo03分别更改成redo01a,redo02a,redo03a与新增加的1,2,3组日志成员想对应;

(1)关闭数据库,并将日志文件改名(或者可以移动到新的位置)

shutdown immediate

使用操作系统命令:

cd /u01/app/oracle/oradata/nice

mv redo01.log redo01a.log

mv redo02.log redo02a.log

mv redo03.log redo03a.log

(2)启动数据库到mount状态

startup mount;

(3)对修改过的redo文件重命名

alter database rename file '/u01/app/oracle/oradata/nice/redo01.log' to '/u01/app/oracle/oradata/nice/redo01a.log';

alter database rename file '/u01/app/oracle/oradata/nice/redo02.log' to '/u01/app/oracle/oradata/nice/redo02a.log';

alter database rename file '/u01/app/oracle/oradata/nice/redo03.log' to '/u01/app/oracle/oradata/nice/redo03a.log';

查询改变后的状态:

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

   GROUP# MEMBER                                   STATUS
---------- ---------------------------------------- -------
        3 /u01/app/oracle/oradata/nice/redo03a.log
        2 /u01/app/oracle/oradata/nice/redo02a.log
        1 /u01/app/oracle/oradata/nice/redo01a.log
        1 /u03/app/oracle/redo01b.log
        2 /u03/app/oracle/redo02b.log
        3 /u03/app/oracle/redo03b.log

============================================================

3.增加新的日志组

SQL> select group#,bytes/1024/1024 as MB from v$log;

   GROUP#         MB
----------         ----------
        1                 50
        3                 50
        2                 50

增加新的日志组的文件大小为50M,与前三组相同。

alter database add logfile group 4 ('/u01/app/oracle/oradata/nice/redo04a.log','/u03/app/oracle/redo04b.log') size 50M;


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

   GROUP# MEMBER                                   STATUS
---------- ---------------------------------------- -------
        3 /u01/app/oracle/oradata/nice/redo03a.log
        2 /u01/app/oracle/oradata/nice/redo02a.log
        1 /u01/app/oracle/oradata/nice/redo01a.log
        1 /u03/app/oracle/redo01b.log
        2 /u03/app/oracle/redo02b.log
        3 /u03/app/oracle/redo03b.log
        4 /u01/app/oracle/oradata/nice/redo04a.log
        4 /u03/app/oracle/redo04b.log

============================================================

4.删除redo日志组或者成员

需要redo日志在INACTIVE状态下才能删除;

SQL> select group#,archived,status from v$log;

   GROUP# ARC STATUS
---------- --- ----------------
        1 NO  INACTIVE
        2 NO  INACTIVE
        3 NO  CURRENT
        4 NO  INACTIVE

将第4组删除:

SQL> alter database drop logfile group 4;

Database altered.

SQL> select group#,archived,status from v$log;

   GROUP# ARC STATUS
---------- --- ----------------
        1 NO  INACTIVE
        2 NO  INACTIVE
        3 NO  CURRENT

在操作系统中将第4组的文件删除;

备份数据库的control file。

alter database backup controlfile '/u02/oradata/nice/hotbak/control.ctl';


你可能感兴趣的:(redo,logfile)