首页 > 其他分享 >[20231023]备库与alter system flush buffer_cache.txt

[20231023]备库与alter system flush buffer_cache.txt

时间:2023-10-30 21:12:53浏览次数:39  
标签:备库 20231023 buffer 192.168 -- UBA ---------- CR block

[20231023]备库与alter system flush buffer_cache.txt

--//测试遇到的问题,在备库执行alter system flush buffer_cache;刷新数据缓存命令无效.
--//通过例子验证:

1.环境:
[email protected]:1521/orcl> @ ver1
[email protected]:1521/orcl> @ pr
==============================
PORT_STRING                   : x86_64/Linux 2.4.xx
VERSION                       : 19.0.0.0.0
BANNER                        : Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
BANNER_FULL                   : Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
BANNER_LEGACY                 : Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
CON_ID                        : 0
PL/SQL procedure successfully completed.
--//235 主库,237 备库、

2.建立测试例子:
create table t1  tablespace users pctfree 99 as select level id, lpad(level, 3500, 'T1') vc from dual connect by level <= 500 order by dbms_random.random;
--//建立的表T1非常特殊1块1条记录,这样便于后面的分析。

3.测试:
--//在备库测试:
[email protected]:1521/orcldg> select rowid,id,substr(vc,3498,3) from t1 where id=1;
ROWID                      ID SUBSTR
------------------ ---------- ------
AAA8CMAAHAAAErrAAA          1 1T1

[email protected]:1521/orcldg> @ rowid AAA8CMAAHAAAErrAAA
    OBJECT       FILE      BLOCK        ROW ROWID_DBA            DBA                  TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
    245900          7      19179          0  0x1C04AEB           7,19179              alter system dump datafile 7 block 19179

[email protected]:1521/orcldg> @ bh1 7 19179
DBARFIL      DBABLK CLASS CLASS_TYPE         STATE STATE1        TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ CR_UBA_REC CR_XID_USN CR_XID_SLT CR_XID_SQN CR_CLS_BAS CR_CLS_WRP   LRBA_SEQ   LRBA_BNO   HSCN_BAS   HSCN_WRP   HSUB_SCN OBJECT_NAME
------- ----------- ----- ------------------ ----- ------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------------
      7       19179     1 data block             5 mrec            0          0          0          0          0          0          0          0          0          0          0          0          0     524288          0          0          0 T1

[email protected]:1521/orcldg> alter system flush buffer_cache ;
System altered.

[email protected]:1521/orcldg> @ bh1 7 19179
DBARFIL      DBABLK CLASS CLASS_TYPE         STATE STATE1        TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ CR_UBA_REC CR_XID_USN CR_XID_SLT CR_XID_SQN CR_CLS_BAS CR_CLS_WRP   LRBA_SEQ   LRBA_BNO   HSCN_BAS   HSCN_WRP   HSUB_SCN OBJECT_NAME
------- ----------- ----- ------------------ ----- ------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------------
      7       19179     1 data block             5 mrec            0          0          0          0          0          0          0          0          0          0          0          0          0     524288          0          0          0 T1
--//备库上记录的STATE1=mrec,也就是在备库执行alter system flush buffer_cache ;,根本无法刷新这些数据块从数据缓存。

--//在主库测试:
[email protected]:1521/orcl> select rowid,id,substr(vc,3498,3) from t1 where id=1;
ROWID                      ID SUBSTR
------------------ ---------- ------
AAA8CMAAHAAAErrAAA          1 1T1

[email protected]:1521/orcl> @ bh1 7 19179
DBARFIL      DBABLK CLASS CLASS_TYPE         STATE STATE1        TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ CR_UBA_REC CR_XID_USN CR_XID_SLT CR_XID_SQN CR_CLS_BAS CR_CLS_WRP   LRBA_SEQ   LRBA_BNO   HSCN_BAS   HSCN_WRP   HSUB_SCN OBJECT_NAME
------- ----------- ----- ------------------ ----- ------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------------
      7       19179     1 data block             1 xcur            2          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0      65535 T1
      7       19179     1 data block             0 free            0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0 T1
      7       19179     1 data block             0 free            0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0 T1
--//STATE1=xcur

[email protected]:1521/orcl> alter system flush buffer_cache;
System altered.

[email protected]:1521/orcl> @ bh1 7 19179
DBARFIL      DBABLK CLASS CLASS_TYPE         STATE STATE1        TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ CR_UBA_REC CR_XID_USN CR_XID_SLT CR_XID_SQN CR_CLS_BAS CR_CLS_WRP   LRBA_SEQ   LRBA_BNO   HSCN_BAS   HSCN_WRP   HSUB_SCN OBJECT_NAME
------- ----------- ----- ------------------ ----- ------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------------
      7       19179     1 data block             0 free            0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0 T1
      7       19179     1 data block             0 free            0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0 T1
      7       19179     1 data block             0 free            0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0 T1
