Skip to content

Instantly share code, notes, and snippets.

@codesenju
Last active May 18, 2020 19:07
Show Gist options
  • Save codesenju/7266efa630865c7ab3ee47bf74e70d96 to your computer and use it in GitHub Desktop.
Save codesenju/7266efa630865c7ab3ee47bf74e70d96 to your computer and use it in GitHub Desktop.
docker_setup_replication
# configure postgresql for real-time replication
docker_setup_replication() {
psql -U postgres -c "CREATE USER replicator WITH REPLICATION ENCRYPTED PASSWORD 'passw0rd';" && \
psql -U postgres -c "ALTER SYSTEM SET listen_addresses TO '*'" && \
psql -U postgres -c "alter system set wal_level = replica ;" && \
psql -U postgres -c "alter system set max_wal_senders = 18;" && \
psql -U postgres -c "alter system set hot_standby = on;" && \
echo host replication replicator 0.0.0.0/0 trust >> "$PGDATA/pg_hba.conf"
echo "User Replicator added!"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment