- Notifications
You must be signed in to change notification settings - Fork1.2k
PostgreSQL error ( log Docker)#1250
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I'm running two replicated databases with Docker and tried to add a load balancer (HAProxy), but every time I do docker compose up, I get the following log:
My Docker Compose file is structured like this: services:pg_primary:image:postgres:16user:postgresrestart:alwayshealthcheck:test:'pg_isready -U user --dbname=postgres'interval:10stimeout:5sretries:5ports: -5432:5432environment:POSTGRES_USER:userPOSTGRES_PASSWORD:passwordPOSTGRES_HOST_AUTH_METHOD:"scram-sha-256\nhost replication all 0.0.0.0/0 md5"POSTGRES_INITDB_ARGS:"--auth-host=scram-sha-256"command:| postgres -c wal_level=replica -c hot_standby=on -c max_wal_senders=10 -c max_replication_slots=10 -c hot_standby_feedback=onvolumes: -${PWD}/00_init.sql:/docker-entrypoint-initdb.d/00_init.sql:ropg_replica:image:postgres:16user:postgresrestart:alwayshealthcheck:test:'pg_isready -U user --dbname=postgres'interval:10stimeout:5sretries:5ports: -5433:5432environment:PGUSER:replicatorPGPASSWORD:replicator_passwordcommand:| bash -c " until pg_basebackup --pgdata=/var/lib/postgresql/data -R --slot=replication_slot --host=pg_primary --port=5432 do echo 'Waiting for primary to connect..' sleep 1s done echo 'Backup done, starting replica...' chmod 0700 /var/lib/postgresql/data postgres "depends_on: -pg_primarypgadmin:image:dpage/pgadmin4restart:alwaysports: -8080:80environment:PGADMIN_DEFAULT_EMAIL:admin@example.comPGADMIN_DEFAULT_PASSWORD:admindepends_on: -pg_primary -pg_replicahaproxy:image:haproxy:2.5restart:alwaysports: -5434:5432volumes: -./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:rodepends_on: -pg_primary -pg_replicaentrypoint:["sh", "-c", "sleep 10 && haproxy -f /usr/local/etc/haproxy/haproxy.cfg"] |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment 3 replies
-
It looks like |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
my haproxy configuration look like this: global log stdout format raw local0 maxconn4096defaults log global mode tcp option tcplog timeout connect10s timeout client1m timeout server1mfrontendpgsql_frontend bind *:5432 default_backend pgsql_backendbackendpgsql_backend balance roundrobin option httpchk server pg_primary pg_primary:5432 check server pg_replica pg_replica:5432 check |
BetaWas this translation helpful?Give feedback.
All reactions
-
I saw another error in the logs; when HAProxy starts, this happens: haproxy-1 | Server pgsql_backend/pg_primary is DOWN, reason: Layer7 invalid response, check duration: 3ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Ok, the issue is that postgres doesn't recognize the "check" data that haproxy sends during its check. Can you try the following In your db init CREATEUSERstandbyuser WITH PASSWORD'standbyuser'; Haproxy config:
|
BetaWas this translation helpful?Give feedback.
All reactions
This discussion was converted from issue #1249 on June 18, 2024 21:43.