summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2010-04-18 21:14:49 +0000
committerpjd <pjd@FreeBSD.org>2010-04-18 21:14:49 +0000
commit61b0f125e6f04a1060f00bd9cf7f541fd5d11474 (patch)
treef398b448eafd060df59e90a49e3c34b89d12145d /share
parent083a76a5b6255e73f7ff4669241c9376ebebb7df (diff)
downloadFreeBSD-src-61b0f125e6f04a1060f00bd9cf7f541fd5d11474.zip
FreeBSD-src-61b0f125e6f04a1060f00bd9cf7f541fd5d11474.tar.gz
MFC r204076,r204077,r204083,r205279:
r204076: Please welcome HAST - Highly Avalable Storage. HAST allows to transparently store data on two physically separated machines connected over the TCP/IP network. HAST works in Primary-Secondary (Master-Backup, Master-Slave) configuration, which means that only one of the cluster nodes can be active at any given time. Only Primary node is able to handle I/O requests to HAST-managed devices. Currently HAST is limited to two cluster nodes in total. HAST operates on block level - it provides disk-like devices in /dev/hast/ directory for use by file systems and/or applications. Working on block level makes it transparent for file systems and applications. There in no difference between using HAST-provided device and raw disk, partition, etc. All of them are just regular GEOM providers in FreeBSD. For more information please consult hastd(8), hastctl(8) and hast.conf(5) manual pages, as well as http://wiki.FreeBSD.org/HAST. Sponsored by: FreeBSD Foundation Sponsored by: OMCnet Internet Service GmbH Sponsored by: TransIP BV r204077: Remove some lines left over by accident. r204083: Add missing KEYWORD line. Pointed out by: dougb r205279 sys: Simplify loops.
Diffstat (limited to 'share')
-rw-r--r--share/examples/Makefile6
-rwxr-xr-xshare/examples/hast/ucarp.sh69
-rwxr-xr-xshare/examples/hast/ucarp_down.sh98
-rwxr-xr-xshare/examples/hast/ucarp_up.sh105
-rwxr-xr-xshare/examples/hast/vip-down.sh5
-rwxr-xr-xshare/examples/hast/vip-up.sh7
-rw-r--r--share/man/man5/rc.conf.521
7 files changed, 311 insertions, 0 deletions
diff --git a/share/examples/Makefile b/share/examples/Makefile
index 315eb91..99d92c0 100644
--- a/share/examples/Makefile
+++ b/share/examples/Makefile
@@ -13,6 +13,7 @@ LDIRS= BSD_daemon \
drivers \
etc \
find_interface \
+ hast \
ibcs2 \
ipfw \
kld \
@@ -69,6 +70,11 @@ XFILES= BSD_daemon/FreeBSD.pfa \
find_interface/Makefile \
find_interface/README \
find_interface/find_interface.c \
+ hast/ucarp.sh \
+ hast/ucarp_down.sh \
+ hast/ucarp_up.sh \
+ hast/vip-down.sh \
+ hast/vip-up.sh \
ibcs2/README \
ibcs2/hello.uu \
ipfw/change_rules.sh \
diff --git a/share/examples/hast/ucarp.sh b/share/examples/hast/ucarp.sh
new file mode 100755
index 0000000..6a02c89
--- /dev/null
+++ b/share/examples/hast/ucarp.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 The FreeBSD Foundation
+# All rights reserved.
+#
+# This software was developed by Pawel Jakub Dawidek under sponsorship from
+# the FreeBSD Foundation.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+# Shared IP address, unused for now.
+addr="10.99.0.3"
+# Password for UCARP communication.
+pass="password"
+# First node IP and interface for UCARP communication.
+nodea_srcip="10.99.0.1"
+nodea_ifnet="bge0"
+# Second node IP and interface for UCARP communication.
+nodeb_srcip="10.99.0.2"
+nodeb_ifnet="em3"
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
+
+vhid="1"
+upscript="/root/hast/sbin/hastd/vip-up.sh"
+downscript="/root/hast/sbin/hastd/vip-down.sh"
+
+ifconfig "${nodea_ifnet}" 2>/dev/null | grep -q "inet ${nodea_srcip} "
+if [ $? -eq 0 ]; then
+ srcip="${nodea_srcip}"
+ ifnet="${nodea_ifnet}"
+ node="node A"
+fi
+ifconfig "${nodeb_ifnet}" 2>/dev/null | grep -q "inet ${nodeb_srcip} "
+if [ $? -eq 0 ]; then
+ if [ -n "${srcip}" -o -n "${ifnet}" ]; then
+ echo "Unable to determine which node is this (both match)." >/dev/stderr
+ exit 1
+ fi
+ srcip="${nodeb_srcip}"
+ ifnet="${nodeb_ifnet}"
+ node="node B"
+fi
+if [ -z "${srcip}" -o -z "${ifnet}" ]; then
+ echo "Unable to determine which node is this (none match)." >/dev/stderr
+ exit 1
+fi
+ucarp -i ${ifnet} -s ${srcip} -v ${vhid} -a ${addr} -p ${pass} -u "${upscript}" -d "${downscript}"
diff --git a/share/examples/hast/ucarp_down.sh b/share/examples/hast/ucarp_down.sh
new file mode 100755
index 0000000..a5b3428
--- /dev/null
+++ b/share/examples/hast/ucarp_down.sh
@@ -0,0 +1,98 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 The FreeBSD Foundation
+# All rights reserved.
+#
+# This software was developed by Pawel Jakub Dawidek under sponsorship from
+# the FreeBSD Foundation.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+# Resource name as defined in /etc/hast.conf.
+resource="test"
+# Supported file system types: UFS, ZFS
+fstype="UFS"
+# ZFS pool name. Required only when fstype == ZFS.
+pool="test"
+# File system mount point. Required only when fstype == UFS.
+mountpoint="/mnt/test"
+# Name of HAST provider as defined in /etc/hast.conf.
+# Required only when fstype == UFS.
+device="/dev/hast/${resource}"
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
+
+# KIll UP script if it still runs in the background.
+sig="TERM"
+for i in `jot 30`; do
+ pgid=`pgrep -f ucarp_up.sh | head -1`
+ [ -n "${pgid}" ] || break
+ kill -${sig} -- -${pgid}
+ sig="KILL"
+ sleep 1
+done
+if [ -n "${pgid}" ]; then
+ logger -p local0.error -t hast "UCARP UP process for resource ${resource} is still running after 30 seconds."
+ exit 1
+fi
+logger -p local0.debug -t hast "UCARP UP is not running."
+
+case "${fstype}" in
+UFS)
+ mount | egrep -q "^${device} on "
+ if [ $? -eq 0 ]; then
+ # Forcibly unmount file system.
+ out=`umount -f "${mountpoint}" 2>&1`
+ if [ $? -ne 0 ]; then
+ logger -p local0.error -t hast "Unable to unmount file system for resource ${resource}: ${out}."
+ exit 1
+ fi
+ logger -p local0.debug -t hast "File system for resource ${resource} unmounted."
+ fi
+ ;;
+ZFS)
+ zpool list | egrep -q "^${pool} "
+ if [ $? -eq 0 ]; then
+ # Forcibly export file pool.
+ out=`zpool export -f "${pool}" 2>&1`
+ if [ $? -ne 0 ]; then
+ logger -p local0.error -t hast "Unable to export pool for resource ${resource}: ${out}."
+ exit 1
+ fi
+ logger -p local0.debug -t hast "ZFS pool for resource ${resource} exported."
+ fi
+ ;;
+esac
+
+# Change role to secondary for our resource.
+out=`hastctl role secondary "${resource}" 2>&1`
+if [ $? -ne 0 ]; then
+ logger -p local0.error -t hast "Unable to change to role to secondary for resource ${resource}: ${out}."
+ exit 1
+fi
+logger -p local0.debug -t hast "Role for resource ${resource} changed to secondary."
+
+logger -p local0.info -t hast "Successfully switched to secondary for resource ${resource}."
+
+exit 0
diff --git a/share/examples/hast/ucarp_up.sh b/share/examples/hast/ucarp_up.sh
new file mode 100755
index 0000000..9e56040
--- /dev/null
+++ b/share/examples/hast/ucarp_up.sh
@@ -0,0 +1,105 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 The FreeBSD Foundation
+# All rights reserved.
+#
+# This software was developed by Pawel Jakub Dawidek under sponsorship from
+# the FreeBSD Foundation.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+# Resource name as defined in /etc/hast.conf.
+resource="test"
+# Supported file system types: UFS, ZFS
+fstype="UFS"
+# ZFS pool name. Required only when fstype == ZFS.
+pool="test"
+# File system mount point. Required only when fstype == UFS.
+mountpoint="/mnt/test"
+# Name of HAST provider as defined in /etc/hast.conf.
+device="/dev/hast/${resource}"
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
+
+# If there is secondary worker process, it means that remote primary process is
+# still running. We have to wait for it to terminate.
+for i in `jot 30`; do
+ pgrep -f "hastd: ${resource} \(secondary\)" >/dev/null 2>&1 || break
+ sleep 1
+done
+if pgrep -f "hastd: ${resource} \(secondary\)" >/dev/null 2>&1; then
+ logger -p local0.error -t hast "Secondary process for resource ${resource} is still running after 30 seconds."
+ exit 1
+fi
+logger -p local0.debug -t hast "Secondary process in not running."
+
+# Change role to primary for our resource.
+out=`hastctl role primary "${resource}" 2>&1`
+if [ $? -ne 0 ]; then
+ logger -p local0.error -t hast "Unable to change to role to primary for resource ${resource}: ${out}."
+ exit 1
+fi
+# Wait few seconds for provider to appear.
+for i in `jot 50`; do
+ [ -c "${device}" ] && break
+ sleep 0.1
+done
+if [ ! -c "${device}" ]; then
+ logger -p local0.error -t hast "Device ${device} didn't appear."
+ exit 1
+fi
+logger -p local0.debug -t hast "Role for resource ${resource} changed to primary."
+
+case "${fstype}" in
+UFS)
+ # Check the file system.
+ fsck -y -t ufs "${device}" >/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ logger -p local0.error -t hast "File system check for resource ${resource} failed."
+ exit 1
+ fi
+ logger -p local0.debug -t hast "File system check for resource ${resource} finished."
+ # Mount the file system.
+ out=`mount -t ufs "${device}" "${mountpoint}" 2>&1`
+ if [ $? -ne 0 ]; then
+ logger -p local0.error -t hast "File system mount for resource ${resource} failed: ${out}."
+ exit 1
+ fi
+ logger -p local0.debug -t hast "File system for resource ${resource} mounted."
+ ;;
+ZFS)
+ # Import ZFS pool. Do it forcibly as it remembers hostid of
+ # the other cluster node.
+ out=`zpool import -f "${pool}" 2>&1`
+ if [ $? -ne 0 ]; then
+ logger -p local0.error -t hast "ZFS pool import for resource ${resource} failed: ${out}."
+ exit 1
+ fi
+ logger -p local0.debug -t hast "ZFS pool for resource ${resource} imported."
+ ;;
+esac
+
+logger -p local0.info -t hast "Successfully switched to primary for resource ${resource}."
+
+exit 0
diff --git a/share/examples/hast/vip-down.sh b/share/examples/hast/vip-down.sh
new file mode 100755
index 0000000..5e47609
--- /dev/null
+++ b/share/examples/hast/vip-down.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+# $FreeBSD$
+
+/root/hast/sbin/hastd/ucarp_down.sh
+exit 0
diff --git a/share/examples/hast/vip-up.sh b/share/examples/hast/vip-up.sh
new file mode 100755
index 0000000..61dabe9
--- /dev/null
+++ b/share/examples/hast/vip-up.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+# $FreeBSD$
+
+set -m
+/root/hast/sbin/hastd/ucarp_up.sh &
+set +m
+exit 0
diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5
index 5c55b90..07f2fb8 100644
--- a/share/man/man5/rc.conf.5
+++ b/share/man/man5/rc.conf.5
@@ -1645,6 +1645,27 @@ is set to
.Dq Li YES ,
these are the flags to pass to
.Xr inetd 8 .
+.It Va hastd_enable
+.Pq Vt bool
+If set to
+.Dq Li YES ,
+run the
+.Xr hastd 8
+daemon.
+.It Va hastd_program
+.Pq Vt str
+Path to
+.Xr hastd 8
+(default
+.Pa /sbin/hastd ) .
+.It Va hastd_flags
+.Pq Vt str
+If
+.Va hastd_enable
+is set to
+.Dq Li YES ,
+these are the flags to pass to
+.Xr hastd 8 .
.It Va named_enable
.Pq Vt bool
If set to
OpenPOWER on IntegriCloud