|
如果沒看到Archive Log的這張路線圖,也許你沒有想到Archive Log還有這么多學問。
下圖來自Oracle10gR2的文檔:

在RAC環(huán)境中,使用Current子句時,如果不指定Thread,則數(shù)據(jù)庫會歸檔所有Thread,這在實際中是需要注意的。
當發(fā)出archive log current命令時,注意不同Thread同時被歸檔增進:
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 85 52428800 1 NO CURRENT 3578047 03-JUN-06
2 1 84 52428800 1 YES ACTIVE 3545972 03-JUN-06
3 2 25 52428800 1 NO CURRENT 3578044 03-JUN-06
4 2 24 52428800 1 YES INACTIVE 3481897 02-JUN-06
SQL> alter system archive log current;
System altered.
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 85 52428800 1 YES ACTIVE 3578047 03-JUN-06
2 1 86 52428800 1 NO CURRENT 3578082 03-JUN-06
3 2 25 52428800 1 YES INACTIVE 3578044 03-JUN-06
4 2 26 52428800 1 NO CURRENT 3578079 03-JUN-06
而如果我們只是想歸檔個別Thread,那么只需要加入Thread號碼即可:
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 87 52428800 1 NO CURRENT 3578781 03-JUN-06
2 1 86 52428800 1 YES INACTIVE 3578082 03-JUN-06
3 2 25 52428800 1 YES INACTIVE 3578044 03-JUN-06
4 2 26 52428800 1 NO CURRENT 3578079 03-JUN-06
SQL> alter system archive log thread 1 current;
System altered.
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 87 52428800 1 YES ACTIVE 3578781 03-JUN-06
2 1 88 52428800 1 NO CURRENT 3580768 03-JUN-06
3 2 25 52428800 1 YES INACTIVE 3578044 03-JUN-06
4 2 26 52428800 1 NO CURRENT 3578079 03-JUN-06
Oracle文檔中這樣描述Current語句:
Specify CURRENT to manually archive the current redo log file group of the specified thread, forcing a log switch. If you omit the THREAD parameter, then Oracle Database archives all redo log file groups from all enabled threads, including logs previous to current logs. You can specify CURRENT only when the database is open.
而Swith Logfile被如下定義:
The SWITCH LOGFILE clause lets you explicitly force Oracle Database to begin writing to a new redo log file group, regardless of whether the files in the current redo log file group are full. When you force a log switch, Oracle Database begins to perform a checkpoint but returns control to you immediately rather than when the checkpoint is complete. To use this clause, your instance must have the database open.
我們可以看到這兩者的區(qū)別,Switch Logfile只是強制寫新的日志組,并且觸發(fā)一個檢查點,然后控制權(quán)立即轉(zhuǎn)回給調(diào)用者;而Archive Log Current需要等候完成歸檔。
SQL> select thread# from v$instance;
THREAD#
----------
2
Elapsed: 00:00:00.01
SQL> alter system switch logfile;
System altered.
Elapsed: 00:00:00.03
SQL> alter system archive log thread 2 current;
System altered.
Elapsed: 00:00:10.14
我們注意到switch logfile要比archive log current快得多。
-The End-
|