"watchdog" is a sub process of pgpool-II aiming for adding high availability feature to it. Features added by watchdog include:
watchdog monitors responses of pgpool service rather than process. It sends queries to PostgreSQL via pgpool which is being monitored by watchdog and watchdog checks the response. Also watchdog monitors connections to up stream servers (application servers etc.) from the pgpool. The connection between the up stream servers and the pgpool is monitored as service of pgpool.
watchdog processes exchange information on the monitored servers to keep the information up to date, and to allow watchdog processes to mutually monitor each other.
When a fault is detected in the pgpool service, watchdog notifies the other watchdogs of it. Watchdogs decide the new active pgpool if previous active pgpool is broken by voting and change active/standby state.
When a standby pgpool server promotes to active, the new active server brings up virtual IP interface. Meanwhile, the previous active server brings down the virtual IP interface. This enables the active pgpool to work using the same IP address even when servers is switched over.
When broken server recovers or new server is attached, the watchdog process notifies the other watchdog process along with information of the new server, and the watchdog process receives information on the active server and other servers. Then, the attached server is registered as standby.
Figure below describes how pgpool-II and watchdog process is configured.
watchdog process is started/stopped automatically by pgpool-II, therefore there is no dedicated command to start/stop it. However, pgpool-II must to be started with root privilege because watchdog process needs to control the virtual IP interface.
watchdog configuration parameters is described in pgpool.conf. There is sample configuration in WATCHDOG section in pgpool.conf.sample file. All following options are required to be specified in watchdog process.
If on, activates watchdog. Default is off.
The list of trusted servers to check the up stream connections. Each server is required to respond to ping. Specify a comma separated list of servers such as "hostA,hostB,hostC".
Specifies the virtual IP address (VIP) of pgpool-II that is connected from client servers (application servers etc.). When a pgpool is switched from standby to active, the pgpool takes over this VIP.
Specifies the hostname or IP address for mutual monitoring of watchdog processes.
Specifies the port number for mutual monitoring of watchdog processes.
This parameter specifies the interval between life checks of pgpool-II in second. (A number greater than or equal to 1)
This parameter specifies a path of ping command for monitoring connection to the upper servers. Set the only path such as "/bin".
This parameter specifies a path of a command to switch the IP address. Set the only path such as "/sbin".
This parameter specifies a command to bring up the virtual IP. Set the command and parameters such as "ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0". $_IP_$ is replaced by the IP address specified in delegate_IP.
This parameter specifies a command to bring down the virtual IP. Set the command and parameters such as "ifconfig eth0:0 down".
This parameter specifies a path of a command to send an ARP request after the virtual IP is switched. Set the only path such as "/usr/sbin".
This parameter specifies a command to send an ARP request after the virtual IP is switched. Set the command and parameters such as "arping -U $_IP_$ -w 1". $_IP_$ is replaced by the IP address specified in delegate_IP.
The times to retry a failed life check of pgpool-II. (A number greater than or equal to 1)
Actual query to check pgpool-II. Default is "SELECT 1"
Specifies the hostname pgpool-II server to be monitored. The number at the end of the parameter name is referred as "server id", and it starts from 0.
Specifies the port number for pgpool on pgpool-II server to be monitored. The number at the end of the parameter name is referred as "server id", and it starts from 0.
Specifies the port number for watchdog on pgpool-II server to be monitored. The number at the end of the parameter name is referred as "server id", and it starts from 0.