You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PostgreSQL 13.6主从复制执行pg_basebackup时连接中断求助

PostgreSQL 13.6主从架构pg_basebackup连接频繁中断问题求助

我们采用PostgreSQL 13.6主从架构,执行pg_basebackup命令从主库获取文件以启动复制时,连接频繁中断。搜索相关错误未找到原因,日志也未提供有效线索。

使用的初始命令及错误

命令:

pg_basebackup -h MASTER_IP -U postgres --checkpoint=fast  -D /var/lib/pgsql/13/data/ -R

错误输出:

This probably means the server terminated abnormally
        before or while processing the request.
pg_basebackup: removing data directory /var/lib/pgsql/13/data

主库pg_hba.conf配置

local all all trust

# IPv4 local connections:
host    all             all             0.0.0.0/0           md5

host replication all 0.0.0.0/0 trust
host postgres all 0.0.0.0/0 trust
host all all 0.0.0.0/0 trust
host replication all 0.0.0.0/0 trust

# replication privilege.
host  replication postgres SLAVE_IP/32 md5
host replication replication SLAVE_IP/32 md5
-bash-4.2$

已尝试的操作及对应结果

  • 添加端口参数的命令,执行后仍报错:

    pg_basebackup -h MASTER_IP -p 5432 -U postgres -D /var/lib/pgsql/13/data/ -Fp -Xs -R --checkpoint=fast
    

    从库输出错误:

    FATAL: terminating connection due to administrator command error: could not read COPY data: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
    
  • 使用tar选项的命令,依旧报错:

    pg_basebackup -h MASTER_IP -p 5432 -U postgres -Ft  --checkpoint=fast -z  --wal-method=none -D - > /var/lib/pgsql/13/data_1/backup.tar
    

    对应错误输出:

    pg_basebackup: error: could not read COPY data: server closed the connection unexpectedly
            This probably means the server terminated abnormally
            before or while processing the request.
    

补充检查信息

  • 检查主库PostgreSQL目录,未发现root组所属文件:
    [root@master01 data]#  find /var/lib/pgsql/13/data/ -group root
    [root@master01 data]# 
    
  • 主库日志仅记录:
    STATEMENT:  BASE_BACKUP LABEL 'pg_basebackup base backup' PROGRESS  FAST NOWAIT    MANIFEST 'yes'   
    

恳请各位帮忙排查原因。


内容的提问来源于stack exchange,提问作者1010111100011

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 19:25:20