mhagander / bgw_replstatus Goto Github PK
View Code? Open in Web Editor NEWSmall PostgreSQL background worker to report whether a node is a replication master or standby
License: Other
Small PostgreSQL background worker to report whether a node is a replication master or standby
License: Other
hi everyone.
I try to implement PostgreSQL high availability using bgw_replstatus and haproxy.
according to part of your readme, it said :
automatically switches over to the backup node if the master goes down and the backup is promoted.
but I have an issue when the master instance is down, the slave does not take over/ promoted to master node. here is my environment :
here is my postgresql.conf configuration on master node that I change :
wal_level = hot_standby
archive_mode = on
archive_command = 'test ! -f mnt/server/archivedir/%f && cp %p mnt/server/archivedir/%f'
max_wal_senders = 3
wal_keep_segments = 1000
shared_preload_libraries = 'bgw_replstatus'
here is my postgresql.conf on slave node after pg_basebackup
which I change:
hot_standby = on
and here is my recovery.conf on the slave node
standby_mode = on
primary_conninfo = 'host=[host-ip-source] port=[source-port] user=repuser password=[some-password]'
and here is my haproxy configuration
frontend pgcluster
bind *:5433
mode tcp
default_backend pgcluster
backend pgcluster
mode tcp
balance roundrobin
option tcp-check
tcp-check expect string MASTER
server tm 172.31.32.129:5444 check port 5446
server x2 172.31.18.158:5554 check port 5400 backup
here is the return when I test it using nc [ip-address] [port-bgw_replstatus]
command
when all node is up, the PostgreSQL running well, and I can access it using this command :
psql -h some.domain.to.pgcluster -p 5433 -U postgres
ย
but when the master is down, the slave is not promoted to master/not takeover here is the return :
is there a miss configuration or is there workaround which I can use to implement this high availability for haproxy?
I noticed that @snopoke added some commits to check for replication lag on a standby server. That could be helpful for a haproxy configuration where you just need a somewhat "current" read-only instance.
Do you think integrating these commits makes sense?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.