There are two ways to try.
Method 1
Use JDBC connect the PostgreSQL cluster (primary, standby 2 servers only):
jdbc:postgresql://192.168.0.1:5432,192.168.0.2:5432/jiradb
But failed:
The configuration of your dbconfig.xml file is incorrect (user, password, or database URL etc.)
How to connect multiple servers from jdbc?
Method 2
Use pgbouncer
and repmgr
Three servers:
- pgbouncer
- PostgreSQL Primary (192.168.0.1) Installed repmgr, running repmgrd
- PostgreSQL Standby (192.168.0.2) Installed repmgr, running repmgrd
Set config in pgbouncer server(pgbouncer.ini):
[databases]
postgres = host=192.168.0.1 port=5432 dbname=postgres
postgres = host=192.168.0.2 port=5432 dbname=postgres
[pgbouncer]
listen_port = 6432
listen_addr = *
auth_type = md5
auth_file = userlist.txt
logfile = pgbouncer.log
pidfile = pgbouncer.pid
admin_users = postgres
unix_socket_dir = /tmp
When primary down, repmgr can switch to standby server as primary. But pgbouncer didn't automatic connect the second db server. Why? The config setting for databases
does not work. Is it the wrong usage? Or pgbouncer doesn't has this automatic switch feature?