Unix Technical Forum

Warm-Backup configuration question

This is a discussion on Warm-Backup configuration question within the pgsql Admins forums, part of the PostgreSQL category; --> I've got 2 identical servers configured exactly the same way, except for some minor differences for the WAL logging ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Admins

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 09:10 AM
Kenji Morishige
 
Posts: n/a
Default Warm-Backup configuration question

I've got 2 identical servers configured exactly the same way, except for some
minor differences for the WAL logging directories. I have both machines set up
as a NFS server and client, so that the WAL archive gets written out to the
local filesystem of the backup machine depending on which role the machine is
currently configured for.

I've been able to get the backup server syncronized by using the recover.conf
file as described in the documenation, but I can't seem to write a generic shell
script that will keep the warm-backup in a continously syncronizing mode. It
always stops and renames the recover.conf to recover.done.

I've tried to write an alternate restore command as follows:

#!/usr/local/bin/bash
if [ -e /export/raid/pgsql/recovery.stop ]; then
exit 1
fi
if [ -e $1 ]; then
`/bin/cp $1 $2`
fi
sleep 5
exit 0

The documenation says that it should return 0 only if it is successfull. My
understanding is that the recovery script should continuously try to copy the
archived data to the WAL directory so that the WARM-BACKUP server can
syncronize. I'd like to have the WARM-BACKUP always be only a few minutes
behind in syncronization from the PRIMARY without human intervention. I can
write a cronjob to clean out the WAL archive directory accordingly.

I would be extremely gratefull for any assistance from anyone with a similar
configuration. I must be confused by how the restore_command is supposed to
work.

Sincerely,
Kenji

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 09:10 AM
Tom Arthurs
 
Posts: n/a
Default Re: Warm-Backup configuration question

You need to make the script wait forever for the next archive file, or
return 1 only if you want to complete the recovery. Here's a stub of
what we do:

#!/usr/bin/ksh

set -e

# Where copy.sh fetches WALs from
ARCHDIR=/data3/archive_log

# Name of log file that copy.sh writes to
copy_log=copy.log
# Name of stop file that copy looks for to signal "go live"
copy_stop=copy.stop

# How many seconds sleep between copy iterations
seconds=15
# Expected size of WAL file
size=16777216

src=$1
dest=$2
base=$(basename $src)

exec >>$copy_log
exec 2>&1

echo $base

case $base in
*.history)
echo "\tignored"
exit 1
;;
*.backup)
size=+0
;;
esac


while :; do

if [ -f $copy_stop ]; then
echo "\tstop file"
rm $copy_stop
exit 1
fi

if [ -f "$src" ]; then
if [ "$(find $src -size ${size}c)" ]; then

echo "\tfound"
cp $src $dest

exit 0
else
echo "\ttoo small"
fi
fi

echo "\tsleeping $seconds"
sleep $seconds
done


Kenji Morishige wrote:
> I've got 2 identical servers configured exactly the same way, except for some
> minor differences for the WAL logging directories. I have both machines set up
> as a NFS server and client, so that the WAL archive gets written out to the
> local filesystem of the backup machine depending on which role the machine is
> currently configured for.
>
> I've been able to get the backup server syncronized by using the recover.conf
> file as described in the documenation, but I can't seem to write a generic shell
> script that will keep the warm-backup in a continously syncronizing mode. It
> always stops and renames the recover.conf to recover.done.
>
> I've tried to write an alternate restore command as follows:
>
> #!/usr/local/bin/bash
> if [ -e /export/raid/pgsql/recovery.stop ]; then
> exit 1
> fi
> if [ -e $1 ]; then
> `/bin/cp $1 $2`
> fi
> sleep 5
> exit 0
>
> The documenation says that it should return 0 only if it is successfull. My
> understanding is that the recovery script should continuously try to copy the
> archived data to the WAL directory so that the WARM-BACKUP server can
> syncronize. I'd like to have the WARM-BACKUP always be only a few minutes
> behind in syncronization from the PRIMARY without human intervention. I can
> write a cronjob to clean out the WAL archive directory accordingly.
>
> I would be extremely gratefull for any assistance from anyone with a similar
> configuration. I must be confused by how the restore_command is supposed to
> work.
>
> Sincerely,
> Kenji
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>
>


