Oracle Database 联机日志文件管理

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle Database 联机日志文件管理相关的知识,希望对你有一定的参考价值。

查询联机日志文件
SQL> col member for a50

SQL> select group#,status,type,member from v$logfile;   
    GROUP# Status    TS Type         MEMBER
---------- --------- --------------- --------------------------------------------------
         3           ONLINE          /u01/app/oracle/oradata/king/redo03.log
         2           ONLINE          /u01/app/oracle/oradata/king/redo02.log
         1           ONLINE          /u01/app/oracle/oradata/king/redo01.log


查询联机日志组
SQL> select group#,sequence#,members,bytes,status,archived from v$log;
    GROUP#  SEQUENCE#    MEMBERS      BYTES Status    ARCHIVED
---------- ---------- ---------- ---------- --------- ---------
         1          4          1   52428800 INACTIVE  YES
         2          5          1   52428800 INACTIVE  YES
         3          6          1   52428800 CURRENT   NO


删除联机日志组
SQL> alter database drop logfile group 1;

SQL> host rm -rf /u01/app/oracle/oradata/king/redo01.log

创建联机日志组
SQL> alter database add logfile group 1
('/u01/app/oracle/oradata/king/redo01a.log','/u01/app/oracle/oradata/king/redo01b.log')
size 50M;


SQL> alter database drop logfile group 2;

SQL> host rm -rf /u01/app/oracle/oradata/king/redo02.log

SQL> alter database add logfile group 2
('/u01/app/oracle/oradata/king/redo02a.log','/u01/app/oracle/oradata/king/redo02b.log')
size 50M;


SQL> alter system switch logfile;

SQL> alter system checkpoint;


SQL> alter database drop logfile group 3;

SQL> host rm -rf /u01/app/oracle/oradata/king/redo03.log

SQL> alter database add logfile group 3
('/u01/app/oracle/oradata/king/redo03a.log','/u01/app/oracle/oradata/king/redo03b.log')
size 50M;


SQL> select group#,status,type,member from v$logfile;
    GROUP# Status    TS Type         MEMBER
---------- --------- --------------- --------------------------------------------------
         3           ONLINE          /u01/app/oracle/oradata/king/redo03a.log
         2           ONLINE          /u01/app/oracle/oradata/king/redo02a.log
         1           ONLINE          /u01/app/oracle/oradata/king/redo01a.log
         1           ONLINE          /u01/app/oracle/oradata/king/redo01b.log
         2           ONLINE          /u01/app/oracle/oradata/king/redo02b.log
         3           ONLINE          /u01/app/oracle/oradata/king/redo03b.log


SQL> select group#,sequence#,members,bytes,status,archived from v$log;
    GROUP#  SEQUENCE#    MEMBERS      BYTES Status    ARCHIVED
---------- ---------- ---------- ---------- --------- ---------
         1          7          2   52428800 CURRENT   NO
         2          0          2   52428800 UNUSED    YES
         3          0          2   52428800 UNUSED    YES


在日志组中增加联机日志文件
SQL> alter database add logfile member
'/u01/app/oracle/oradata/king/redo01c.log' to group 1,
'/u01/app/oracle/oradata/king/redo02c.log' to group 2,
'/u01/app/oracle/oradata/king/redo03c.log' to group 3;


SQL> select group#,status,type,member from v$logfile;
    GROUP# Status    TS Type         MEMBER
---------- --------- --------------- --------------------------------------------------
         3           ONLINE          /u01/app/oracle/oradata/king/redo03a.log
         2           ONLINE          /u01/app/oracle/oradata/king/redo02a.log
         1           ONLINE          /u01/app/oracle/oradata/king/redo01a.log
         1           ONLINE          /u01/app/oracle/oradata/king/redo01b.log
         2           ONLINE          /u01/app/oracle/oradata/king/redo02b.log
         3           ONLINE          /u01/app/oracle/oradata/king/redo03b.log
         1 INVALID   ONLINE          /u01/app/oracle/oradata/king/redo01c.log
         2 INVALID   ONLINE          /u01/app/oracle/oradata/king/redo02c.log
         3 INVALID   ONLINE          /u01/app/oracle/oradata/king/redo03c.log


SQL> select group#,sequence#,members,bytes,status,archived from v$log;
    GROUP#  SEQUENCE#    MEMBERS      BYTES Status    ARCHIVED
---------- ---------- ---------- ---------- --------- ---------
         1          7          3   52428800 CURRENT   NO
         2          0          3   52428800 UNUSED    YES
         3          0          3   52428800 UNUSED    YES


删除日志组中的联机日志文件
SQL>  alter database drop logfile member
'/u01/app/oracle/oradata/king/redo02c.log';

SQL> host rm -rf /u01/app/oracle/oradata/king/redo02c.log


SQL> alter database drop logfile member
'/u01/app/oracle/oradata/king/redo03c.log';

SQL> host rm -rf /u01/app/oracle/oradata/king/redo03c.log


SQL> alter system switch logfile;
SQL> alter system checkpoint;


SQL>  alter database drop logfile member
'/u01/app/oracle/oradata/king/redo01c.log';

SQL> host rm -rf /u01/app/oracle/oradata/king/redo01c.log


以上是关于Oracle Database 联机日志文件管理的主要内容,如果未能解决你的问题,请参考以下文章

DB笔试面试225在Oracle中,如果联机Redo日志文件损坏,那么如何恢复?

oracle联机重做日志文件(online redo log file)

Oracle学习笔记

Oracle--基础

Oracle11g17_归档方式和日志文件的操作

9. Oracle 归档日志