分享

Archive Log Current及Archive Log路线图

 浸心阁 2015-07-17

如果没看到Archive Log的这张路线图,也许你没有想到Archive Log还有这么多学问。
下图来自Oracle10gR2的文档

在RAC环境中,使用Current子句时,如果不指定Thread,则数据库会归档所有Thread,这在实际中是需要注意的。

当发出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.

我们可以看到这两者的区别,Switch Logfile只是强制写新的日志组,并且触发一个检查点,然后控制权立即转回给调用者;而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-

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多