I want to achieve Docker Postgres Volume Replication , Failover and load balancing with zero down time high availability of PostgreSQL.
When I using bitnami/postgres-repmgr in docker swarm environment setup like
One Manager node
• Manager IP: 192.168.1.10
Two Worker nodes
• Worker1 IP: 192.168.1.11
• Worker2 IP: 192.168.1.12
version: '3.8'
services:
pg-0:
image: bitnami/postgresql-repmgr:15
ports:
- 5050:5432
volumes:
- pg_0_data:/bitnami/postgresql
environment:
- POSTGRESQL_POSTGRES_PASSWORD=adminpassword
- POSTGRESQL_USERNAME=customuser
- POSTGRESQL_PASSWORD=custompassword
- POSTGRESQL_DATABASE=customdatabase
- REPMGR_PASSWORD=repmgrpassword
- REPMGR_PRIMARY_HOST=pg-0
- REPMGR_PRIMARY_PORT=5432
- REPMGR_PARTNER_NODES=pg-0,pg-1:5432
- REPMGR_NODE_NAME=pg-0
- REPMGR_NODE_NETWORK_NAME=pg-0
- REPMGR_PORT_NUMBER=5432
pg-1:
image: bitnami/postgresql-repmgr:15
ports:
- 5051:5432
volumes:
- pg_1_data:/bitnami/postgresql
environment:
- POSTGRESQL_POSTGRES_PASSWORD=adminpassword
- POSTGRESQL_USERNAME=customuser
- POSTGRESQL_PASSWORD=custompassword
- POSTGRESQL_DATABASE=customdatabase
- REPMGR_PASSWORD=repmgrpassword
- REPMGR_PRIMARY_HOST=pg-0
- REPMGR_PRIMARY_PORT=5432
- REPMGR_PARTNER_NODES=pg-0,pg-1:5432
- REPMGR_NODE_NAME=pg-1
- REPMGR_NODE_NETWORK_NAME=pg-1
- REPMGR_PORT_NUMBER=5432
volumes:
pg_0_data:
driver: local
pg_1_data:
driver: local
I am facing the below Problems, when I am running above docker compose file.
- I couldn’t achieve high availability and load balancing.
- How can I call common ip and port postgres database
• Primary node port – 5050
• Replica node port - 5051 - If primary database goes down, how to handle the situation for downtime if it possible or not.
- I want to achieve zero downtime without data losing, if it possible or not.
kindly could give me solution as soon as possible