High Availability Integration

In high availability (HA) configurations, the database servers that are being monitored may be moved (“failed over”) to a different host in the event of any problems, such as a hardware failure. There are numerous ways to maintain a backup server using features of Postgres and external tools. Please consult the Postgres documentation for further details.

In order to run in an HA environment, it is recommended that a PEM agent be installed on both the primary host machine, and any secondary machines that may be used as backups. The server is bound to the agent running on the primary host in the normal fashion.

When the clustering solution initiates a failover of Postgres from one server to another, the PEM agent on the server that is taking over the running of the database may be instructed to take over the monitoring of the database server as well. The server must first be configured to allow “takeovers” using the Allow takeover? configuration option on the PEM Agent tab of the server configuration dialogue.

To instruct the agent to takeover the monitoring of a server, the failover process must simply create a file in a special “flag” directory which will instruct the agent to take responsibility for the specified server. A command such as the following could be added to a failover script on a Linux server for example:

touch /tmp/pem/agent-AGENTID/takeover-server-SERVERID where AGENTID is the numeric ID of the agent that should takeover the monitoring of the server, and SERVERID is the numeric ID of the server that should be taken over. The IDs may be found by logging into the PEM client, and selecting the Agent or Server and viewing the ID values on the Properties pane of the main window.

The agent will take over monitoring of the failed-over server within approximately 30 seconds in a standard configuration of PEM.

The flag directory used by the agent is $TMPDIR/pem/agent-AGENTID by default (where $TMPDIR is as set for the user account under which the agent runs, usually root on Linux/Unix, or Administrator on Windows). The directory path can be overridden using the AgentFlagDir configuration option in the registry on Windows, or the agent_flag_dir option in the agent configuration file on other platforms.