我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

如何进行oracleswitchlogfile日志切换以及altersystemcheckpoint做了什么

本篇文章为大家展示了如何进行oracle switch logfile日志切换以及alter system checkpoint做了什么,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

创新互联建站是专业的新兴网站建设公司,新兴接单;提供成都网站建设、成都做网站,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行新兴网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

日志切换或checkpoint到底发生了什么?
 1,刚变成active的日志文件(即由last_change#到next_change#的redo)被 dbwr写入到数据文件

2,ckpt更新所有数据文件头的start scn即v$datafile_header.checkpoint_change#为刚变成active的日志文件
  的first_change#

3,ckpt同时更新控制文件的检查点scn,即v$database.checkpoint_change#为active状态日志文件的first_change#

/***********测试开始*************/
/**********检查点发生前的数据文件头scn*********/
SQL> select checkpoint_change# from v$datafile_header;
 
CHECKPOINT_CHANGE#
------------------
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
 
CHECKPOINT_CHANGE#
------------------
          10590730
 
21 rows selected

SQL> select * from v$log;
 
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARCHIVED STATUS           FIRST_CHANGE# FIRST_TIME  NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- ----------- ------------ -----------
         3          1        817   52428800        512          1 NO       INACTIVE              10453013 2013/3/24 1     10454569 2013/3/24 1
         4          1        818  209715200        512          1 NO       INACTIVE              10454569 2013/3/24 1     10492795 2013/3/24 1
         5          1        819  209715200        512          1 NO       INACTIVE              10492795 2013/3/24 1     10560992 2013/3/25 1
         6          1        820  209715200        512          1 NO       INACTIVE              10560992 2013/3/25 1     10561002 2013/3/25 1
         7          1        821  209715200        512          1 NO       INACTIVE              10561002 2013/3/25 1     10561202 2013/3/25 1
         8          1        822  209715200        512          1 NO       INACTIVE              10561202 2013/3/25 1     10588922 2013/3/25 1
         9          1        816  209715200        512          1 NO       INACTIVE              10446578 2013/3/24 1     10453013 2013/3/24 1
        10          1        823   20971520        512          1 NO       CURRENT               10588922 2013/3/25 1 281474976710
 
8 rows selected


SQL> select checkpoint_change# from v$database;
 
CHECKPOINT_CHANGE#
------------------
          10590730
 
SQL> select checkpoint_change# from v$datafile;
 
CHECKPOINT_CHANGE#
------------------
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
 
CHECKPOINT_CHANGE#
------------------
          10590730
 
21 rows selected

/*********日志切换后各个scn*****************/
SQL> alter system switch logfile;
 
System altered
 
 
SQL> select checkpoint_change# from v$datafile;
 
CHECKPOINT_CHANGE#
------------------
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
 
CHECKPOINT_CHANGE#
------------------
          10590730
 
21 rows selected

SQL> select checkpoint_change# from v$database;
 
CHECKPOINT_CHANGE#
------------------
          10590730
         

SQL> select * from v$log;
 
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARCHIVED STATUS           FIRST_CHANGE# FIRST_TIME  NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- ----------- ------------ -----------
         3          1        817   52428800        512          1 NO       INACTIVE              10453013 2013/3/24 1     10454569 2013/3/24 1
         4          1        818  209715200        512          1 NO       INACTIVE              10454569 2013/3/24 1     10492795 2013/3/24 1
         5          1        819  209715200        512          1 NO       INACTIVE              10492795 2013/3/24 1     10560992 2013/3/25 1
         6          1        820  209715200        512          1 NO       INACTIVE              10560992 2013/3/25 1     10561002 2013/3/25 1
         7          1        821  209715200        512          1 NO       INACTIVE              10561002 2013/3/25 1     10561202 2013/3/25 1
         8          1        822  209715200        512          1 NO       INACTIVE              10561202 2013/3/25 1     10588922 2013/3/25 1
         9          1        824  209715200        512          1 NO       CURRENT               10591778 2013/3/25 1 281474976710
        10          1        823   20971520        512          1 NO       ACTIVE                10588922 2013/3/25 1     10591778 2013/3/25 1
 
8 rows selected          
 
SQL> select checkpoint_change# from v$datafile_header;
 
CHECKPOINT_CHANGE#
------------------
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
 
CHECKPOINT_CHANGE#
------------------
          10590730
 
21 rows selected

小结:alter system checkpoint不会触发变更数据文件及数据文件头的检查点scn


/***********再看下日志切换是怎么样的情况********************/
/**************日志切换前*************************/
SQL> select checkpoint_change# from v$datafile_header;
 
CHECKPOINT_CHANGE#
------------------
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
 
CHECKPOINT_CHANGE#
------------------
          10590730
 
21 rows selected
 
SQL> select checkpoint_change# from v$datafile;
 
CHECKPOINT_CHANGE#
------------------
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
          10590730
 
CHECKPOINT_CHANGE#
------------------
          10590730
 
21 rows selected
 
SQL> select checkpoint_change# from v$database;
 
CHECKPOINT_CHANGE#
------------------
          10590730
 
SQL> select * from v$log;
 
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARCHIVED STATUS           FIRST_CHANGE# FIRST_TIME  NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- ----------- ------------ -----------
         3          1        817   52428800        512          1 NO       INACTIVE              10453013 2013/3/24 1     10454569 2013/3/24 1
         4          1        818  209715200        512          1 NO       INACTIVE              10454569 2013/3/24 1     10492795 2013/3/24 1
         5          1        819  209715200        512          1 NO       INACTIVE              10492795 2013/3/24 1     10560992 2013/3/25 1
         6          1        820  209715200        512          1 NO       INACTIVE              10560992 2013/3/25 1     10561002 2013/3/25 1
         7          1        821  209715200        512          1 NO       INACTIVE              10561002 2013/3/25 1     10561202 2013/3/25 1
         8          1        822  209715200        512          1 NO       INACTIVE              10561202 2013/3/25 1     10588922 2013/3/25 1
         9          1        824  209715200        512          1 NO       CURRENT               10591778 2013/3/25 1 281474976710
        10          1        823   20971520        512          1 NO       ACTIVE                10588922 2013/3/25 1     10591778 2013/3/25 1
 
8 rows selected
 
SQL>

/***********日志切换后****************/
SQL> alter system switch logfile;
 
System altered


SQL> select * from v$log;
 
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARCHIVED STATUS           FIRST_CHANGE# FIRST_TIME  NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- ----------- ------------ -----------
         3          1        825   52428800        512          1 NO       CURRENT               10592541 2013/3/25 1 281474976710
         4          1        818  209715200        512          1 NO       INACTIVE              10454569 2013/3/24 1     10492795 2013/3/24 1
         5          1        819  209715200        512          1 NO       INACTIVE              10492795 2013/3/24 1     10560992 2013/3/25 1
         6          1        820  209715200        512          1 NO       INACTIVE              10560992 2013/3/25 1     10561002 2013/3/25 1
         7          1        821  209715200        512          1 NO       INACTIVE              10561002 2013/3/25 1     10561202 2013/3/25 1
         8          1        822  209715200        512          1 NO       INACTIVE              10561202 2013/3/25 1     10588922 2013/3/25 1
         9          1        824  209715200        512          1 NO       ACTIVE                10591778 2013/3/25 1     10592541 2013/3/25 1
        10          1        823   20971520        512          1 NO       INACTIVE              10588922 2013/3/25 1     10591778 2013/3/25 1
 
8 rows selected

/***参考上面日志信息,控制文件的检查点scn及数据文件及数据文件头的scn已经更新active日志的first_change#/
SQL> select checkpoint_change# from v$database;
 
CHECKPOINT_CHANGE#
------------------
          10591778
 
SQL> select checkpoint_change# from v$datafile;
 
CHECKPOINT_CHANGE#
------------------
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
 
CHECKPOINT_CHANGE#
------------------
          10591778
 
21 rows selected
 
SQL> select checkpoint_change# from v$datafile_header;
 
CHECKPOINT_CHANGE#
------------------
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
          10591778
 
CHECKPOINT_CHANGE#
------------------
          10591778
 
21 rows selected

上述内容就是如何进行oracle switch logfile日志切换以及alter system checkpoint做了什么,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联行业资讯频道。


当前名称:如何进行oracleswitchlogfile日志切换以及altersystemcheckpoint做了什么
当前链接:http://shouzuofang.com/article/gjgodo.html

其他资讯