oracle日誌操作記錄

msdnchina發表於2009-03-08

/*在startup之前,REDO01B.LOG已經被重新命名為REDO01B.LOG--*/
/*在startup之前,REDO02A.LOG已經被重新命名為REDO02A.LOG--*/
/*在startup之前,REDO03B.LOG已經被重新命名為REDO03B.LOG--*/

感謝http://space.itpub.net/12778571/viewspace-201664 蒙昭良

Connected to Oracle9i Enterprise Edition Release 9.2.0.1.0
Connected as system


SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER
---------- ------- ------- --------------------------------------------------------------------------------
         1 STALE   ONLINE  D:\ORACLE\ORADATA\RXL\REDO01A.LOG
         1 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO01B.LOG
         2 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO02A.LOG
         2                 ONLINE  D:\ORACLE\ORADATA\RXL\REDO02B.LOG
         3 STALE   ONLINE  D:\ORACLE\ORADATA\RXL\REDO03A.LOG
         3 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO03B.LOG

6 rows selected

SQL> alter database add logfile member 'D:\ORACLE\ORADATA\RXL\REDO01B.LOG' to group 1
  2  ;

alter database add logfile member 'D:\ORACLE\ORADATA\RXL\REDO01B.LOG' to group 1

ORA-01577: 無法新增日誌檔案'D:\ORACLE\ORADATA\RXL\REDO01B.LOG' - 檔案已是資料庫的一部分

SQL> alter database drop logfile member 'D:\ORACLE\ORADATA\RXL\REDO01B.LOG';

alter database drop logfile member 'D:\ORACLE\ORADATA\RXL\REDO01B.LOG'

ORA-00362: 組成組 1 中的有效日誌檔案要求輸入成員
ORA-01517: 日誌成員: 'D:\ORACLE\ORADATA\RXL\REDO01B.LOG'

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER
---------- ------- ------- --------------------------------------------------------------------------------
         1 STALE   ONLINE  D:\ORACLE\ORADATA\RXL\REDO01A.LOG
         1 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO01B.LOG
         2 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO02A.LOG
         2                ONLINE  D:\ORACLE\ORADATA\RXL\REDO02B.LOG
         3 STALE   ONLINE  D:\ORACLE\ORADATA\RXL\REDO03A.LOG
         3 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO03B.LOG

6 rows selected

SQL> alter system switch logfile;

System altered

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER
---------- ------- ------- --------------------------------------------------------------------------------
         1 STALE   ONLINE  D:\ORACLE\ORADATA\RXL\REDO01A.LOG
         1 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO01B.LOG
         2 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO02A.LOG
         2         ONLINE  D:\ORACLE\ORADATA\RXL\REDO02B.LOG
         3         ONLINE  D:\ORACLE\ORADATA\RXL\REDO03A.LOG
         3 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO03B.LOG

6 rows selected

SQL> alter database drop logfile member 'D:\ORACLE\ORADATA\RXL\REDO01B.LOG';

alter database drop logfile member 'D:\ORACLE\ORADATA\RXL\REDO01B.LOG'

ORA-00362: 組成組 1 中的有效日誌檔案要求輸入成員
ORA-01517: 日誌成員: 'D:\ORACLE\ORADATA\RXL\REDO01B.LOG'

SQL> alter system switch logfile;

System altered

SQL> select * from v$logfile;
Cannot execute commands now

SQL>

    GROUP# STATUS  TYPE    MEMBER
---------- ------- ------- --------------------------------------------------------------------------------
         1         ONLINE  D:\ORACLE\ORADATA\RXL\REDO01A.LOG
         1 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO01B.LOG
         2 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO02A.LOG
         2         ONLINE  D:\ORACLE\ORADATA\RXL\REDO02B.LOG
         3         ONLINE  D:\ORACLE\ORADATA\RXL\REDO03A.LOG
         3 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO03B.LOG

6 rows selected

