Oracle RAC Past Image(PI) 说明

.  PI 说明

转自

       Oracle RAC Concept of Past Image (PI)

       http://www.remote-dba.net/t_rac_concept_past_image_pi.htm

 

       The past image concept was introduced in the RAC version of Oracle 9i to maintain data integrity. In an Oracle database, a typical data block is not written to the disk immediately, even after it is dirtied. When the same dirty data block is requested by another instance for write or read purposes, an image of the block is created at the owning instance, and only that block is shipped to the requesting instance. This backup image of the block is called the past image (PI) and is kept in memory. In the event of failure, Oracle can reconstruct the current version of the block by reading PIs. It is also possible to have more than one past image in the memory depending on how many times the data block was requested in the dirty stage.

 

       A past image copy of the data block is different from a CR block, which is needed for reconstructing a read-consistent image. A CR version of a block represents a consistent snapshot of the data at a point in time. It is constructed by applying information from the undo/rollback segments. The PI image copy helps the recovery process and aids in maintaining data integrity.

       有关CR block 的说明,参考我的blog

              CR (consistent read) blocks create 说明

              http://blog.csdn.net/tianlesoftware/archive/2011/06/07/6529401.aspx

 

       For example, suppose user A of Instance 1 has updated row 2 on block 5. Later, user B of Instance 2 intends to update row 6 on the same block 5. The GCS transfers block 5 from Instance A to Instance B. At this point, the past image (PI) for block 5 is created on Instance A.

 

Lock Modes

 

       From the examination of resource roles, resource modes, and past images, the next step is to consider the possible resource access modes as shown in Table 2.2.

       There are three characters that distinguish lock or block access modes. The first letter represents the lock mode, the second character represents the lock role, and the third character (a number) indicates any past images for the lock in the local instance.

-- 介绍LOCK_MODE 各个字段的含义。

  

LOCK MODE

DESCRIPTION

NL0

Null Local and No past images

SL0

Shared Local with no past image

XL0

Exclusive Local with no past image

NG0

Null Global – Instance owns current block image

SG0

Global Shared Lock – Instance owns current image

XG0

Global Exclusive Lock – Instance own current image

NG1

Global Null – Instance owns the past image block

SG1

Shared Global – Instance owns past image

XG1

Global Exclusive Lock – Instance owns past image.

 

       When a block is brought into the local cache of an instance, it is acquired with the local role. But if a dirty buffer for the same data block is present in a remote instance, a past image is created in the remote instance before the data block is sent to the requesting instance’s cache. Therefore, the data block resource acquires a global role.

       For recovery purposes, instances that have past images will keep those past images in their buffer cache until the master instance prompts the lock to release them. When the buffers are discarded, the instance holding the past image will write a block written redo (BWR) to the redo stream. The BWR indicates that the block has already been written to disk and is not needed for recovery by the instance. Buffers are discarded when the disk write is initiated on the master instance. The master instance is where the current status and position of the data block is maintained.

       This has been a review of how a GCS resource maintains its access mode and its role. There is another feature called the buffer state, which is covered in the next section.

 

 

.  PI 示例

 

转自:http://blogs.oracle.com/toddbao/entry/past_imagepi

 

      Past Image是一种RAC环境中脏缓冲块的状态,是集群中不同实例对同一个数据缓冲块写而又写后的间接结果。简而言之,Past Image是一种特殊的脏数据块,它保留了前一次更改后的样子。 对于同一个block,每一个实例最多只能有一个Past ImagePI 也称残像。 实例间争夺、修改热块很容易观察到Past Image

       当前环境是这样的:HR.EMPLOYEES中的100号员工和101号员工都在5号文件的88号数据块中。

       每个数据块可以包含多条row记录。 可以将block dump出来,查看trace 内容。如:alter system dump datafile 4 block 32;

 

在我的blog里有一个示例:

       Oracle rdba dba 说明

       http://blog.csdn.net/tianlesoftware/archive/2011/06/07/6529346.aspx

 

 

将设称此数据块为球,让两个实例争夺这个球。


#
观测1 球不在任何节点上。
SYS@RAC1//scripts> select inst_id,status from gv$bh where file#=5 and block#=88;
no rows selected

节点1要球。
SYS@RAC1//scripts> update hr.employees set salary=1 where employee_id=100;
1 row updated.

#
观测2 球在节点1上。xcur表示写调用的当前数据缓冲,即排他当前数据块。
SYS@RAC1//scripts> select inst_id,dirty,status from gv$bh where file#=5 and block#=88;
INST_ID + D + STATUS
---------- + - + -------
1 + Y + xcur
1 row selected.

#
节点2要球。
SYS@RAC2//scripts> update hr.employees set salary=2 where employee_id=101;
1 row updated.

#
观测3 球在节点2上,残像在节点1上。pi表示Past Image,也就是残像。它保留了数据块前一次更改后的样子。
SYS@RAC1//scripts> select inst_id,dirty,status from gv$bh where file#=5 and block#=88;
INST_ID + D + STATUS
---------- + - + -------
1 + Y + pi
2 + Y + xcur
2 rows selected.

