Skip to content

Commit

Permalink
Merge pull request #11 from zalando/feature/exhibitor
Browse files Browse the repository at this point in the history
Feature/exhibitor
  • Loading branch information
Oleksii Kliukin committed Jul 13, 2015
2 parents f630a04 + 12f503f commit b4e6e4d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
5 changes: 4 additions & 1 deletion postgres-appliance/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ RUN pip install requests --upgrade
RUN pip install six --upgrade
RUN pip install wal-e

ENV ETCDVERSION 2.0.11
# Install kazoo for ZooKeeper
RUN pip install kazoo

ENV ETCDVERSION 2.0.13
# install etcd
RUN apt-get install curl -y
RUN curl -L https://github.com/coreos/etcd/releases/download/v${ETCDVERSION}/etcd-v${ETCDVERSION}-linux-amd64.tar.gz | tar xz -C /bin --strip=1 --wildcards --no-anchored etcd etcdctl
Expand Down
42 changes: 36 additions & 6 deletions postgres-appliance/postgres_ha.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,47 @@ function write_postgres_yaml
local aws_private_ip=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)
local pg_port=5432
local api_port=8008
local etcd_client_port=2379

cat >> postgres.yml <<__EOF__
loop_wait: 10
ttl: &ttl 30
loop_wait: &loop_wait 10
scope: &scope $SCOPE
restapi:
listen: 0.0.0.0:${api_port}
connect_address: ${aws_private_ip}:${api_port}
__EOF__

if [[ -n $ZOOKEEPER_HOSTS || -n $EXHIBITOR_HOSTS && -n $EXHIBITOR_PORT ]]; then
cat >> postgres.yml <<__EOF__
zookeeper:
scope: *scope
session_timeout: *ttl
reconnect_timeout: *loop_wait
__EOF__

[[ -n $ZOOKEEPER_HOSTS ]] && echo " hosts: ${ZOOKEEPER_HOSTS}" >> postgres.yml

if [[ -n $EXHIBITOR_HOSTS && -n $EXHIBITOR_PORT ]]; then
cat >> postgres.yml <<__EOF__
exhibitor:
poll_interval: 300
port: ${EXHIBITOR_PORT}
hosts: ${EXHIBITOR_HOSTS}
__EOF__
fi
elif [[ -n $ETCD_DISCOVERY_DOMAIN ]]; then
cat >> postgres.yml <<__EOF__
etcd:
scope: $SCOPE
ttl: 30
scope: *scope
ttl: *ttl
discovery_srv: ${ETCD_DISCOVERY_DOMAIN}
__EOF__
else
>&2 echo "Can not find suitable distributed configuration store."
exit 1
fi

cat >> postgres.yml <<__EOF__
postgresql:
name: postgresql_${HOSTNAME}
listen: 0.0.0.0:${pg_port}
Expand Down Expand Up @@ -67,11 +97,11 @@ function write_archive_command_environment
echo "s3://${WAL_S3_BUCKET}/spilo/${SCOPE}/wal/" > ${WALE_ENV_DIR}/WALE_S3_PREFIX
}

write_postgres_yaml

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

write_postgres_yaml

write_archive_command_environment

# run wal-e s3 backup periodically
Expand Down

0 comments on commit b4e6e4d

Please sign in to comment.