设为首页 收藏本站
查看: 526|回复: 0

[经验分享] oracle public redo thread and private redo thread

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-9-1 10:19:16 | 显示全部楼层 |阅读模式
复习之前的学习内容,对public redo thread 和 private redo thread 的用处还是比较模糊,网上搜集的资料非常有限,看来有些好东西不跳墙是不行的。

废话少说,知识点记录下来:

在rac环境下,每个实例都有自己的redo log,这套redo log称为redo thread。这套概念同样适用于单实例数据库。

redo thread有两种,private 和 public ,在默认情况下,我们使用的是public thread。但是如果我们在创建redol log时明确指定了thread参数,那么该redo为private redo。

实验如下:


单实例:



    SQL> l  
      1* select thread#,status,enabled from v$thread  
    SQL> /  
      
       THREAD# STATUS ENABLED  
    ---------- ------ --------  
         1 OPEN   PUBLIC  
      
    SQL> select group#,thread#,status from v$log;  
      
        GROUP#    THREAD# STATUS  
    ---------- ---------- ----------------  
         4      1 INACTIVE  
         5      1 CURRENT  
      
    SQL> col member for a60  
    SQL> select group#,member from v$logfile;  
      
        GROUP# MEMBER  
    ---------- ------------------------------------------------------------  
         4 /home/app/oraten/oradata/oraten/redo04.log  
         5 /home/app/oraten/oradata/oraten/redo05.log  
      
    SQL> alter database add logfile thread 2 group 6 '/home/app/oraten/oradata/oraten/redo06.log' size 100M;  
      
    Database altered.  
      
    SQL> alter database add logfile thread 2 group 7 '/home/app/oraten/oradata/oraten/redo07.log' size 100M;  
      
    Database altered.  
      
    SQL> select thread#,status,enabled from v$thread;  
      
       THREAD# STATUS ENABLED  
    ---------- ------ --------  
         1 OPEN   PUBLIC  
         2 CLOSED DISABLED  
      
    SQL> alter database enable thread 2;  
      
    Database altered.  
      
    SQL> select thread#,status,enabled from v$thread;  
      
       THREAD# STATUS ENABLED  
    ---------- ------ --------  
         1 OPEN   PUBLIC  
         2 CLOSED PRIVATE  
      
    SQL> show parameter thread  
      
    NAME                     TYPE    VALUE  
    ------------------------------------ ----------- ------------------------------  
    parallel_threads_per_cpu         integer     2  
    thread                   integer     1  
    SQL> alter system set thread=2 scope=spfile;  
      
    System altered.  
      
    SQL> shutdown immediate  
    Database closed.  
    Database dismounted.  
    ORACLE instance shut down.  
    SQL> startup  
    ORACLE instance started.  
      
    Total System Global Area  281018368 bytes  
    Fixed Size          2095672 bytes  
    Variable Size         222299592 bytes  
    Database Buffers       50331648 bytes  
    Redo Buffers            6291456 bytes  
    Database mounted.  
    Database opened.  
    SQL> select thread#,status,enabled from v$thread;  
      
       THREAD# STATUS ENABLED  
    ---------- ------ --------  
         1 CLOSED PUBLIC  
         2 OPEN   PRIVATE  
      
    SQL> select group#,thread#,status from v$log;  
      
        GROUP#    THREAD# STATUS  
    ---------- ---------- ----------------  
         4      1 INACTIVE  
         5      1 CURRENT  
         6      2 CURRENT  
         7      2 UNUSED  
      
    SQL>   