节点1要球。
SYS@RAC1//scripts> update hr.employees set salary=3 where employee_id=100;
1 row updated.

#
观测4 球在节点1上,残像在节点2和节点1上都存在。节点2上的残像比节点1上的残像更新
SYS@RAC1//scripts> select inst_id,dirty,status from gv$bh where file#=5 and block#=88;
INST_ID + D + STATUS
---------- + - + -------
1 + Y + pi
1 + Y + xcur
2 + Y + pi
3 rows selected.

#
节点2又要球。
SYS@RAC2//scripts> update hr.employees set salary=4 where employee_id=101;
1 row updated.

#
观测5 球在节点2上,很不巧这时候发生了增量检查点,DBWR醒了,想到要工作了,残像(pi)变成了陈旧的一致性读缓存块(cr。它们完全可以被覆盖。坑爹的我辛苦产生的残像都没了。
SYS@RAC1//scripts> select inst_id,dirty,status from gv$bh where file#=5 and block#=88;
INST_ID + D + STATUS
---------- + - + -------
1 + N + cr
1 + N + cr
2 + Y + xcur
3 rows selected.

重来。节点1要球。
SYS@RAC1//scripts> update hr.employees set salary=5 where employee_id=100;
1 row updated.

#
观测6 球在节点1上,残像在节点2上。陈旧的一致性读缓存块不用理会,它们随时可以消失。
SYS@RAC1//scripts> select inst_id,dirty,status from gv$bh where file#=5 and block#=88;
INST_ID + D + STATUS
---------- + - + -------
1 + Y + xcur
1 + N + cr
1 + N + cr
2 + Y + pi
4 rows selected.

#
节点2要球。
SYS@RAC2//scripts> update hr.employees set salary=6 where employee_id=101;
1 row updated.

#
观测7 球在节点2上,残像在节点12上。节点1上的残像比节点2上的残像更新。回顾一下观测4,很相似。两节点上的残像都出现了。
SYS@RAC1//scripts> select inst_id,dirty,status from gv$bh where file#=5 and block#=88;
INST_ID + D + STATUS
---------- + - + -------
1 + Y + pi
2 + Y + pi
2 + Y + xcur
3 rows selected.

#
节点1要球。
SYS@RAC1//scripts> update hr.employees set salary=7 where employee_id=100;
1 row updated.

#
观测8 球在节点1上,残像在节点21上。节点2上的残像比节点1上的残像更新。原来在节点2上的残像变成了陈旧的一致性读缓存块。没有破坏每一个实例最多只能有一个残像(针对同一个数据块)的规则
SYS@RAC1//scripts> select inst_id,dirty,status from gv$bh where file#=5 and block#=88;
INST_ID + D + STATUS
---------- + - + -------
1 + Y + pi
1 + Y + xcur
2 + Y + pi
2 + N + cr
4 rows selected.

      
不考虑任何检查点的话, xcur块移动到另一个节点时:原来节点上的xcur块转变成pi块、原来的pi块(如果有的话)转变为cr块,结果是cr块越来越多,pi则最多和节点数一样多。

接下来让两个节点进行一次弹珠球大战:同时在两个节点上执行匿名块AB

A

SYS@RAC1//scripts> run
1 begin
2 for i in 1..100000 loop
3 update hr.employees set salary=i where employee_id=100;
4 end loop;
5* end;

B

SYS@RAC2//scripts> run
1 begin
2 for i in 1..100000 loop
3 update hr.employees set salary=i where employee_id=101;
4 end loop;
5* end;

      
等到它们执行完毕后,看一下5号文件88号数据块在buffer cache中占了几个位置:
SYS@RAC2//scripts> select count(*) from gv$bh where file#=5 and block#=88;
COUNT(*)
----------
412
1 row selected.

其中409个是一致性读块缓冲(cr):
SYS@RAC2//scripts> select count(*) from gv$bh where file#=5 and block#=88 where status='cr';
COUNT(*)
----------
409
1 row selected.

1
个排他当前块缓冲(xcur):
SYS@RAC2//scripts> select count(*) from gv$bh where file#=5 and block#=88 where status='xcur';
COUNT(*)
----------
1
1 row selected.

还有...2个我们的主角--残像缓冲(pi)。分别在两个节点上。
SYS@RAC1//scripts> select inst_id,dirty,status from gv$bh where file#=5 and block#=88 and status='pi';
INST_ID + D + STATUS
---------- + - + -------
1 + Y + pi
2 + Y + pi
2 rows selected.

      
某些时候,当你在RAC环境中发现大量的一致性读缓冲(cr)时,可能你看到的是实例间争夺热块的搏斗痕迹。这是一个xcurpi再到cr的过程


PI至少有两个作用:

一,需要时节点可以从本地的pi块制造cr块,避免从其他节点请求cr块。
二,当拥有xcur块的实例崩溃后,pi块重新转变为xcur块,提高了实例恢复的速度。

 

 

 

 

-------------------------------------------------------------------------------------------------------

QQ:492913789

Email:ahdba@qq.com

Blog: http://www.cndba.cn/dave


DBA1 群:62697716();   DBA2 群:62697977()   DBA3 群:62697850()  

DBA 超级群:63306533();  DBA4 群: 83829929  DBA5群: 142216823   

DBA6 群:158654907  聊天 群:40132017   聊天2群:69087192

--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请

 

### 回答1: CentOS 7启动httpd服务失败可能有多种原因,以下是一些常见的解决方法: 1. 检查httpd配置文件是否正确:可以使用命令`httpd -t`检查httpd配置文件是否正确,如果有错误,需要修改配置文件。 2. 检查端口是否被占用:可以使用命令`netstat -tlnp`查看端口是否被占用,如果被占用需要释放端口或修改httpd配置文件中的端口号。 3. 检查httpd服务是否安装:可以使用命令`rpm -qa | grep httpd`查看httpd服务是否安装,如果没有安装需要先安装httpd服务。 4. 检查httpd服务是否启动:可以使用命令`systemctl status httpd`查看httpd服务是否启动,如果没有启动需要使用命令`systemctl start httpd`启动httpd服务。 5. 检查SELinux是否开启:如果SELinux开启,可能会导致httpd服务启动失败,需要使用命令`setenforce 0`关闭SELinux,或者修改SELinux策略。 以上是一些常见的解决方法,如果以上方法都无法解决问题,可以查看httpd服务日志文件,找到具体的错误信息,然后根据错误信息进行解决。 ### 回答2: CentOS 7上的httpd服务启动失败可能有多种原因。以下列出了一些常见问题和解决方法: 1. 端口被占用 当httpd试图占用已被其他程序占用的端口时会启动失败。此时可以通过使用`netstat -tunlp`命令检查端口占用情况,然后杀死占用该端口的进程及时释放端口。或者修改httpd的配置文件,将端口修改为未被占用的端口。 2. 配置文件错误 有时httpd服务的配置文件中可能出现错误,例如语法错误或路径错误等等。在启动httpd服务之前,可以使用`apachectl configtest`命令进行检查,如果输出“Syntax OK”,则表示配置文件没有错误。如果出现错误,则需要根据错误提示进行相应修改。 3. 依赖关系问题 如果httpd依赖的其他程序或库缺失,也会导致启动失败。可以通过使用`systemctl status httpd.service`命令来查看httpd服务状态,如果输出“Failed to start”或“Loaded: failed”,则需要检查依赖关系是否完整。 4. SELinux问题 当SELinux启用时,有时会导致httpd服务启动失败。在这种情况下,可以在SELinux上禁用httpd服务,或者修改httpd配置文件解决SELinux相关的问题。 5. 用户权限问题 httpd服务启动可能需要特定的用户权限。如果使用的用户权限不够,则无法启动。可以尝试使用root用户启动httpd服务,或者根据需要修改相应的用户权限。 ### 回答3: CentOS 7中的Apache HTTP服务器(httpd)是一个常见的Web服务器,如果遇到httpd服务启动失败的情况,可能会影响服务器正常的工作和对外服务的稳定性。本文将提供一些可能会导致httpd服务启动失败的原因,并给出相应的解决方法。 1. 端口被占用 如果端口被其他进程占用,httpd服务就无法启动。可以通过 netstat -tulpn 命令查看端口占用情况,并杀死占用该端口的进程。如果端口被 httpd 服务自身占用,可以通过 systemctl restart httpd 命令重启 httpd 服务;如果是其他进程占用了端口,可以通过 kill 命令杀死该进程或更改 httpd.conf 文件配置,将 httpd 服务的端口改为其他空闲端口,重新启动。 2. 配置文件错误 httpd 服务的配置文件通常是 /etc/httpd/conf/httpd.conf,如果其中存在语法错误、权限问题或者其它配置错误,可能会导致 httpd 服务启动出错。可以通过将 httpd.conf 文件备份后删掉,重新执行 yum install httpd 命令安装 httpd 服务,然后手动修改 httpd.conf 文件,逐个检查每个配置项是否正确,确认无误后重启 httpd 服务。 3. SELinux 问题 SELinux 是 CentOS 7中提供的一种安全模块,它可以对系统文件和应用程序进行安全管控。如果 SELinux 配置不正确,可能会阻止 httpd 服务正常启动。可以通过修改 /etc/selinux/config 文件中 SELINUX=disabled 来暂时关闭 SELinux,然后重新启动 httpd 服务;或者一个更优的方式是,根据日志确定问题原因,使用命令 semanage 或者 setsebool 等工具将相关目录或者配置加入到 SELinux 许可列表中,重新启动 httpd 服务,以恢复服务正常工作。 4. 防火墙问题 如果你的 CentOs 7 服务器启用了防火墙,有可能会导致 httpd 服务启动失败。可以通过检查防火墙相关配置来确定问题原因,解决方案是修改防火墙规则,将端口 80 或者 443 等 httpd 服务需要的端口放行,重新启动 httpd 服务。 总之,当遇到 httpd 服务启动失败时,不要慌张,可以先通过日志或者执行命令查看错误信息,找到错误原因,然后根据错误原因一步一步解决问题。在解决问题过程中注意备份原始配置文件,以免造成不必要的损失。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值