【问题标题】:Postgres replication not starting due to wal error由于 wal 错误,Postgres 复制未启动
【发布时间】:2015-01-14 09:27:17
【问题描述】:

我在两台服务器上使用 postgres 9.3.2 版,一台主服务器,一台主服务器。

我正在按如下方式设置复制:-

在主人身上:-

  sudo -u postgres psql -c "CREATE USER replicator REPLICATION LOGIN ENCRYPTED PASSWORD 'FOO’;"

编辑 postgresql.conf

listen_address = '*'
wal_level = hot_standby
max_wal_senders = 32 
checkpoint_segments = 8    
wal_keep_segments = 100 

编辑 pg_hba.conf

hostssl replication     replicator      <SLAVE IP>/32        md5

在奴隶上:-

编辑 postgresql.conf

wal_level = hot_standby
max_wal_senders = 3
checkpoint_segments = 8
wal_keep_segments = 8
hot_standby = on

运行

sudo service postgresql stop

sudo -u postgres rm -rf /var/lib/postgresql/9.3/main

sudo -u postgres pg_basebackup -h <MASTER IP> -D /var/lib/postgresql/9.3/main -U replicator -v -P

创建/var/lib/postgresql/9.3/main/recovery.conf

 standby_mode = 'on'
 primary_conninfo = 'host=<MASTER IP> port=5432 user=replicator password=FOO sslmode=require'
 trigger_file = '/tmp/postgresql.trigger'

运行:-

sudo service postgresql restart

当我在从属设备上重新启动 postgres 时,我收到以下错误消息:-

LOG: database system was shut down at 2015-01-14 09:10:50 GMT 2015-01-14 09:11:01 GMT [16741-2] 
LOG: entering standby mode 2015-01-14 09:11:01 GMT [16741-3] WARNING: WAL was generated with wal_level=minimal, data may be missing 2015-01-14 09:11:01 GMT [16741-4] HINT: This happens if you temporarily set wal_level=minimal without taking a new base backup. 2015-01-14 09:11:01 GMT [16741-5] 
FATAL: hot standby is not possible because wal_level was not set to "hot_standby" on the master server 2015-01-14 09:11:01 GMT [16741-6] HINT: Either set wal_level to "hot_standby" on the master, or turn off hot_standby here. 2015-01-14 09:11:01 GMT [16740-1] 
LOG: startup process (PID 16741) exited with exit code 1 2015-01-14 09:11:01 GMT [16740-2] LOG: aborting startup due to startup process failure ... failed!

为什么会这样?我已经检查并重新检查了主 wal_level 是否设置为 hot_standby。在master上运行“show all”显示是这样吗?我不知道我在这里做错了什么。

【问题讨论】:

    标签: postgresql replication


    【解决方案1】:

    您必须再次重新启动主数据库才能让当前 WAL 文件在备用数据库上重播,因为此 WAL 文件是在 wal_level=archive 时生成的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-23
      • 1970-01-01
      相关资源
      最近更新 更多