小類注:
1.若是新增的日誌成員已經存在,不管是其status是什麼,必須先drop,之後才能add
2.在group1中,REDO01A.LOG 的status是STALE,此時再drop logfile,就會報ORA-00362錯,
  可以這麼理解,因為REDO01A.LOG 的status是STALE了,此時再drop logfile REDO01B.LOG,
  就會導致group1中沒有日誌可供使用.所以,先要alter system switch logfile;

3.當前的日誌組不能刪除,這個好理解.select status from v$log;查詢日誌組的狀態.
  status為current的為當前的日誌組.這裡我還不太明白current和active的含義.
 


SQL> alter database drop logfile member 'D:\ORACLE\ORADATA\RXL\REDO01B.LOG';

alter database drop logfile member 'D:\ORACLE\ORADATA\RXL\REDO01B.LOG'

ORA-01609: 日誌1是執行緒1的當前日誌 - 無法刪除成員
ORA-00312: 聯機日誌 1 執行緒 1: 'D:\ORACLE\ORADATA\RXL\REDO01A.LOG'
ORA-00312: 聯機日誌 1 執行緒 1: 'D:\ORACLE\ORADATA\RXL\REDO01B.LOG'

SQL> alter system switch logfile;

System altered

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER
---------- ------- ------- --------------------------------------------------------------------------------
         1         ONLINE  D:\ORACLE\ORADATA\RXL\REDO01A.LOG
         1 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO01B.LOG
         2 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO02A.LOG
         2         ONLINE  D:\ORACLE\ORADATA\RXL\REDO02B.LOG
         3         ONLINE  D:\ORACLE\ORADATA\RXL\REDO03A.LOG
         3 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO03B.LOG

6 rows selected

SQL> alter database drop logfile member 'D:\ORACLE\ORADATA\RXL\REDO01B.LOG';

Database altered

SQL> alter database add logfile member 'D:\ORACLE\ORADATA\RXL\REDO01B.LOG' to group 1
  2  ;

Database altered

SQL> alter database add logfile member 'D:\ORACLE\ORADATA\RXL\REDO01A.LOG' to group 2;

alter database add logfile member 'D:\ORACLE\ORADATA\RXL\REDO01A.LOG' to group 2

ORA-01577: 無法新增日誌檔案'D:\ORACLE\ORADATA\RXL\REDO01A.LOG' - 檔案已是資料庫的一部分

SQL> alter database drop logfile member 'D:\ORACLE\ORADATA\RXL\REDO02A.LOG';

alter database drop logfile member 'D:\ORACLE\ORADATA\RXL\REDO02A.LOG'

ORA-01609: 日誌2是執行緒1的當前日誌 - 無法刪除成員
ORA-00312: 聯機日誌 2 執行緒 1: 'D:\ORACLE\ORADATA\RXL\REDO02A.LOG'
ORA-00312: 聯機日誌 2 執行緒 1: 'D:\ORACLE\ORADATA\RXL\REDO02B.LOG'

SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARCHIVED STATUS           FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- -----------
         1          1         82  104857600          2 NO       ACTIVE                 4702690 2009-3-8 15
         2          1         83  104857600          2 NO       CURRENT                4702927 2009-3-8 15
         3          1         81  104857600          2 NO       INACTIVE               4702608 2009-3-8 15

SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARCHIVED STATUS           FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- -----------
         1          1         82  104857600          2 NO       ACTIVE                 4702690 2009-3-8 15
         2          1         83  104857600          2 NO       CURRENT                4702927 2009-3-8 15
         3          1         81  104857600          2 NO       INACTIVE               4702608 2009-3-8 15

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER
---------- ------- ------- --------------------------------------------------------------------------------
         1         ONLINE  D:\ORACLE\ORADATA\RXL\REDO01A.LOG
         1 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO01B.LOG
         2 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO02A.LOG
         2         ONLINE  D:\ORACLE\ORADATA\RXL\REDO02B.LOG
         3         ONLINE  D:\ORACLE\ORADATA\RXL\REDO03A.LOG
         3 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO03B.LOG

