Date: Sun, 30 Nov 2008 01:05:48 +0000 From: Pete French <petefrench@ticketswitch.com> To: pjd@FreeBSD.org Cc: freebsd-stable@freebsd.org Subject: Re: Curious failure of ZFS snapshots Message-ID: <E1L6aku-000NAk-Q1@dilbert.ticketswitch.com> In-Reply-To: <20081130000059.GC1494@garage.freebsd.pl>
next in thread | previous in thread | raw e-mail | index | archive | help
> It's not file system on-disk structure fault, as far as I understand, > because reboot fixes it. I belive it's how you access the snapshots. I was about to say "a reboot doesnt fix it for me" - as I swear i tried that before, but I have discovered you are right, as I just rebooted the server and it is fine. Here is what I am doing - this script is run with an argument '7am' or '7pm' once per day. the mysql database is a slave replication from a master, so there is a continuous trickle of data into it. The symbolic links are there so you can connect to the mysql server and access 'xxx-7am' or 'xxx-7pm' to get a previous version of database 'xxx'. In case its not obvious, the filesystem 'tank/zfs' is mounted on the director '/var/db/mysql'. If you run this for a few cycles it should preseumably break for you too. -pete. ------------------------------------------------------------------- #!/bin/sh SUFFIX=$1 FS_NAME=tank/mysql DB_DIR=/var/db/mysql # First we should make sure we are root if test `/usr/bin/whoami` != "root" then /bin/echo You must be root to run this script exit fi # Check that we have a suffix if test "${SUFFIX}" = "" then /bin/echo "usage: $0 <suffix>" exit fi # Stop mysql, unlink the links and destroy the snapshot /usr/local/etc/rc.d/mysql-server stop > /dev/null /bin/rm -f ${DB_DIR}/*-${SUFFIX} /sbin/zfs destroy ${FS_NAME}@${SUFFIX} # Create the new (dated) snapshot /bin/date > ${DB_DIR}/SNAPSHOT_DATE /sbin/zfs snapshot ${FS_NAME}@${SUFFIX} /bin/rm -f ${DB_DIR}/SNAPSHOT_DATE # Find all mysql subdirectories and link them /usr/bin/find ${DB_DIR}/ -name '[a-z]*' -type d -maxdepth 1 -print | while read DIR do BASE_DIR=`/usr/bin/basename ${DIR}` /bin/ln -s ${DB_DIR}/.zfs/snapshot/${SUFFIX}/${BASE_DIR} ${DIR}-${SUFFIX} done # Restart mysql /usr/local/etc/rc.d/mysql-server start > /dev/null
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1L6aku-000NAk-Q1>