1. 程式人生 > >Oracle Database 聯機日誌文件管理

Oracle Database 聯機日誌文件管理

tab BE alt log ali ren 管理 for PE

查詢聯機日誌文件 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 聯機日誌文件管理