• PGSQL invalid primary checkpoint record 的修复


    最近又遇到这个错误,这种情况一般都是由于客户服务器断电等原因导致的, 因此网上搜索一堆修复方法, 总结了后, 打算写在这里, 由于我们的pgsql是运行在容器内, 因此这里写的命令均是容器内可以执行的。 

    下面是遇到的错误:

    pgsql | 2020-01-18 16:14:06.418 CST [25] LOG: invalid primary checkpoint record

    pgsql | 2020-01-18 16:14:06.418 CST [25] PANIC: could not locate a valid checkpoint record

    如果在容器中, 使用下面命令进行挂载数据库 并执行命令行, 方便与我们执行后面的命令。 registry.uixe.net/images/postgres 是我的内网镜像地址,因此如果公网, 或者你自己私有镜像, 请替换为可用的 镜像名称。 

    docker run -it  -v /dbdata/postgresql:/var/lib/postgresql/data  registry.uixe.net/images/postgres   /bin/bash

    使用su  切换至postgres用户便于执行 pg_resetwal 

    su postgres

    pg_resetwal -f /var/lib/postgresql/data

    如果遇到

    pg_resetwal: error: lock file "postmaster.pid" exists

    pg_resetwal: Is a server running?  If not, delete the lock file and try again

    这种问题一般都是因为断电后, 没能来得及删掉进程导致的, 所以, 只能删除。 否则程序以为自己依然在运行状态。  

    删除命令如下:

     rm /var/lib/postgresql/data/postmaster.pid

    然后回过头来再执行 

    pg_resetwal -f /var/lib/postgresql/data

    重启后, 完美解决 。 应用正常运转。 

  • 相关阅读:
    正则表达式判断手机号是否11位
    php-流程管理(发起流程和审核流程)
    php-流程管理(新建流程)(php+Ajax)
    php-人员权限管理(RBAC)
    状态压缩DP
    树形DP
    Broken Keyboard UVA 11988 数组实现链表
    Trees in a Wood UVA
    POJ1061 青蛙的约会 拓展欧几里得
    UVA10215The Largest/Smallest Box(小数精度)
  • 原文地址:https://www.cnblogs.com/MysticBoy/p/13066420.html
Copyright © 2020-2023  润新知