Last active
February 22, 2016 17:42
-
-
Save anhkind/0eca34847dbcee2c6118 to your computer and use it in GitHub Desktop.
Create a Postgres replication cluster using Docker image from sameersbn/postgresql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HOST=localhost | |
STORAGE_PATH=~/srv/docker/postgresql | |
DUMP_FILE_PATH=/path/to/dump/file | |
docker run --name postgresql-master -itd --restart always \ | |
--publish 5433:5432 \ | |
--volume $STORAGE_PATH/postgresql-master:/var/lib/postgresql \ | |
--env 'PG_PASSWORD=passw0rd' \ | |
--env 'DB_USER=dbuser' --env 'DB_PASS=dbuserpass' --env 'DB_NAME=dbname' \ | |
--env 'REPLICATION_USER=repluser' --env 'REPLICATION_PASS=repluserpass' \ | |
sameersbn/postgresql:9.4-13 | |
docker run --name postgresql-slave01 -itd --restart always \ | |
--link postgresql-master:master \ | |
--publish 5434:5432 \ | |
--volume $STORAGE_PATH/postgresql-slave01:/var/lib/postgresql \ | |
--env 'PG_PASSWORD=passw0rd' \ | |
--env 'REPLICATION_MODE=slave' --env 'REPLICATION_SSLMODE=prefer' \ | |
--env 'REPLICATION_HOST=master' --env 'REPLICATION_PORT=5432' \ | |
--env 'REPLICATION_USER=repluser' --env 'REPLICATION_PASS=repluserpass' \ | |
sameersbn/postgresql:9.4-13 | |
pg_restore --verbose --clean --no-acl --no-owner -h $HOST -p 5433 -U dbuser -d dbname $DUMP_FILE_PATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment