(no commit message)
[ikiwiki.git] / docs / how_to_implement_hammer_pseudo_file_system__40___pfs___41___slave_mirroring_from_pfs_master / index.mdwn
CommitLineData
436b15f7 1*** THIS GUIDE IS INCOMPLETE ***
2
e4802ac5 3[[!toc]]
c0db5f1e 4#Scenario
6998bbdd 5I 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.
6
7#Creating the master pfs on Disk 1
8
9c4d145c 9The hammer file systems on Disk 1 and Disk2 are mounted in '/etc/fstab' according to the following.
6998bbdd 10
11 /dev/ad4s1h /Backup1 hammer rw 2 2
12 /dev/ad6s1h /Backup2 hammer rw 2 2
13
95469a7f 14Go 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.
9c4d145c 15
16 # pwd
17 /Backup1
18 # mkdir pfs
95469a7f 19
20If you already have the pfs directory under the hammer file system you can skip the above step and continue.
21
9c4d145c 22 # hammer pfs-master /Backup1/pfs/test
23 Creating PFS #3 succeeded!
24 /Backup1/pfs/test
25 sync-beg-tid=0x0000000000000001
95469a7f 26 sync-end-tid=0x000000013f644ce0
27 shared-uuid=9043570e-b3d9-11de-9bef-011617202aa6
28 unique-uuid=9043574c-b3d9-11de-9bef-011617202aa6
9c4d145c 29 label=""
30 prune-min=00:00:00
31 operating as a MASTER
32 snapshots dir for master defaults to <fs>/snapshots
9c4d145c 33
95469a7f 34
9c4d145c 35Now 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.
36You can mount the pfs under the hammer file system on Disk 1 by doing the following.
37
38 # mkdir /Backup1/test
39
40Now Edit '/etc/fstab' to contain the following line.
41
42 /Backup1/pfs/test /Backup1/test null rw 0 0
43
44Now mount the pfs by doing.
45
46 # mount -a
47 # mount |grep test
48 /Backup1/pfs/@@-1:00003 on /Backup1/test (null, local)
49
d2d39136 50#Creating the slave pfs on Disk 2.
51Note that we will be using the 'shared-uuid of the master pfs so enable mirroring.
436b15f7 52
95469a7f 53 # hammer pfs-slave /Backup2/pfs/test shared-uuid=9043570e-b3d9-11de-9bef-011617202aa6
436b15f7 54 Creating PFS #3 succeeded!
55 /Backup2/pfs/test
56 sync-beg-tid=0x0000000000000001
57 sync-end-tid=0x0000000000000001
95469a7f 58 shared-uuid=9043570e-b3d9-11de-9bef-011617202aa6
59 unique-uuid=97d77f53-b3da-11de-9bef-011617202aa6
436b15f7 60 slave
61 label=""
62 prune-min=00:00:00
63 operating as a SLAVE
64 snapshots directory not set for slave
65
95469a7f 66
436b15f7 67The slave pfs is not mounted but a symlink is created in the root hammer file system to point to it.
68
69 # ln -s /Backup2/pfs/test /Backup2/test
70 # ls -l /Backup2/test
71 lrwxr-xr-x 1 root wheel 17 Oct 8 12:07 /Backup2/test -> /Backup2/pfs/test
72
d2d39136 73#Copying contents from pfs on Disk 1 to pfs on Disk2 to enable mirroring.
74The pfs will be accessible only after the first 'mirror-copy' operation.
436b15f7 75
76 # touch /Backup1/test/test-file
95469a7f 77 # ls /Backup1/test/
78 test-file
79 # sync
80
81We 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.
82
83 # hammer mirror-copy /Backup1/test /Backup2/pfs/test
84 histogram range 000000013f6425fd - 000000013f644d60
85 Mirror-read: Mirror from 0000000000000002 to 000000013f644d60
86 Mirror-read /Backup1/test succeeded
c0db5f1e 87
95469a7f 88 # ls /Backup2/test/
89 test-file
35c80e16 90
91#Enabling continuous mirroring.
92
93You can enable continuous mirroring by editing a few files.
94One way to make sure the mirroring works continously is to use the 'lockf' utility.
95This is one way to do it.
96
97 # mkdir /root/adm && cd /root/adm
98 # touch .lockfile
99
100Now make two scripts 'hms' and 'hmc' with the following contents inside /root/adm
101
102 # cat hms
103 hammer mirror-stream /Backup1/test /Backup2/test &
104
105 # cat hmc
106 hammer synctid /Backup1/test
107 hammer mirror-copy /Backup1/test /Backup2/test
108
109Edit '/etc/rc.local and add the following line.
110
111 (cd /root/adm; /usr/bin/lockf -k -t 0 .lockfile ./hms) &
112
113Edit 'crontab' and add the following Lines.
114
115 #Check and restart mirroring if needed every 10 minutes
116 10 1 * * * (cd /root/adm; /usr/bin/lockf -k -t 0 .lockfile ./hms) &
117
118Edit '/etc/rc.shutdown.local' and add the following lines.
119
120 pkill -f /usr/bin/lockf -k -t 0 .lockfile ./hms
121 pkill -f hammer mirror-stream /Backup1/test /Backup2/test
122 (cd /root/adm; /usr/bin/lockf -k -t 10 .lockfile ./hmc)