Skip site navigation (1) Skip section navigation (2)

Re: [linux-lvm] RE: [PERFORM] backup/restore - another

From: CLeon(at)phs(dot)org
To: linux-lvm(at)sistina(dot)com, tgl(at)sss(dot)pgh(dot)pa(dot)us
Cc: threshar(at)torgo(dot)978(dot)org, josh(at)agliodbs(dot)com, markw(at)osdl(dot)org,pgsql-performance(at)postgresql(dot)org, pgsql-admin(at)postgresql(dot)org
Subject: Re: [linux-lvm] RE: [PERFORM] backup/restore - another
Date: 2003-10-30 17:28:10
Message-ID: FDF162266E09D81193350008C7E6346425091C@pinemail1 (view raw or flat)
Thread:
Lists: pgsql-adminpgsql-performance
Does xfs_freeze work on red hat 7.3?
  
Cynthia Leon

-----Original Message-----
From: Murthy Kambhampaty [mailto:murthy(dot)kambhampaty(at)goeci(dot)com]
Sent: Friday, October 17, 2003 11:34 AM
To: 'Tom Lane'; Murthy Kambhampaty
Cc: 'Jeff'; Josh Berkus; markw(at)osdl(dot)org;
pgsql-performance(at)postgresql(dot)org; linux-lvm(at)sistina(dot)com;
pgsql-admin(at)postgresql(dot)org
Subject: [linux-lvm] RE: [ADMIN] [PERFORM] backup/restore - another
area.


Friday, October 17, 2003 12:05, Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us] wrote:

>Murthy Kambhampaty <murthy(dot)kambhampaty(at)goeci(dot)com> writes:
>> ... The script handles situations
>> where (i) the XFS filesystem containing $PGDATA has an 
>external log and (ii)
>> the postmaster log ($PGDATA/pg_xlog) is written to a 
>filesystem different
>> than the one containing the $PGDATA folder.
>
>It does?  How exactly can you ensure snapshot consistency between
>data files and XLOG if they are on different filesystem

Say, you're setup looks something like this:

mount -t xfs /dev/VG1/LV_data /home/pgdata
mount -t xfs /dev/VG1/LV_xlog /home/pgdata/pg_xlog

When you want to take the filesystem backup, you do:

Step 1:
xfs_freeze -f /dev/VG1/LV_xlog
xfs_freeze -f /dev/VG1/LV_data
	This should finish any checkpoints that were in progress, and not
start any new ones
	till you unfreeze. (writes to an xfs_frozen filesystem wait for the
xfs_freeze -u, 
	but reads proceed; see text from xfs_freeze manpage in postcript
below.)


Step2: 
create snapshots of /dev/VG1/LV_xlog and /dev/VG1/LV_xlog

Step 3: 
xfs_freeze -u /dev/VG1/LV_data
xfs_freeze -u /dev/VG1/LV_xlog
	Unfreezing in this order should assure that checkpoints resume where
they left off, then log writes commence.


Step4:
mount the snapshots taken in Step2 somewhere; e.g. /mnt/snap_data and
/mnt/snap_xlog. Copy (or rsync or whatever) /mnt/snap_data to /mnt/pgbackup/
and /mnt/snap_xlog to /mnt/pgbackup/pg_xlog. Upon completion, /mnt/pgbackup/
looks to the postmaster like /home/pgdata would if the server had crashed at
the moment that Step1 was initiated. As I understand it, during recovery
(startup) the postmaster will roll the database forward to this point,
"checkpoint-ing" all the transactions that made it into the log before the
crash.

Step5:
remove the snapshots created in Step2.

The key is 
(i) xfs_freeze allows you to "quiesce" any filesystem at any point in time
and, if I'm not mistaken, the order (LIFO) in which you freeze and unfreeze
the two filesystems: freeze $PGDATA/pg_xlog then $PGDATA; unfreeze $PGDATA
then $PGDATA/pg_xlog.
(ii) WAL recovery assures consistency after a (file)sytem crash.

Presently, the test server for my backup scripts is set-up this way, and the
backup works flawlessly, AFAICT. (Note that the backup script starts a
postmaster on the filesystem copy each time, so you get early warning of
problems. Moreover the data in the "production" and "backup" copies are
tested and found to be identical.

Comments? Any suggestions for additional tests?

Thanks,
	Murthy

PS: From the xfs_freeze manpage:
"xfs_freeze suspends and resumes access to an XFS filesystem (see
xfs(5)). 

xfs_freeze halts new access to the filesystem and creates a stable image
on disk. xfs_freeze is intended to be used with volume managers and
hardware RAID devices that support the creation of snapshots. 

The mount-point argument is the pathname of the directory where the
filesystem is mounted. The filesystem must be mounted to be frozen (see
mount(8)). 

The -f flag requests the specified XFS filesystem to be frozen from new
modifications. When this is selected, all ongoing transactions in the
filesystem are allowed to complete, new write system calls are halted,
other calls which modify the filesystem are halted, and all dirty data,
metadata, and log information are written to disk. Any process
attempting to write to the frozen filesystem will block waiting for the
filesystem to be unfrozen. 

Note that even after freezing, the on-disk filesystem can contain
information on files that are still in the process of unlinking. These
files will not be unlinked until the filesystem is unfrozen or a clean
mount of the snapshot is complete. 

The -u option is used to un-freeze the filesystem and allow operations
to continue. Any filesystem modifications that were blocked by the
freeze are unblocked and allowed to complete."

_______________________________________________
linux-lvm mailing list
linux-lvm(at)sistina(dot)com
http://lists.sistina.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

==============================================================================
--- PRESBYTERIAN HEALTHCARE SERVICES DISCLAIMER ---

This message originates from Presbyterian Healthcare Services or one of its
affiliated organizations. It contains information, which may be confidential
or privileged, and is intended only for the individual or entity named above.
It is prohibited for anyone else to disclose, copy, distribute or use the
contents of this message. All personal messages express views solely of the
sender, which are not to be attributed to Presbyterian Healthcare Services or
any of its affiliated organizations, and may not be distributed without this
disclaimer. If you received this message in error, please notify us
immediately at postmaster(at)phs(dot)org(dot) 
==============================================================================


Responses

pgsql-performance by date

Next:From: Tom LaneDate: 2003-10-30 17:28:47
Subject: Re: vacuum locking
Previous:From: scott.marloweDate: 2003-10-30 17:05:15
Subject: Re: vacuum locking

pgsql-admin by date

Next:From: Tom LaneDate: 2003-10-30 17:52:36
Subject: Re: Shared memory corrupted?
Previous:From: Jeff BoesDate: 2003-10-30 16:07:29
Subject: Re: Shared memory corrupted?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group