Rac环境下:



      
    [oracle@node1 ~]$ crs_stat -t -v  
    Name           Type           R/RA   F/FT   Target    State     Host         
    ----------------------------------------------------------------------  
    ora.easy.db    application    0/0    0/1    ONLINE    ONLINE    node1         
    ora....y1.inst application    0/5    0/0    ONLINE    ONLINE    node1         
    ora....y2.inst application    0/5    0/0    ONLINE    ONLINE    node2         
    ora....SM1.asm application    0/5    0/0    ONLINE    ONLINE    node1         
    ora....E1.lsnr application    0/5    0/0    ONLINE    ONLINE    node1         
    ora.node1.gsd  application    0/5    0/0    ONLINE    ONLINE    node1         
    ora.node1.ons  application    0/3    0/0    ONLINE    ONLINE    node1         
    ora.node1.vip  application    0/0    0/0    ONLINE    ONLINE    node1         
    ora....SM2.asm application    0/5    0/0    ONLINE    ONLINE    node2         
    ora....E2.lsnr application    0/5    0/0    ONLINE    ONLINE    node2         
    ora.node2.gsd  application    0/5    0/0    ONLINE    ONLINE    node2         
    ora.node2.ons  application    0/3    0/0    ONLINE    ONLINE    node2         
    ora.node2.vip  application    0/0    0/0    ONLINE    ONLINE    node2         
      
    [oracle@node1 ~]$   
    [oracle@node1 ~]$ sqlplus / as sysdba  
      
    SQL*Plus: Release 10.2.0.5.0 - Production on Sat Aug 30 17:47:08 2014  
      
    Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.  
      
      
    Connected to:  
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production  
    With the Partitioning, Real Application Clusters, OLAP, Data Mining  
    and Real Application Testing options  
      
    SQL> desc v$thread  
     Name                      Null?    Type  
     ----------------------------------------- -------- ----------------------------  
     THREAD#                        NUMBER  
     STATUS                         VARCHAR2(6)  
     ENABLED                        VARCHAR2(8)  
     GROUPS                         NUMBER  
     INSTANCE                       VARCHAR2(80)  
     OPEN_TIME                      DATE  
     CURRENT_GROUP#                     NUMBER  
     SEQUENCE#                      NUMBER  
     CHECKPOINT_CHANGE#                 NUMBER  
     CHECKPOINT_TIME                    DATE  
     ENABLE_CHANGE#                     NUMBER  
     ENABLE_TIME                        DATE  
     DISABLE_CHANGE#                    NUMBER  
     DISABLE_TIME                       DATE  
     LAST_REDO_SEQUENCE#                    NUMBER  
     LAST_REDO_BLOCK                    NUMBER  
     LAST_REDO_CHANGE#                  NUMBER  
     LAST_REDO_TIME                     DATE  
      
    SQL> select thread#,status,enabled from v$thread;  
      
       THREAD# STATUS ENABLED  
    ---------- ------ --------  
         1 OPEN   PUBLIC  
         2 OPEN   PUBLIC  
      
    SQL> show parameter thread  
      
    NAME                     TYPE    VALUE  
    ------------------------------------ ----------- ------------------------------  
    parallel_threads_per_cpu         integer     2  
    thread                   integer     1  
    SQL> exit  
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production  
    With the Partitioning, Real Application Clusters, OLAP, Data Mining  
    and Real Application Testing options  
    [oracle@node1 ~]$ ssh oracle@node2  
    Last login: Mon Aug 25 13:09:51 2014 from node3  
    [oracle@node2 ~]$ sqlplus / as sysdba  
      
    SQL*Plus: Release 10.2.0.5.0 - Production on Sat Aug 30 17:48:27 2014  
      
    Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.  
      
      
    Connected to:  
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production  
    With the Partitioning, Real Application Clusters, OLAP, Data Mining  
    and Real Application Testing options  
      
    SQL> show parameter thread  
      
    NAME                     TYPE    VALUE  
    ------------------------------------ ----------- ------------------------------  
    parallel_threads_per_cpu         integer     2  
    thread                   integer     2  
      
    SQL> alter system set thread=1 scope=spfile sid='easy2';  
      
    System altered.  
      
    SQL> alter system set thread=2 scope=spfile sid='easy1';  
      
    System altered.  
      
    SQL> shutdown immediate  
    Database closed.  
    Database dismounted.  
    ORACLE instance shut down.  
    SQL> exit  
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production  
    With the Partitioning, Real Application Clusters, OLAP, Data Mining  
    and Real Application Testing options  
    [oracle@node2 ~]$ exit  
    logout  
      
    Connection to node2 closed.  
    [oracle@node1 ~]$ sqlplus / as sysdba  
      
    SQL*Plus: Release 10.2.0.5.0 - Production on Sat Aug 30 17:55:54 2014  
      
    Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.  
      
      
    Connected to:  
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production  
    With the Partitioning, Real Application Clusters, OLAP, Data Mining  
    and Real Application Testing options  
      
    SQL> shutdown immediate  
    Database closed.  
    Database dismounted.  
    ORACLE instance shut down.  
    SQL> startup  
    ORACLE instance started.  
      
    Total System Global Area  205520896 bytes  
    Fixed Size          2095088 bytes  
    Variable Size         121636880 bytes  
    Database Buffers       75497472 bytes  
    Redo Buffers            6291456 bytes  
    Database mounted.  
    Database opened.  
    SQL> show parameter thread  
      
    NAME                     TYPE    VALUE  
    ------------------------------------ ----------- ------------------------------  
    parallel_threads_per_cpu         integer     2  
    thread                   integer     2  
    SQL> exit  
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production  
    With the Partitioning, Real Application Clusters, OLAP, Data Mining  
    and Real Application Testing options  
    [oracle@node1 ~]$ ssh oracle@node2  
    Last login: Sat Aug 30 17:54:14 2014 from node1  
    [oracle@node2 ~]$ sqlplus / as sysdba  
      
    SQL*Plus: Release 10.2.0.5.0 - Production on Sat Aug 30 17:57:00 2014  
      
    Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.  
      
    Connected to an idle instance.  
      
    SQL> startup  
    ORACLE instance started.  
      
    Total System Global Area  205520896 bytes  
    Fixed Size          2095088 bytes  
    Variable Size         100665360 bytes  
    Database Buffers       96468992 bytes  
    Redo Buffers            6291456 bytes  
    Database mounted.  
    Database opened.  
    SQL> show parameter thread  
      
    NAME                     TYPE    VALUE  
    ------------------------------------ ----------- ------------------------------  
    parallel_threads_per_cpu         integer     2  
    thread                   integer     1  
    SQL> desc gv$log     
     Name                      Null?    Type  
     ----------------------------------------- -------- ----------------------------  
     INST_ID                        NUMBER  
     GROUP#                         NUMBER  
     THREAD#                        NUMBER  
     SEQUENCE#                      NUMBER  
     BYTES                          NUMBER  
     MEMBERS                        NUMBER  
     ARCHIVED                       VARCHAR2(3)  
     STATUS                         VARCHAR2(16)  
     FIRST_CHANGE#                      NUMBER  
     FIRST_TIME                     DATE  
      
    SQL> select inst_id,group#,thread# from gv$log;  
      
       INST_ID     GROUP#    THREAD#  
    ---------- ---------- ----------  
         1      1          1  
         1      2          1  
         1      3          2  
         1      4          2  
         2      1          1  
         2      2          1  
         2      3          2  
         2      4          2  
      
    8 rows selected.  
      
    SQL> show parameter thread  
      
    NAME                     TYPE    VALUE  
    ------------------------------------ ----------- ------------------------------  
    parallel_threads_per_cpu         integer     2  
    thread                   integer     1  
      
    SQL> select thread#,status,enabled from v$thread  
      2  ;  
      
       THREAD# STATUS ENABLED  
    ---------- ------ --------  
         1 OPEN   PUBLIC  
         2 OPEN   PUBLIC  
      
    SQL> alter database add logfile thread 3 group 5 '+DG4' size 50M;  
      
    Database altered.  
      
      
    SQL> alter database add logfile member '+DG4' to group 5;  
      
    Database altered.  
      
      
    SQL> alter database add logfile thread 3 group 6 '+DG4' size 50M;  
      
    Database altered.  
      
    SQL> alter database add logfile member '+DG4' to group 6;  
      
    Database altered.  
      
    SQL> alter database enable thread 3;  
      
    Database altered.  
      
    SQL> select thread#,status,enabled from v$thread;  
      
       THREAD# STATUS ENABLED  
    ---------- ------ --------  
         1 OPEN   PUBLIC  
         2 OPEN   PUBLIC  
         3 CLOSED PRIVATE  


结论:如果我们使用add logifle 语句时,指定的thread大于instancde_number,就会产生private thread(个人猜测),只有private thread的作用,目前尚未发现有特别的用处



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-24124-1-1.html 上篇帖子: 使用dbms_lob.compare比对lob字段 下篇帖子: Oracle之sql语句优化 private thread oracle public
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表