Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
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)? –  Geesu May 7 at 22:14
    
Yes, it would, so if you're possibly promoting servers you'll want archive_command configured. –  Craig Ringer May 8 at 1:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.