Thursday, December 29, 2011

Postgresql - pgpool - getting it done without repmgr

Formerly I had used repmgr to aid my recovery and failover scripts in pgpool, but recently changed my mind and now I'm removing that extra layer.

The recovery script should look like this now:

# first stage recovery
# $1 datadir
# $2 desthost
# $3 destdir
MASTERNODE=`/sbin/ifconfig eth0 | grep inet | awk '{print $2}' | sed 's/addr://'`
CMD=`ssh postgres@$2 "pg_basebackup --pgdata=$3 --host=$MASTERNODE --xlog --port=5432"`
CMD1=`ssh postgres@$2 "echo standby_mode = \'on\' > $3/recovery.conf"`
CMD2=`ssh postgres@$2 "echo primary_conninfo = \'host=$MASTERNODE port=5432 user=postgres password=pgsql\' >> $3/recovery.conf"`
echo $CMD
echo $CMD1
echo $CMD2
exit 0

+ One thing that had me scratching my head a little was the single quote inside double quotes that are inside back ticks -> but then my old friend the back slash came to rescue. =-)

+ The issue that emerges now, is: how does pg_basebackup behave when the cluster directory is not empty?

+ I had previously modified the /etc/ssh/ssh_config parameter file so that user environment variables are permited. So I aggregated them in the ~/.ssh/environment file, this in order to enter only the binary name instead of the whole path. Well,second guessing I think that it's better to leave the ssh environment variables alone.

No comments:

Post a Comment