X-Git-Url: https://gitweb.dragonflybsd.org/ikiwiki.git/blobdiff_plain/5c949dfcc9bbd75ee22e7edcfe569a41e62385d1..HEAD:/docs/how_to_implement_hammer_pseudo_file_system__40___pfs___41___slave_mirroring_from_pfs_master/index.mdwn diff --git a/docs/how_to_implement_hammer_pseudo_file_system__40___pfs___41___slave_mirroring_from_pfs_master/index.mdwn b/docs/how_to_implement_hammer_pseudo_file_system__40___pfs___41___slave_mirroring_from_pfs_master/index.mdwn deleted file mode 100644 index f238ae7f..00000000 --- a/docs/how_to_implement_hammer_pseudo_file_system__40___pfs___41___slave_mirroring_from_pfs_master/index.mdwn +++ /dev/null @@ -1,121 +0,0 @@ - -[[!toc]] -#Scenario -I have two 500 GB hard disks both having hammer file system. I want to create a master pfs in one of the hard disk and a slave pfs in the other disk. I want to mirror the data continuosly from the master pfs to the slave pfs. This will help me avoid long 'fsck'and raid parity rewrite times after an unclean shut down and also will give me a set up some what like Raid. - -#Creating the master pfs on Disk 1 - -The hammer file systems on Disk 1 and Disk2 are mounted in '/etc/fstab' according to the following. - - /dev/ad4s1h /Backup1 hammer rw 2 2 - /dev/ad6s1h /Backup2 hammer rw 2 2 - -Go to the hammer file system on Disk 1. We will be creaing a master pfs called 'test' and will be mounting it using a null mount. If you dont have a directory called 'pfs' under the hammer file system you should create it because it is there we will be creating the pfs. - - # pwd - /Backup1 - # mkdir pfs - -If you already have the pfs directory under the hammer file system you can skip the above step and continue. - - # hammer pfs-master /Backup1/pfs/test - Creating PFS #3 succeeded! - /Backup1/pfs/test - sync-beg-tid=0x0000000000000001 - sync-end-tid=0x000000013f644ce0 - shared-uuid=9043570e-b3d9-11de-9bef-011617202aa6 - unique-uuid=9043574c-b3d9-11de-9bef-011617202aa6 - label="" - prune-min=00:00:00 - operating as a MASTER - snapshots dir for master defaults to /snapshots - - -Now the master pfs 'test' is created. make a note of its 'shared-uuid' because we will need to use that to create the Slave pfs for mirroring. -You can mount the pfs under the hammer file system on Disk 1 by doing the following. - - # mkdir /Backup1/test - -Now Edit '/etc/fstab' to contain the following line. - - /Backup1/pfs/test /Backup1/test null rw 0 0 - -Now mount the pfs by doing. - - # mount -a - # mount |grep test - /Backup1/pfs/@@-1:00003 on /Backup1/test (null, local) - -#Creating the slave pfs on Disk 2. -Note that we will be using the 'shared-uuid of the master pfs so enable mirroring. - - # hammer pfs-slave /Backup2/pfs/test shared-uuid=9043570e-b3d9-11de-9bef-011617202aa6 - Creating PFS #3 succeeded! - /Backup2/pfs/test - sync-beg-tid=0x0000000000000001 - sync-end-tid=0x0000000000000001 - shared-uuid=9043570e-b3d9-11de-9bef-011617202aa6 - unique-uuid=97d77f53-b3da-11de-9bef-011617202aa6 - slave - label="" - prune-min=00:00:00 - operating as a SLAVE - snapshots directory not set for slave - - -The slave pfs is not mounted but a symlink is created in the root hammer file system to point to it. - - # ln -s /Backup2/pfs/test /Backup2/test - # ls -l /Backup2/test - lrwxr-xr-x 1 root wheel 17 Oct 8 12:07 /Backup2/test -> /Backup2/pfs/test - -#Copying contents from pfs on Disk 1 to pfs on Disk2 to enable mirroring. -The pfs will be accessible only after the first 'mirror-copy' operation. - - # touch /Backup1/test/test-file - # ls /Backup1/test/ - test-file - # sync - -We do the "sync" so that the file creation operation in flushed from the kernel memory. Mirroring works only on operations flushed from the kernel memory. The slave pfs will be accessible only after the first mirroring operation. - - # hammer mirror-copy /Backup1/test /Backup2/pfs/test - histogram range 000000013f6425fd - 000000013f644d60 - Mirror-read: Mirror from 0000000000000002 to 000000013f644d60 - Mirror-read /Backup1/test succeeded - - # ls /Backup2/test/ - test-file - -#Enabling continuous mirroring. - -You can enable continuous mirroring by editing a few files. -One way to make sure the mirroring works continously is to use the 'lockf' utility. -This is one way to do it. - - # mkdir /root/adm && cd /root/adm - # touch .lockfile - -Now make two scripts 'hms' and 'hmc' with the following contents inside /root/adm - - # cat hms - hammer mirror-stream /Backup1/test /Backup2/test & - - # cat hmc - hammer synctid /Backup1/test - hammer mirror-copy /Backup1/test /Backup2/test - -Edit '/etc/rc.local and add the following line. - - (cd /root/adm; /usr/bin/lockf -k -t 0 .lockfile ./hms) & - -Edit 'crontab' and add the following Lines. - - #Check and restart mirroring if needed every 10 minutes - 10 1 * * * (cd /root/adm; /usr/bin/lockf -k -t 0 .lockfile ./hms) & - -Edit '/etc/rc.shutdown.local' and add the following lines. - - pkill -f /usr/bin/lockf -k -t 0 .lockfile ./hms - pkill -f hammer mirror-stream /Backup1/test /Backup2/test - (cd /root/adm; /usr/bin/lockf -k -t 10 .lockfile ./hmc)