From: | Murthy Kambhampaty <murthy(dot)kambhampaty(at)goeci(dot)com> |
---|---|
To: | 'Tom Lane' <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Murthy Kambhampaty <murthy(dot)kambhampaty(at)goeci(dot)com> |
Cc: | 'Jeff' <threshar(at)torgo(dot)978(dot)org>, Josh Berkus <josh(at)agliodbs(dot)com>, markw(at)osdl(dot)org, pgsql-performance(at)postgresql(dot)org, linux-lvm(at)sistina(dot)com, pgsql-admin(at)postgresql(dot)org |
Subject: | Re: [PERFORM] backup/restore - another area. |
Date: | 2003-10-17 17:33:36 |
Message-ID: | 2D92FEBFD3BE1346A6C397223A8DD3FC092440@THOR.goeci.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin pgsql-performance |
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."
From | Date | Subject | |
---|---|---|---|
Next Message | David Wagoner | 2003-10-17 18:18:29 | How to extract table DDL from PGSQL database? |
Previous Message | Tom Lane | 2003-10-17 16:05:25 | Re: [PERFORM] backup/restore - another area. |
From | Date | Subject | |
---|---|---|---|
Next Message | Manfred Koizar | 2003-10-17 17:41:56 | Re: vacuum locking |
Previous Message | Josh Berkus | 2003-10-17 16:36:25 | Re: vacuum locking |