--//刷新数据缓存后变成了STATE1=free.

--//补充测试,经历几天,该数据块应该不再数据缓存,继续测试看看,验证是否是state1=mrec的原因。
[email protected]:1521/orcldg> @ bh1 7 19179
no rows selected

[email protected]:1521/orcldg> select rowid,id,substr(vc,3498,3) from t1 where id=1;
ROWID                      ID SUBSTR
------------------ ---------- ------
AAA8CMAAHAAAErrAAA          1 1T1

[email protected]:1521/orcldg> @ bh1 7 19179
DBARFIL      DBABLK CLASS CLASS_TYPE         STATE STATE1        TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ CR_UBA_REC CR_XID_USN CR_XID_SLT CR_XID_SQN CR_CLS_BAS CR_CLS_WRP   LRBA_SEQ   LRBA_BNO   HSCN_BAS   HSCN_WRP   HSUB_SCN OBJECT_NAME
------- ----------- ----- ------------------ ----- ------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------------
      7       19179     1 data block             1 xcur            1          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0      65535 T1
--//注意看现在状态是xcur.

[email protected]:1521/orcldg> alter system flush buffer_cache ;
System altered.

[email protected]:1521/orcldg> @ bh1 7 19179
DBARFIL      DBABLK CLASS CLASS_TYPE         STATE STATE1        TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ CR_UBA_REC CR_XID_USN CR_XID_SLT CR_XID_SQN CR_CLS_BAS CR_CLS_WRP   LRBA_SEQ   LRBA_BNO   HSCN_BAS   HSCN_WRP   HSUB_SCN OBJECT_NAME
------- ----------- ----- ------------------ ----- ------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------------
      7       19179     1 data block             0 free            0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0 T1
--//可以发现state1=free,这样是可以刷新出共享池的.mrec状态的不行.

[email protected]:1521/orcldg> SELECT /*+ leading (t1 t2) use_nl(t2) */ t1.id,substr(t1.vc,3496,5) vc1,substr(t2.vc,3496,5) vc2 FROM t1 , t2 WHERE t1.id = t2.id AND t1.id between 1 and 10;
        ID VC1        VC2
---------- ---------- ----------
         1 1T1T1      2T2T1
         2 1T1T2      2T2T2
        10 1T110      2T210
         9 1T1T9      2T2T9
         3 1T1T3      2T2T3
         4 1T1T4      2T2T4
         5 1T1T5      2T2T5
         6 1T1T6      2T2T6
         7 1T1T7      2T2T7
         8 1T1T8      2T2T8
10 rows selected.
--//这样可以再现我链接遇到的情况.id=10,9在前面输出.
--// http://blog.itpub.net/267265/viewspace-2990586/ =>[20231020]为什么刷新缓存后输出记录顺序发生变化5.txt

[email protected]:1521/orcldg> select * from V$SESSION_WAIT_HISTORY where sid=1276 and event ='db file parallel read';
       SID       SEQ#     EVENT# EVENT                 P1TEXT      P1 P2TEXT      P2 P3TEXT      P3  WAIT_TIME WAIT_TIME_MICRO TIME_SINCE_LAST_WAIT_MICRO     CON_ID
---------- ---------- ---------- --------------------- ---------- --- ---------- --- ---------- --- ---------- --------------- -------------------------- ----------
      1276          1        184 db file parallel read files        1 blocks       7 requests     7          0              37                         94          0
      1276          4        184 db file parallel read files        1 blocks       8 requests     8          0              42                         70          0
--//确实会出现2次db file parallel read.

5.附上bh1.sql脚本:
 $ cat bh1.sql
set echo off
--------------------------------------------------------------------------------
-- @name: bh
-- @author: dion cho
-- @note: show block header
-- @usage: @bh f# b#
--------------------------------------------------------------------------------

col object_name format a12
col state1 format a6
col dbarfil format 999999
col dbablk  format 9999999999
col state format 99
col class format 99

select
  b.dbarfil,
  b.dbablk,
  b.class,
  decode(b.class,1,'data block',2,'sort block',3,'save undo block', 4,
  'segment header',5,'save undo header',6,'free list',7,'extent map',
  8,'1st level bmb',9,'2nd level bmb',10,'3rd level bmb', 11,'bitmap block',
  12,'bitmap index block',13,'file header block',14,'unused',
  15,'system undo header',16,'system undo block', 17,'undo header',
  18,'undo block') class_type,
  state,
  decode(state,0,'free',1,'xcur',2,'scur',3,'cr', 4,'read',5,'mrec',6,'irec',7,'write',8,'pi', 9,'memory',10,'mwrite',11,'donated') as state1,
  b.tch,
  cr_scn_bas,
  cr_scn_wrp,
  cr_uba_fil,
  cr_uba_blk,
  cr_uba_seq,
  cr_uba_rec,
  cr_xid_usn,
  cr_xid_slt,
  cr_xid_sqn,
  cr_cls_bas,
  cr_cls_wrp,
  lrba_seq,
  lrba_bno,
  hscn_bas,
  hscn_wrp,
  hsub_scn,
  (select object_name from dba_objects where object_id = b.obj) as object_name
from x$bh b
where
  dbarfil = &1 and
  dbablk = &2
;
--select b.*,
--  decode(b.state,0,'free',1,'xcur',2,'scur',3,'cr', 4,'read',5,'mrec',6,'irec',7,'write',8,'pi', 9,'memory',10,'mwrite',11,'donated') as state,
--  (select object_name from dba_objects where object_id = b.obj) as object_name
--from x$bh b
--where
--  dbarfil = &1 and
--  dbablk = &2
--;

标签:备库,20231023,buffer,192.168,--,UBA,----------,CR,block
From: https://www.cnblogs.com/lfree/p/17798837.html

相关文章

  • 开启大页与否对CacheBuffer的影响的学习
    开启大页与否对CacheBuffer的影响的学习背景最近遇到数据库压力较高的场景.原厂工程师到位后修改了几个参数(自己以为参数没问题)然后最近一周环境就比较正常了.这个地方很打脸,自己没有进行详细的调查.分析思考问题的思路和方向出现了问题.基于这个情况,自己特别想......
  • 创建用户供备库查询
    背景和目的:为不影响主库性能,创建一用户和视图只允许在备库访问。涉及视图中表较大,结构设计不合理,性能稍差。过程:创建视图、用户、授权、创建同义词、验证1、produser用户创建视图切换到g_tab等用户下altersessionsetcurrent_schema=produser;替换下面view的sql--createor......
  • Chromium Command Buffer原理解析
    CommandBuffer 是支撑Chromium多进程硬件加速渲染的核心技术之一。它基于OpenGLES2.0定义了一套序列化协议,这套协议规定了所有OpenGLES2.0命令的序列化格式,使得应用对OpenGL的调用可以被缓存并传输到其他的进程中去执行(GPU进程),从而实现多个进程配合的渲染机制。1. Com......
  • String和StringBuffer的区别
    String和StringBuffer是Java中两种用于处理字符串的不同类,它们之间有一些重要的区别。 可变性:String 是不可变的(immutable):一旦创建了一个 String 对象,就不能更改它的内容。每次对 String 进行修改操作(例如拼接字符串),都会创建一个新的 String 对象。这可能会导致......
  • 数据序列化协议 Protocol Buffers(Protobuf) 认知
    写在前面需要存大数据,同事推荐,了解一下理解不足小伙伴帮忙指正对每个人而言,真正的职责只有一个:找到自我。然后在心中坚守其一生,全心全意,永不停息。所有其它的路都是不完整的,是人的逃避方式,是对大众理想的懦弱回归,是随波逐流,是对内心的恐惧——赫尔曼·黑塞《德米安》ProtocolBuf......
  • 【图形学笔记】Lecture02&03 光栅化、抗锯齿、Z-buffer
    目录Lecture02-DigitalDrawing数码绘画Triangles-FundamentalAreaPrimitive三角形——基本区域Rasterization光栅化Sampling采样Lecture03-Sampling,Aliasing,Antialiasing采样、锯齿、抗锯齿Artifactsduetosampling-“Aliasing”采样产生的问题-混叠Antialias......
  • InnoDB 存储引擎之 Buffer Pool
    Mysql5.7InnoDB存储引擎整体逻辑架构图一、BufferPool概述InnoDB作为一个存储引擎,为了降低磁盘IO,提升读写性能,必然有相应的缓冲池机制,这个缓冲池就是BufferPool为了方便理解,对于磁盘上的数据所在的页,叫做数据页,当数据页加载进BufferPool之后,叫做缓存页,......
  • 每日总结20231023
    代码时间(包括上课)3h代码量(行):100行博客数量(篇):1篇相关事项:1、今天是周一,新的一周开始了,然后软件模式是上机课,这节课写的第一个实验是UML的复习,赶上软考也考UML,正好趁着这个机会把uml的知识多看看。2、第二节课是人机交互技术,这节课老师点了五名同学讲了一下他们分别对H+这个模......
  • 20231023学习总结
    Hive数据库的数据类型:TINYINT:1个字节SMALLINT:2个字节INT:4个字节BIGINT:8个字节BOOLEAN:TRUE/FALSE)FLOAT:4个字节,单精度浮点型DOUBLE:8个字节,双精度浮点型STRING字符串ARRAY:有序字段MAP:无序字段STRUCT:一组命名的字段HiveQL:createdatabaseifnotexistsdbna......
  • Java基础 read (char[] buffer) 底层原理
    FileReaderfr=newFileReader("E:\\Java基础资料\\a.txt");char[]chars=newchar[2];while(true){intlen=fr.read(chars);if(len==-1)break;System.out.print(newString(chars,0,len));}fr.close(); read(char[] buffer)......