HAST or “Highly Available Storage”, is a mechanism built into FreeBSD that allows for transparent syncing of block data between two physical hosts (connected via a network).
HAST is a “primary/secondary” cluster, meaning that there will always be a single source of truthieness (the master/primary)
For the sake of the example, assume we have two machines (fbsd_h1 and fbsd_h2) and both have a /dev/da0
disk which contains the data we want to sync.
The config file (/etc/hast.conf) must be the same on both the primary and secondary machines!
listen tcp://0.0.0.0
resource shared {
local /dev/ada0p4
on fbsd_h1 {
remote tcp://10.0.0.231
}
on fbsd_h2 {
remote tcp://10.0.0.233
}
}
Now we can start up hastd on each client and tell the cluster which host is the master!
fbsd_h1# hastctl create shared
fbsd_h1# hastd
fbsd_h1# hastctl role primary shared
fbsd_h1# newfs -U /dev/hast/shared
fbsd_h1# mount -o noatime /dev/hast/shared /data
fbsd_h2# hastctl create shared
fbsd_h2# hastd
fbsd_h2# hastctl role secondary shared
If all goes to plan when you run hastctl status
you should see something like this:
fbsd_h1# hastctl status
Name Status Role Components
shared complete primary /dev/ada0p4 tcp://10.0.1.233
fbsd_h2# hastctl status
Name Status Role Components
shared complete secondary /dev/ada0p4 tcp://10.0.1.231
memsync
’d HAST cluster!