6 rows selected

SQL> alter database drop logfile member 'D:\ORACLE\ORADATA\RXL\REDO02A.LOG';

alter database drop logfile member 'D:\ORACLE\ORADATA\RXL\REDO02A.LOG'

ORA-01609: 日誌2是執行緒1的當前日誌 - 無法刪除成員
ORA-00312: 聯機日誌 2 執行緒 1: 'D:\ORACLE\ORADATA\RXL\REDO02A.LOG'
ORA-00312: 聯機日誌 2 執行緒 1: 'D:\ORACLE\ORADATA\RXL\REDO02B.LOG'

SQL> alter system switch logfile;

System altered

SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARCHIVED STATUS           FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- -----------
         1          1         82  104857600          2 NO       INACTIVE               4702690 2009-3-8 15
         2          1         83  104857600          2 NO       ACTIVE                 4702927 2009-3-8 15
         3          1         84  104857600          2 NO       CURRENT                4705096 2009-3-8 16

SQL> alter database drop logfile member 'D:\ORACLE\ORADATA\RXL\REDO02A.LOG';

Database altered

SQL> alter database add logfile member 'D:\ORACLE\ORADATA\RXL\REDO01A.LOG' to group 2;

alter database add logfile member 'D:\ORACLE\ORADATA\RXL\REDO01A.LOG' to group 2

ORA-01577: 無法新增日誌檔案'D:\ORACLE\ORADATA\RXL\REDO01A.LOG' - 檔案已是資料庫的一部分

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER
---------- ------- ------- --------------------------------------------------------------------------------
         1         ONLINE  D:\ORACLE\ORADATA\RXL\REDO01A.LOG
         1 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO01B.LOG
         2         ONLINE  D:\ORACLE\ORADATA\RXL\REDO02B.LOG
         3         ONLINE  D:\ORACLE\ORADATA\RXL\REDO03A.LOG
         3 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO03B.LOG

SQL> alter database add logfile member 'D:\ORACLE\ORADATA\RXL\REDO02A.LOG' to group 2;

Database altered

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER
---------- ------- ------- --------------------------------------------------------------------------------
         1         ONLINE  D:\ORACLE\ORADATA\RXL\REDO01A.LOG
         1 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO01B.LOG
         2 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO02A.LOG
         2         ONLINE  D:\ORACLE\ORADATA\RXL\REDO02B.LOG
         3         ONLINE  D:\ORACLE\ORADATA\RXL\REDO03A.LOG
         3 INVALID ONLINE  D:\ORACLE\ORADATA\RXL\REDO03B.LOG

6 rows selected

小類注:
1.在group1中, add logfile  REDO02A.LOG 成功後,查詢status是INVALID,
   此時因為還沒有使用REDO02A.LOG,所以status是INVALID.

 

SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARCHIVED STATUS           FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- -----------
         1          1         82  104857600          2 NO       INACTIVE               4702690 2009-3-8 15
         2          1         83  104857600          2 NO       ACTIVE                 4702927 2009-3-8 15
         3          1         84  104857600          2 NO       CURRENT                4705096 2009-3-8 16

SQL> alter system switch logfile;

System altered

SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARCHIVED STATUS           FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- -----------
         1          1         85  104857600          2 NO       CURRENT                4705344 2009-3-8 16
         2          1         83  104857600          2 NO       INACTIVE               4702927 2009-3-8 15
         3          1         84  104857600          2 NO       ACTIVE                 4705096 2009-3-8 16

SQL> alter database drop logfile member 'D:\ORACLE\ORADATA\RXL\REDO03B.LOG';

Database altered

SQL> alter database add logfile member 'D:\ORACLE\ORADATA\RXL\REDO03B.LOG' to group 3;
Cannot execute commands now

SQL>

Database altered

SQL>

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/161195/viewspace-563252/,如需轉載,請註明出處,否則將追究法律責任。

相關文章