Skip to main content
Skip table of contents

Step 3: Setup ZFS folders

We are going to put all of our XNAT and PostgreSQL data on ZFS.   This will provide periodic snapshots that can be used for replication, data recovery or creating writable clones for development or testing.

 

Prepare data for migration

BASH
root@xnat-12:~# service tomcat7 stop
 * Stopping Tomcat servlet engine tomcat7                                   [ OK ]
root@xnat-12:~# mv /data /data.old
root@xnat-12:~# service postgresql stop
 * Stopping PostgreSQL 9.5 database server                                  [ OK ]
root@xnat-12:~# mv /var/lib/postgresql/9.5/main /var/lib/postgresql/9.5/main.old

Create ZFS folders

BASH
zfs create -o mountpoint=/data/xnat tank/xnat
zfs create tank/xnat/home
zfs create tank/xnat/archive
zfs create tank/xnat/build
zfs create tank/xnat/cache
zfs create tank/xnat/prearchive
zfs create -o mountpoint=/data/postgres tank/postgres

Confirm ZFS folders

BASH
root@xnat-12:~# zfs list
NAME                   USED  AVAIL  REFER  MOUNTPOINT
tank                   207K  30.8G    19K  /tank
tank/postgres           19K  30.8G    19K  /data/postgres
tank/xnat              119K  30.8G    19K  /data/xnat
tank/xnat/archive       19K  30.8G    19K  /data/xnat/archive
tank/xnat/build         19K  30.8G    19K  /data/xnat/build
tank/xnat/cache         19K  30.8G    19K  /data/xnat/cache
tank/xnat/home          24K  30.8G    24K  /data/xnat/home
tank/xnat/prearchive    19K  30.8G    19K  /data/xnat/prearchive

ZFS Folders

We have now created independent ZFS folders for various data types in our XNAT installation. This allows us to assign different snapshot policies for each dataset.

Setup ZFS Snapshot Management

We will be using OZMT (Open Zfs Management Tools)

BASH
cd /opt
hg clone https://bitbucket.org/ozmt/ozmt
cd ozmt
./install-ozmt.sh
 
# Create some snapshot jobs
ozmt-snapjobs-add.sh tank/xnat 15min/4 hourly/12 daily/60
ozmt-snapjobs-add.sh tank/xnat/archive 15min/4 hourly/12 daily/0
ozmt-snapjobs-add.sh tank/xnat/build 15min/4
ozmt-snapjobs-add.sh tank/xnat/cache 15min/4
ozmt-snapjobs-add.sh tank/xnat/home 15min/4 hourly/12 daily/60
ozmt-snapjobs-add.sh tank/xnat/prearchive 15min/4 hourly/12 
ozmt-snapjobs-add.sh tank/postgres 15min/4 hourly/12 daily/60
ozmt-snapjobs-add.sh tank/zfs_tools 15min/4 hourly/12 daily/7

Snapshots

Typically 15 minutes or even hourly is more aggressive than needed, but useful in our example so we can actively see our snapshots at work within this practical.

Like our production XNAT file systems we are keeping many daily snapshots. 60 of the /data/xnat, /data/xnat/home, and /data/postgres. This can be used to create writeable snap clones for development and testing purposes. 'daily/0' on the archive means make daily snapshots, but never delete any of them.

You can see all the snapshots on the ZFS pool with the command:

# zfs list -t snapshot -r tank

(If you run that command right now, you won't see any snapshots. None have been taken yet, since we set them to be taken every 15 minutes.)

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.