]> git.8kb.co.uk Git - slony-i/pgbouncer_follower/blob - README.md
Add support for auth_user and ensure nodes currently being cloned are never used.
[slony-i/pgbouncer_follower] / README.md
1 #PgBouncer Slony-I replication set follower
2
3 This script is a command-line utility to monitor the nodes in a Slony-I cluster 
4 and reconfigure pgbouncer to follow an origin or subscriber of replication sets.
5
6 The idea is pretty simple; periodically poll the slony schema to identify origin 
7 and subscriber nodes and repoint an existing pgbouncer instance to follow either 
8 the origin for read-write or a subscriber for read-only operation.  The script 
9 takes a template pgbouncer.ini file containing all the desired settings except 
10 for the target database and will write a copy with the target database and reload 
11 pgbouncer.  In 'ro' mode the script will try and choose a subscriber node  closest 
12 to pgbouncer host if IPv4 addressing has been used for the slony conninfos.
13
14 ##Example usage
15
16 The script can be either run on a schedule or as a daemon with the "D" flag:
17
18 ```bash
19 $ pgbouncer_follower.pl -f <config file> [-D]
20 ```
21
22 To run as a daemon in debian:
23
24 ```bash
25 $ sudo cp init.debian /etc/init.d/pgbouncer_follower_rw
26 $ cp pgbouncer_follower.pl /var/slony/pgbouncer_follower/pgbouncer_follower.pl 
27 $ cp pgbouncer_follower_rw.conf /var/slony/pgbouncer_follower/pgbouncer_follower_rw.conf 
28 $ sudo chmod +x /etc/init.d/pgbouncer_follower_rw
29 $ sudo update-rc.d pgbouncer_follower_rw start 99 2 3 4 5 . stop 24 0 1 6
30 $ sudo invoke-rc.d pgbouncer_follower_rw start
31 ```
32
33 ##Configuration options
34
35 | Section   | Parameter              | Type    | Default                                     | Comment
36 |:----------|:-----------------------|:--------|:--------------------------------------------|:-----------------------------------
37 | Slony     | slony_user             | text    | *'slony'*                                   | Username used to connect to PostgreSQL and select from slony schema tables
38 | Slony     | slony_pass             | text    | *''*                                        | Recommended to leave blank and use .pgpass file
39 | Slony     | slony_cluster_name     | text    | *'replication'*                             | Name of slony cluster (without leading underscore of schema name)
40 | Slony     | server_conninfo        | text    | *null*                                      | Conninfo string for slony a node, can be specified multiple times
41 | pgBouncer | debug                  | boolean | *false*                                     | Churn out debugging info to log file / stdout
42 | pgBouncer | follower_poll_interval | integer | *1000*                                      | Interval to poll slony cluster state when in daemon mode
43 | pgBouncer | sets_to_follow         | text    | *1*                                         | Comma separated list of sets to follow or 'all' to follow all sets
44 | pgBouncer | pool_mode              | 'ro/rw' | *'rw'*                                      | Select a read-only subscriber or the origin for read-write
45 | pgBouncer | pool_all_databases     | boolean | *'false'*                                   | If true uses wildcard for database name in pgbouncer.ini, false uses slony database
46 | pgBouncer | auth_user              | text    | *''*                                        | If set auth_user will be appended to conninfo written in [databases] section
47 | pgBouncer | only_follow_origins    | boolean | *'false'*                                   | If true pgbouncer will only be reconfigured and reloaded when sets move origin
48 | pgBouncer | status_file            | text    | *'/tmp/pgbouncer_follower_%mode.status'*    | File used to store a hash depicting the state of the cluster
49 | pgBouncer | log_file               | text    | *'/tmp/pgbouncer_follower_%mode.log'*       | Log file for the script
50 | pgBouncer | pid_file               | text    | *'/tmp/pgbouncer_follower_%mode.log'*       | PID file for the script when run as a daemon
51 | pgBouncer | pool_conf_template     | text    | *'/etc/pgbouncer/pgbouncer_%mode.template'* | Template pgbouncer.ini file with your settings and a blank [databases] section
52 | pgBouncer | pool_conf_target       | text    | *'/etc/pgbouncer/pgbouncer_%mode.ini'*      | Target pgbouncer.ini file to write a copy of pool_conf_template with a [databases] section to
53 | pgBouncer | pool_reload_command    | text    | *'/etc/init.d/pgbouncer_%mode reload"'*     | System command to execute to reload pgbouncer instance
54 | pgBouncer | max_ro_lag             | integer | *0*                                         | Maximum lag in seconds allowed for subscriber nodes when running in ro mode. 0 = don't monitor lag.
55
56 The status_file, log_file, pid_file, pool_conf_template, pool_conf_target and 
57 pool_reload_command parameters can contain the following special values:
58
59     %mode - Pool Mode
60     %clname - Slony cluster name