I have a primary server that archives (and gzips) WAL files into /wal/archive/
. At the moment, I'm attempting to set up a hot standby with streaming replication from a base backup.
When starting up the standby, I noticed it was producing errors such as:
could not receive data from WAL stream: ERROR: requested WAL segment 000000010000142400000014 has already been removed
This makes sense, as it's been around a day since the base_backup was taken, and the WAL files have already been archived. I provided a restore_command
in the standby server's recovery.conf
to scp the file over from the primary and unzip it:
restore_command = '(set -o pipefail; scp primary_ip:/wal/archive/%f.gz /dev/stdout | pigz -d > "%p")'
Strangely, the same errors kept appearing. Keep in mind, I have tested the above command works when I run it and provide a file. I wanted to see if the command was actually being run, so I added an echo:
restore_command = '(set -o pipefail; echo "%f" >> /data/test.txt && scp primary_ip:/wal/archive/%f.gz /dev/stdout | pigz -d > "%p")'
I can clearly see it is not running the command as /data/test.txt is not being created. The postgres
user has permission to write to /data/
. Is there something that needs to be specified on the standby to instruct it to use restore_command
when the primary has already archived a WAL file?
My recovery.conf file has been set up according to section 25.2.4 of the docs.