---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 09:10 AM
Mikko Partio
 
Posts: n/a
Default Re: Warm-Backup configuration question

On 8/24/07, Kenji Morishige <kenjim@juniper.net> wrote:
>
> I've got 2 identical servers configured exactly the same way, except for
> some
> minor differences for the WAL logging directories. I have both machines
> set up
> as a NFS server and client, so that the WAL archive gets written out to
> the
> local filesystem of the backup machine depending on which role the machine
> is
> currently configured for.
>
> I've been able to get the backup server syncronized by using the
> recover.conf
> file as described in the documenation, but I can't seem to write a generic
> shell
> script that will keep the warm-backup in a continously syncronizing
> mode. It
> always stops and renames the recover.conf to recover.done.
>
> I've tried to write an alternate restore command as follows:
>
> #!/usr/local/bin/bash
> if [ -e /export/raid/pgsql/recovery.stop ]; then
> exit 1
> fi
> if [ -e $1 ]; then
> `/bin/cp $1 $2`
> fi
> sleep 5
> exit 0
>
> The documenation says that it should return 0 only if it is
> successfull. My
> understanding is that the recovery script should continuously try to copy
> the
> archived data to the WAL directory so that the WARM-BACKUP server can
> syncronize. I'd like to have the WARM-BACKUP always be only a few minutes
> behind in syncronization from the PRIMARY without human intervention. I
> can
> write a cronjob to clean out the WAL archive directory accordingly.
>
> I would be extremely gratefull for any assistance from anyone with a
> similar
> configuration. I must be confused by how the restore_command is supposed
> to
> work.
>
>
>

Why don't you just use pg_standby from contrib.

Regards

MP

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 09:10 AM
Kenji Morishige
 
Posts: n/a
Default Re: Warm-Backup configuration question

Hmm. I recently installed 8.2.4 out of ports (FreeBSD) and didn't see that file
in contrib. I'd like to take a look at it.
Kenji

On Fri, Aug 24, 2007 at 07:18:12AM +0300, Mikko Partio wrote:
>
>
> On 8/24/07, Kenji Morishige <kenjim@juniper.net> wrote:
>
> I've got 2 identical servers configured exactly the same way, except for
> some
> minor differences for the WAL logging directories. I have both machines
> set up
> as a NFS server and client, so that the WAL archive gets written out to the
> local filesystem of the backup machine depending on which role the machine
> is
> currently configured for.
>
> I've been able to get the backup server syncronized by using the
> recover.conf
> file as described in the documenation, but I can't seem to write a generic
> shell
> script that will keep the warm-backup in a continously syncronizing
> mode. It
> always stops and renames the recover.conf to recover.done.
>
> I've tried to write an alternate restore command as follows:
>
> #!/usr/local/bin/bash
> if [ -e /export/raid/pgsql/recovery.stop ]; then
> exit 1
> fi
> if [ -e $1 ]; then
> `/bin/cp $1 $2`
> fi
> sleep 5
> exit 0
>
> The documenation says that it should return 0 only if it is
> successfull. My
> understanding is that the recovery script should continuously try to copy
> the
> archived data to the WAL directory so that the WARM-BACKUP server can
> syncronize. I'd like to have the WARM-BACKUP always be only a few minutes
> behind in syncronization from the PRIMARY without human intervention. I can
> write a cronjob to clean out the WAL archive directory accordingly.
>
> I would be extremely gratefull for any assistance from anyone with a
> similar
> configuration. I must be confused by how the restore_command is supposed
> to
> work.
>
>
>
>
> Why don't you just use pg_standby from contrib.
>
> Regards
>
> MP


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:01 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com