Skip to content

Commit

Permalink
Support WAL shipping through WAL-e, remove the obsolete ETCD_ADDRESS …
Browse files Browse the repository at this point in the history
…parameter in favor of discovery URL.
  • Loading branch information
alexeyklyukin committed May 13, 2015
1 parent fb0f624 commit adad58f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
5 changes: 2 additions & 3 deletions postgres-appliance/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ RUN usermod -d /home/postgres -m postgres

# install WAL-e
RUN apt-get install build-essential -y
RUN apt-get install python-pip -y
RUN apt-get install python-dev libxml2-dev libxslt-dev libffi-dev lzop pv -y
RUN apt-get install python-pip python-dev libxml2-dev libxslt-dev libffi-dev lzop pv daemontools -y
RUN pip install six --upgrade
RUN pip install wal-e

Expand All @@ -49,9 +48,9 @@ ADD postgres_ha.sh /home/postgres/
RUN chown postgres:postgres /home/postgres/postgres_ha.sh
RUN chmod 700 /home/postgres/postgres_ha.sh

ENV ETCD_ADDRESS=""
ENV ETCD_DISCOVERY_URL postgres.acid.example.com
ENV SCOPE test
ENV WAL_S3_BUCKET spilo-example-com
ENV DEBUG 0
# run subsequent commands as user postgres
USER postgres
Expand Down
21 changes: 13 additions & 8 deletions postgres-appliance/postgres_ha.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

PATH=$PATH:/usr/lib/postgresql/${PGVERSION}/bin
WALE_ENV_DIR=/home/postgres/etc/wal-e.d/env

function write_postgres_yaml
{
Expand Down Expand Up @@ -28,31 +29,35 @@ postgresql:
parameters:
archive_mode: "on"
wal_level: hot_standby
archive_command: /bin/true
archive_command: "envdir ${WALE_ENV_DIR} wal-e --aws-instance-profile wal-push \"%p\" -p 1"
max_wal_senders: 5
wal_keep_segments: 8
archive_timeout: 1800s
max_replication_slots: 5
hot_standby: "on"
recovery_conf:
restore_command: "envdir ${WALE_ENV_DIR} wal-e --aws-instance-profile wal-fetch \"%f\" \"%p\" -p 1"
__EOF__
}

function write_archive_command_environment
{
mkdir -p ${WALE_ENV_DIR}
echo "s3://${WAL_S3_BUCKET}/spilo/${SCOPE}/wal/" > ${WALE_ENV_DIR}/WALE_S3_PREFIX
}

# get governor code
git clone https://github.com/zalando/governor.git

write_postgres_yaml

write_archive_command_environment

# start etcd proxy
# for the -proxy on TDB the url of the etcd cluster
[ "$DEBUG" -eq 1 ] && exec /bin/bash

if [[ -n $ETCD_ADDRESS ]]
then
# address is still useful for local debugging
etcd -name "proxy-$SCOPE" -proxy on -bind-addr 127.0.0.1:8080 --data-dir=etcd -initial-cluster $ETCD_ADDRESS &
else
etcd -name "proxy-$SCOPE" -proxy on -bind-addr 127.0.0.1:8080 --data-dir=etcd -discovery-srv $ETCD_DISCOVERY_URL &
fi
etcd -name "proxy-$SCOPE" -proxy on -bind-addr 127.0.0.1:8080 --data-dir=etcd -discovery-srv $ETCD_DISCOVERY_URL &

exec governor/governor.py "/home/postgres/postgres.yml"

Expand Down

0 comments on commit adad58f

Please sign in to comment.