How To Set Up An Active/Passive PostgreSQL Cluster With Pacemaker, Corosync, And DRBD (CentOS 5.5) - Page 4

This article explains how to set up (and monitor) an Active/Passive PostgreSQL Cluster, using Pacemaker with Corosync and DRBD. Prepared by Rafael Marangoni, from BRLink Servidor Linux Team.

8. Creating Webpage to show status

This configuration is very usefull to quickly check the cluster status. Must be runned on both nodes.

Start apache (if it's not running):

/etc/init.d/httpd start
chkconfig --level 35 httpd on

Create a cluster directory (under the DocumentRoot):

mkdir /var/www/html/cluster/

To generate the html, do:

crm_mon --daemonize --as-html /var/www/html/cluster/index.html

Let's put on rc.local to automatically run on startup:

 echo "crm_mon --daemonize --as-html /var/www/html/cluster/index.html" >> /etc/rc.d/rc.local 

To access, points your browser to


9. Installing phppgadmin to manage postgres

It's very simple. Remenber to do this on both nodes:

First, download it:

mkdir /download
cd /download
wget ''

Then, install:

tar -jxvf phpPgAdmin-5.0-beta2.tar.bz2
mv phpPgAdmin-5.0-beta2 /var/www/html/cluster-pgadmin
chown apache.apache -R /var/www/html/cluster-pgadmin

To access, points you browser to:
PS: Use admpgsql as user and the password that you configured to logon


10. Acessing from network

If you need to access postgres from LAN, don't forget to configure authentication on postgres:

Here, we'll set md5 authentication to network In the node that postgresql in running, do:

echo "host all all md5">> /var/lib/pgsql/data/pg_hba.conf

Then, restart postgres to reload configuration:

crm resource stop postgresql
crm resource start postgresql


11. Monitoring

Cluster monitoring is mandatory on production scenarios. To make this work with Zabbix, we suggests that you install Zabbix agent on every node.
Then monitor on every node, these items::

  •   Check Local Ping (, and,
  •   Check DBIP (Cluster IP)
  •   Check Postgres TCP Port (5432) on DBIP
  •   General checks, like disk use, memory, processor
  •   Use the following (and very simple) script called (that returns 1, when everything is ok, and 0 when got problems.)

Here goes the to use with Zabbix:


CHECK=`cat /proc/drbd | grep UpToDate/UpToDate | cut -d: -f5 | cut -c1-17`

# Comparando as duas.
if [ "$CHECK" == "$STRING_OK" ] ; then
	# Is ok, returning 1
	echo 1;
	# Not ok, returning 0
	echo 0;



Pacemaker and DRBD:
DRBD User Guide:
HowTO pacemaker:

Share this page:

2 Comment(s)