Skip to content

Latest commit

 

History

History
53 lines (38 loc) · 1.32 KB

README.md

File metadata and controls

53 lines (38 loc) · 1.32 KB

Docker

Docker is used to run PostgreSQL instances within a container, using a Docker network, and with different host names.

For example "db01" is the primary host, and "db02" is a secondary host. These commands are intended in general to run as shell scripts, from this directory.

sh docker/run_db_db01_primary.sh

sh docker/run_db_db02_replica.sh

docker ps

Disable Docker Messages

export DOCKER_CLI_HINTS=false

Restarting container

pg_ctl: cannot be run as root

docker restart

Replacing pg_hba.conf content

docker cp db01:/var/lib/postgresql/data/pg_hba.conf .
cp pg_hba.conf pg_hba.backup.conf

vim pg_hba.conf
host    replication     replication_user 172.19.0.3/32               md5

docker cp pg_hba.conf db01:/var/lib/postgresql/data/.

docker restart db01

Standby process

  1. Create replication slot
  2. Create pg_hba.conf entries for replication_user. Use the IP address from db02 and db03 /32 version (IPv4)
  3. Make sure there is a standby.signal file
  4. Restart it (should restart in recovery mode)

Docker permissions

  • Run chown and chmod on the .pgpass file
  • Use the postgres user
docker exec --user root -it db02 chown postgres:root /var/lib/postgresql/.pgpass
docker exec --user root -it db02 chmod 0600 /var/lib/postgresql/.pgpass