• zero_damaged_pages 隐含参数,处理磁盘页损坏(先占位)


    os: centos 7.6
    db: postgresql 12

    版本

    # cat /etc/centos-release
    CentOS Linux release 7.6.1810 (Core) 
    # 
    # yum list installed |grep -i postgre
    postgresql12.x86_64                12.7-1PGDG.rhel7                    @pgdg12  
    postgresql12-contrib.x86_64        12.7-1PGDG.rhel7                    @pgdg12  
    postgresql12-devel.x86_64          12.7-1PGDG.rhel7                    @pgdg12  
    postgresql12-docs.x86_64           12.7-1PGDG.rhel7                    @pgdg12  
    postgresql12-libs.x86_64           12.7-1PGDG.rhel7                    @pgdg12  
    postgresql12-llvmjit.x86_64        12.7-1PGDG.rhel7                    @pgdg12  
    postgresql12-odbc.x86_64           13.00.0000-1PGDG.rhel7              @pgdg12  
    postgresql12-odbc-debuginfo.x86_64 12.02.0000-1PGDG.rhel7              @pgdg-common
    postgresql12-plperl.x86_64         12.7-1PGDG.rhel7                    @pgdg12  
    postgresql12-plpython.x86_64       12.7-1PGDG.rhel7                    @pgdg12  
    postgresql12-plpython3.x86_64      12.7-1PGDG.rhel7                    @pgdg12  
    postgresql12-pltcl.x86_64          12.7-1PGDG.rhel7                    @pgdg12  
    postgresql12-server.x86_64         12.7-1PGDG.rhel7                    @pgdg12  
    postgresql12-tcl.x86_64            2.7.5-1.rhel7                       @pgdg12  
    postgresql12-test.x86_64           12.7-1PGDG.rhel7                    @pgdg12
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    创建初始化表

    pgbenchdb=# create table tmp_t0(
    id   int8,
    name varchar(100)
    );
    
    pgbenchdb=# insert into tmp_t0 select id,md5(id::varchar) from generate_series(1,1000000) as id;
    
    pgbenchdb=# checkpoint;
    
    pgbenchdb=# select count(1) from tmp_t0;
      count  
    ---------
     1000000
    (1 row)
    
    pgbenchdb=# select pg_relation_filepath('public.tmp_t0'::regclass);
     pg_relation_filepath 
    ----------------------
     base/16384/40960
    (1 row)
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    dd命令损坏数据页

    $ cd $PGDATA/base/16384
    $ pwd
    /var/lib/pgsql/12/data/base/16384
    
    $ ls -l |grep -i 40960
    -rw------- 1 postgres postgres  76562432 Jul  8 11:07 40960
    -rw------- 1 postgres postgres     40960 Jul  8 11:07 40960_fsm
    
    $ dd if=/dev/zero of=/var/lib/pgsql/12/data/base/16384/40960 bs=512 count=100
    
    $ ls -l |grep -i 40960
    -rw------- 1 postgres postgres    409600 Jul  8 11:13 40960
    -rw------- 1 postgres postgres     40960 Jul  8 11:07 40960_fsm
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    再次查询

    pgbenchdb=# select count(1) from tmp_t0;
     count 
    -------
      5350
    (1 row)
    
    pgbenchdb=# checkpoint;
    
    pgbenchdb=# select count(1) from tmp_t0;
      count  
    ---------
     1000000
    (1 row)
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    执行了 checkpoint 后发现又是100w条数据,怀疑是从 wal恢复。

    dd命令损坏数据页2

    pgbenchdb=# select pg_walfile_name(pg_current_wal_lsn());
         pg_walfile_name      
    --------------------------
     00000001000000000000005C
    (1 row)
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
  • 相关阅读:
    第二章《Java程序世界初探》第8节:条件运算符
    多线程必知必会的知识点
    JAVA--枚举类
    SQL仓库
    10个Pandas数据查询案例
    车牌识别 支持12种中文车牌类型 车牌数据集下载
    “嵌入式智能化”为医疗设备不断赋能
    C++ Reference: Standard C++ Library reference: C Library: ctime: asctime
    PHP低代码开发平台 V5.0.7新版发布
    使用Python调用Linux下的动态链接库
  • 原文地址:https://blog.csdn.net/ctypyb2002/article/details/118567591