4

I'm attempting to set up a 3-server chain by leveraging WAL-E. I've done this in the past with replication/wal segments and I'm attempting the exact same method, just with using WAL-E in between.

My replication from a -> b is working perfectly through WAL-E. I specify the S3 bucket and access information and a uploads to S3, and b pulls down segments it may need if streaming falls behind.

I'm having an issue trying to get b to upload segments to S3 for use by server c. I've updated my postgresql.conf on b to be:

wal_level = hot_standby
checkpoint_segments = 10
archive_mode = on
archive_command = '/etc/postgresql/9.2/main/local_backup_script.sh "%p" "%f"'
archive_timeout = 3600
max_wal_senders = 5
wal_keep_segments = 4096
hot_standby = on

My local_backup_script.sh is as follows:

#!/bin/bash
echoerr() { echo "$@" 1>&2; }
FAIL=0
`envdir /etc/wal-e.d/env-rep-a /usr/local/bin/wal-e wal-push 1ドル` & pid_1=$!
echoerr "Spawned replication process $pid_1"
wait $pid_1 || let "FAIL+=1"
if [ "$FAIL" == "0" ];
then
echoerr "Replication success 1ドル 2ドル"
else
echoerr "Replication failed 1ドル 2ドル"
fi
exit "$FAIL"

I am using a different S3 bucket from b -> c so they don't step on each other. I've also verified that wal-e upload works to this bucket by manually calling the script from the pg_xlog directory.

But postgresql NEVER executes archive_command, and I'm not at a loss as to why. I even just tried to print something to STDERR (so it goes to the log), nothing.

Few other points: 1) /var/lib/postgresql/9.2/archive directory is empty (on b) 2) the script permissions have been set properly (owned by postgres and chmod +x)

Anyone have any suggestions on what may be wrong?

asked Feb 21, 2014 at 21:46

1 Answer 1

2

Streaming replicas don't run archive_command because they do not generate WAL. They just replay the master server's WAL.

You can cascade streaming replicas, where one replica acts as a master for the next. But for fallback WAL archiving they both use the master's WAL stream directly.

So just configure the second replica to use the master's WAL stream.

answered Feb 25, 2014 at 0:01
2
  • Under this system, what do u recommend to do if the master fails and the first replica gets promoted? Would that second server just start writing wal segments to S3 (so, run the archive_command)? Commented May 7, 2014 at 22:14
  • Yes, it would, so if you're possibly promoting servers you'll want archive_command configured. Commented May 8, 2014 at 1:07

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.