Hi,

I am working on making a postgresql/drbd/heartbeat high availability cluster. I need a script for heartbeat to start, stop and query the service. I wrote the following:

pgStart() {
su - pg0 -c "cd data ; /mnt/data0/postgresql/bin/pg_ctl start -D /mnt/data0/postgresql/data -w -o '-i -h 192.168.2.50'"
}


pgStop () {
su - pg0 -c "cd data ; /mnt/data$user/postgresql/bin/pg_ctl stop -D /mnt/data0/postgresql/data -m fast -w"
}


pgStatus () {
if su - pg0 -c "cd data ; /mnt/data0/postgresql/bin/pg_ctl status -D /mnt/data0/postgresql/data" | grep -q "postmaster is running"
then
echo running
else
echo stopped
fi
}


This works fine. The only problem is that status - it seems to only check for the existance of the PID file. If the file is there, it assumes that postgresql is running. In the case of a failover, the PID file will of course still be there, but it will be stale. The effect is that heartbeat never starts postgresql because my pgStatus claims it is already running, even though it is not.

Is there a better way to query the status of postgresql? I would expect it to at least check that the process in the PID is actually running and that it is a postgresql process.

I am also confused by the need to specify "-h 192.168.2.50" - that is already in the postgres.conf file, but "pg_ctl start" ignores it.

Thanks,

Baldur


---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly

Reply via email to