postgresql Postgres 复制:不完整的启动数据包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22648029/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 01:22:18  来源:igfitidea点击:

Postgres Replication: Incomplete Startup Packet

postgresqldatabase-replicationpostgresql-9.3

提问by Kyle

I recently configured PostgreSQL 9.3 hot standby replication between a single master/slave.

我最近在单个主/从之间配置了 PostgreSQL 9.3 热备复制。

I've checked my standby server again today and it looks like it is unable to complete and exit recovery mode on restart:

我今天再次检查了我的备用服务器,它看起来无法完成并在重新启动时退出恢复模式:

2014-03-25 22:36:07 UTC LOG:  entering standby mode
2014-03-25 22:36:07 UTC LOG:  incomplete startup packet
2014-03-25 22:36:07 UTC LOG:  redo starts at 7/E1091840
2014-03-25 22:36:07 UTC LOG:  consistent recovery state reached at 7/E10929C8
2014-03-25 22:36:07 UTC LOG:  record with zero length at 7/E10929C8
2014-03-25 22:36:07 UTC LOG:  started streaming WAL from primary at 7/E1000000 on timeline 1
2014-03-25 22:36:08 UTC FATAL:  the database system is starting up
2014-03-25 22:36:08 UTC FATAL:  the database system is starting up
2014-03-25 22:36:09 UTC FATAL:  the database system is starting up
... more ...
2014-03-25 22:36:13 UTC LOG:  incomplete startup packet

I've tried manually copying over WAL records from the master to the slave and I get the same errors, so I wonder if the WAL records on the master are the problem?

我已经尝试将 WAL 记录从主服务器手动复制到从服务器,但我遇到了同样的错误,所以我想知道主服务器上的 WAL 记录是否有问题?

回答by mullerivan

i solved the same problem re doing

我解决了同样的问题

 psql -c "select pg_start_backup('initial_backup');"
 rsync -cva --inplace --exclude=*pg_xlog* /var/lib/postgresql/9.1/main/ slave_IP_address:/var/lib/postgresql/9.1/main/
 psql -c "select pg_stop_backup();"

here is a good tutorial !!

这是一个很好的教程

回答by Konstantin Popov

I have got the same issue with PostgreSQL 9.4

我在 PostgreSQL 9.4 上遇到了同样的问题

The reason was that in my system postgresql.conf and pg_hba.conf are situated in /etc/postgresql, so they didn't came to standby from master during pg_startbackup

原因是在我的系统中 postgresql.conf 和 pg_hba.conf 位于 /etc/postgresql 中,所以它们在 pg_startbackup 期间没有从 master 进入standby

As a result I has wal_level = hot_standby on master and default wal_level = minimal on standby. This produces the same picture in log.

因此,我在 master 上有 wal_level = hot_standby ,在standby 上有默认的 wal_level = minimum 。这会在日志中生成相同的图片。

My decision was to fix postgresql.conf on standby. After that standby started Ok and said it was ready to accept readonly connections.

我的决定是在备用状态下修复 postgresql.conf。在该备用启动之后,Ok 并说它已准备好接受只读连接。