mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 16:46:28 +00:00
Note use of phbouncer %include directive
This commit is contained in:
@@ -22,15 +22,14 @@ of this document).
|
|||||||
|
|
||||||
* * *
|
* * *
|
||||||
|
|
||||||
In a failover situation, `repmgrd` promotes a standby to master by
|
In a failover situation, `repmgrd` promotes a standby to master by executing
|
||||||
executing the command defined in `promote_command`. Normally this
|
the command defined in `promote_command`. Normally this would be something like:
|
||||||
would be something like:
|
|
||||||
|
|
||||||
repmgr standby promote -f /etc/repmgr.conf
|
repmgr standby promote -f /etc/repmgr.conf
|
||||||
|
|
||||||
By wrapping this in a custom script which adjusts the `pgbouncer`
|
By wrapping this in a custom script which adjusts the `pgbouncer` configuration
|
||||||
configuration on all nodes, it's possible to fence the failed master
|
on all nodes, it's possible to fence the failed master and redirect write
|
||||||
and redirect write connections to the new master.
|
connections to the new master.
|
||||||
|
|
||||||
The script consists of three sections:
|
The script consists of three sections:
|
||||||
|
|
||||||
@@ -38,20 +37,19 @@ The script consists of three sections:
|
|||||||
* the promotion command itself
|
* the promotion command itself
|
||||||
* commands to reconfigure and restart `pgbouncer` on all nodes
|
* commands to reconfigure and restart `pgbouncer` on all nodes
|
||||||
|
|
||||||
Note that it requires password-less SSH access between all nodes to be
|
Note that it requires password-less SSH access between all nodes to be able to
|
||||||
able to update the `pgbouncer` configuration files.
|
update the `pgbouncer` configuration files.
|
||||||
|
|
||||||
For the purposes of this demonstration, we'll assume there are 3 nodes
|
For the purposes of this demonstration, we'll assume there are 3 nodes (master
|
||||||
(master and two standbys), with `pgbouncer` listening on port 6432
|
and two standbys), with `pgbouncer` listening on port 6432 handling connections
|
||||||
handling connections to a database called `appdb`. The `postgres`
|
to a database called `appdb`. The `postgres` system user must have write
|
||||||
system user must have write access to the `pgbouncer` configuration
|
access to the `pgbouncer` configuration files on all nodes. We'll assume
|
||||||
file on all nodes, assumed to be at `/etc/pgbouncer.ini`.
|
there's a main `pgbouncer` configuration file, `/etc/pgbouncer.ini`, which uses
|
||||||
|
the `%include` directive (available from PgBouncer 1.6) to include a separate
|
||||||
|
configuration file, `/etc/pgbouncer.database.ini`, which will be modified by
|
||||||
|
`repmgr`.
|
||||||
|
|
||||||
The script also requires a template file containing global `pgbouncer`
|
`/etc/pgbouncer.ini` should look something like this:
|
||||||
configuration, which should looks something like this (adjust
|
|
||||||
settings appropriately for your environment):
|
|
||||||
|
|
||||||
`/var/lib/postgres/repmgr/pgbouncer.ini.template`
|
|
||||||
|
|
||||||
[pgbouncer]
|
[pgbouncer]
|
||||||
|
|
||||||
@@ -80,6 +78,8 @@ settings appropriately for your environment):
|
|||||||
log_disconnections = 1
|
log_disconnections = 1
|
||||||
log_pooler_errors = 1
|
log_pooler_errors = 1
|
||||||
|
|
||||||
|
%include /etc/pgbouncer.database.ini
|
||||||
|
|
||||||
The actual script is as follows; adjust the configurable items as appropriate:
|
The actual script is as follows; adjust the configurable items as appropriate:
|
||||||
|
|
||||||
`/var/lib/postgres/repmgr/promote.sh`
|
`/var/lib/postgres/repmgr/promote.sh`
|
||||||
|
|||||||
Reference in New Issue
Block a user