I'm trying to set up streaming replication on Postgresql 9.5
The master and slave are configured as below and WAL files are accumulating on the master. However, something is wrong as I get complaints that the WAL files are missing:
Slave:
FATAL: could not receive data from WAL stream: ERROR: requested WAL segment 0000000200000059000000BA has already been removed
Master:
repuser@[unknown] ERROR: requested WAL segment 0000000200000059000000BA has already been removed
The WAL file does exist on the master, and the slave will restore happily if I ship the WAL files over and use the restore_command
option in recovery.conf
.
postgres$ ls -l /db/archivedir/0000000200000059000000BA
-rw------- 1 postgres postgres 16777216 Mar 31 10:18 /db/archivedir/0000000200000059000000BA
Master config - postgresql.conf
:
wal_level = hot_standby
archive_mode = on
archive_command = 'test ! -f /db/archivedir/%f && cp %p /db/archivedir/%f'
max_wal_senders = 3
The master also has a replication slot configured:
brp=# SELECT * FROM pg_replication_slots;
slot_name | plugin | slot_type | datoid | database | active | active_pid | xmin | catalog_xmin | restart_lsn
----------+--------+-----------+--------+----------+--------+------------+------+--------------+-------------
brp_uk | | physical | | | f | | | |
Slave - postgresql.conf
:
hot_standby = on
Slave config - recovery.conf
:
standby_mode = on
primary_conninfo = 'host=xxx port=5434 user=repuser password=xxx'
trigger_file = '/tmp/postgresql.trigger.5434'
primary_slot_name = 'brp_uk'
Then the pg_basebackup
is run and the slave started.
The slave has all the data as of the time of the backup, but no new data from the WAL files, and the error above.
What have I mis-configured?