Sign inSign up

yurinek/postgres_master

By yurinek

•Updated about 6 years ago

Dockerized Postgres Replication Master Database as a service

Image
Databases & storage
0

1.1K

yurinek/postgres_master repository overview

⁠HowTo run container

$ docker network create pgreplication_net

$ docker run -dit --name=postgres_master \
--network=pgreplication_net \
-v master_vol:/data/postgresql/12/rep \
-p 5432:5432 \
yurinek/postgres_master:12

# Connect from host ( default password: mysecret )
$ psql -h localhost -p 5432 -U postgres mydb -W

psql: error: connection to server at "localhost" (::1), port 5432 failed: FATAL: no pg_hba.conf entry for host "192.168.65.1", user "postgres", database "mydb"

# if the above error happens, db access from local ip needs to be granted
docker container exec -it postgres_master su - postgres -c "echo 'host all all 192.168.65.1/32 md5' >>/etc/postgresql/12/rep/pg_hba.conf"
docker container exec -it postgres_master su - postgres -c "/usr/bin/pg_ctlcluster 12 rep reload".

⁠Customize database, password and master container name

$ export RUNTIME_ENV_PG_DB=yourdb
$ export POSTGRES_PASSWORD=yoursecret
$ export RUNTIME_ENV_MASTER_HOST=yourcontainername

$ docker run -dit --name=$RUNTIME_ENV_MASTER_HOST \
--network=pgreplication_net \
-e RUNTIME_ENV_PG_DB=$RUNTIME_ENV_PG_DB \
-e POSTGRES_PASSWORD=$POSTGRES_PASSWORD \
-v master_vol:/data/postgresql/12/rep \
-p 5432:5432 \
yurinek/postgres_master:12

# Connect from host
$ psql -h localhost -p 5432 -U postgres $RUNTIME_ENV_PG_DB -W

# Slave db expects the master container name to be $RUNTIME_ENV_MASTER_HOST.
# It's default value is "postgres_master". See yurinek/postgres_slave⁠
# If used as a standalone master any name can be used.

⁠Kubernetes

For Kubernetes tag 12_k8s can be used

Tag summary

Content type

Image

Digest

Size

113.6 MB

Last updated

over 6 years ago

docker pull yurinek/postgres_master