diff --git a/configure.ac b/configure.ac index 58fe74f..ad723f8 100644 --- a/configure.ac +++ b/configure.ac @@ -1,354 +1,388 @@ dnl dnl autoconf for Agents dnl dnl License: GNU General Public License (GPL) dnl =============================================== dnl Bootstrap dnl =============================================== AC_PREREQ(2.63) dnl Suggested structure: dnl information on the package dnl checks for programs dnl checks for libraries dnl checks for header files dnl checks for types dnl checks for structures dnl checks for compiler characteristics dnl checks for library functions dnl checks for system services AC_INIT([sbd], [1.5.0], [lmb@suse.com]) m4_include([tests-opt.m4]) AC_CANONICAL_HOST AC_CONFIG_AUX_DIR(.) AC_CONFIG_HEADERS(config.h) m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([no])]) AM_INIT_AUTOMAKE(1.11.1 foreign TESTS_OPTION) AM_PROG_CC_C_O +# expand_path_option $path_variable_name $default +expand_path_option() { + # The first argument is the variable *name* (not value) + ac_path_varname="$1" + + # Get the original value of the variable + ac_path_value=$(eval echo "\${${ac_path_varname}}") + + # Expand any literal variable expressions in the value so that we don't + # end up with something like '${prefix}' in #defines etc. + # + # Autoconf deliberately leaves values unexpanded to allow overriding + # the configure script choices in make commands (for example, + # "make exec_prefix=/foo install"). No longer being able to do this seems + # like no great loss. + eval ac_path_value=$(eval echo "${ac_path_value}") + + # Use (expanded) default if necessary + AS_IF([test x"${ac_path_value}" = x""], + [eval ac_path_value=$(eval echo "$2")]) + + # Require a full path + AS_CASE(["$ac_path_value"], + [/*], [eval ${ac_path_varname}="$ac_path_value"], + [*], [AC_MSG_ERROR([$ac_path_varname value "$ac_path_value" is not a full path])] + ) +} + PKG_CHECK_MODULES(glib, [glib-2.0]) PKG_CHECK_MODULES(libxml, [libxml-2.0]) PKG_CHECK_MODULES(cmap, [libcmap], HAVE_cmap=1, HAVE_cmap=0) PKG_CHECK_MODULES(votequorum, [libvotequorum], HAVE_votequorum=1, HAVE_votequorum=0) dnl pacemaker > 1.1.8 PKG_CHECK_MODULES(pacemaker, [pacemaker, pacemaker-cib], HAVE_pacemaker=1, HAVE_pacemaker=0) dnl pacemaker <= 1.1.8 PKG_CHECK_MODULES(pcmk, [pcmk, pcmk-cib], HAVE_pcmk=1, HAVE_pcmk=0) PKG_CHECK_MODULES(libqb, [libqb]) CPPFLAGS="$CPPFLAGS -Werror $glib_CFLAGS $libxml_CFLAGS" LIBS="$LIBS $glib_LIBS $libxml_LIBS" if test $HAVE_pacemaker = 0 -a $HAVE_pcmk = 0; then AC_MSG_ERROR(No package 'pacemaker' found) elif test $HAVE_pacemaker = 1; then CPPFLAGS="$CPPFLAGS $glib_CFLAGS $pacemaker_CFLAGS" if test $HAVE_cmap = 0; then AC_MSG_NOTICE(No library 'cmap' found) else CPPFLAGS="$CPPFLAGS $cmap_CFLAGS" LIBS="$LIBS $cmap_LIBS" fi if test $HAVE_votequorum = 0; then AC_MSG_NOTICE(No library 'votequorum' found) else CPPFLAGS="$CPPFLAGS $votequorum_CFLAGS" LIBS="$LIBS $votequorum_LIBS" fi fi CPPFLAGS="$CPPFLAGS $libqb_CFLAGS $pacemaker_CFLAGS $pcmk_CFLAGS" LIBS="$LIBS $libqb_LIBS $pacemaker_LIBS $pcmk_LIBS" dnl checks for libraries AC_CHECK_LIB(c, dlopen) dnl if dlopen is in libc... AC_CHECK_LIB(dl, dlopen) dnl -ldl (for Linux) AC_CHECK_LIB(aio, io_setup, , missing="yes") AC_CHECK_LIB(qb, qb_ipcs_connection_auth_set, , missing="yes") AC_CHECK_LIB(cib, cib_new, , missing="yes") AC_CHECK_LIB(crmcommon, set_crm_log_level, , missing="yes") AC_CHECK_LIB(pe_status, pe_find_node, , missing="yes") AC_CHECK_LIB(pe_rules, test_rule, , missing="yes") AC_CHECK_LIB(crmcluster, crm_peer_init, , missing="yes") AC_CHECK_LIB(uuid, uuid_unparse, , missing="yes") AC_CHECK_LIB(cmap, cmap_initialize, , HAVE_cmap=0) AC_CHECK_LIB(votequorum, votequorum_getinfo, , HAVE_votequorum=0) AC_CHECK_LIB(crmcommon, pcmk_pacemakerd_api_ping, HAVE_pacemakerd_api=1, HAVE_pacemakerd_api=0) dnl pacemaker >= 1.1.8 AC_CHECK_HEADERS(crm/cluster.h) AC_CHECK_LIB(crmcommon, pcmk_strerror, , missing="yes") AC_CHECK_LIB(cib, cib_apply_patch_event, , missing="yes") dnl pacemaker-2.0 removed support for corosync 1 cluster layer AC_CHECK_DECLS([pcmk_cluster_classic_ais, pcmk_cluster_cman],,, [#include ]) dnl check for additional no-quorum-policies dnl AC_TEST_NO_QUORUM_POLICY(POLICY) AC_DEFUN([AC_TEST_NO_QUORUM_POLICY],[ AC_MSG_CHECKING([whether enum pe_quorum_policy defines value $1]) AC_LANG_PUSH([C]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [#include ], [enum pe_quorum_policy policy = $1; return policy;])], AC_DEFINE_UNQUOTED(m4_toupper(HAVE_ENUM_$1), 1, [Does pe_types.h have $1 value in enum pe_quorum_policy?]) AC_MSG_RESULT([yes]), AC_MSG_RESULT([no])) AC_LANG_POP([C]) ]) AC_TEST_NO_QUORUM_POLICY(no_quorum_demote) dnl check for new pe-API AC_CHECK_FUNCS(pe_new_working_set) dnl check if votequorum comes with default for qdevice-sync_timeout AC_CHECK_DECLS([VOTEQUORUM_QDEVICE_DEFAULT_SYNC_TIMEOUT], HAVE_DECL_VOTEQUORUM_QDEVICE_DEFAULT_SYNC_TIMEOUT=1, HAVE_DECL_VOTEQUORUM_QDEVICE_DEFAULT_SYNC_TIMEOUT=0, [#include ]) if test "$missing" = "yes"; then AC_MSG_ERROR([Missing required libraries or functions.]) fi AC_PATH_PROGS(POD2MAN, pod2man, pod2man) AC_ARG_ENABLE([shared-disk], [ --enable-shared-disk Turn on functionality that requires shared disk [default=yes]]) DISK=0 if test "x${enable_shared_disk}" != xno ; then DISK=1 fi AC_DEFINE_UNQUOTED(SUPPORT_SHARED_DISK, $DISK, Turn on functionality that requires shared disk) AM_CONDITIONAL(SUPPORT_SHARED_DISK, test "$DISK" = "1") if test -e /proc/$$ then echo "/proc/{pid} is supported" AC_DEFINE_UNQUOTED(HAVE_PROC_PID, 1, Define to 1 if /proc/{pid} is supported.) fi AC_DEFINE_UNQUOTED(CHECK_TWO_NODE, $HAVE_cmap, Turn on checking for 2-node cluster) AM_CONDITIONAL(CHECK_TWO_NODE, test "$HAVE_cmap" = "1") AC_DEFINE_UNQUOTED(CHECK_VOTEQUORUM_HANDLE, $HAVE_votequorum, Turn on periodic checking of votequorum-handle) AM_CONDITIONAL(CHECK_VOTEQUORUM_HANDLE, test "$HAVE_votequorum" = "1") AC_DEFINE_UNQUOTED(CHECK_QDEVICE_SYNC_TIMEOUT, ($HAVE_DECL_VOTEQUORUM_QDEVICE_DEFAULT_SYNC_TIMEOUT && $HAVE_cmap), Turn on checking if watchdog-timeout and qdevice-sync_timeout are matching) AM_CONDITIONAL(CHECK_QDEVICE_SYNC_TIMEOUT, test "$HAVE_DECL_VOTEQUORUM_QDEVICE_DEFAULT_SYNC_TIMEOUT" = "1" && test "$HAVE_cmap" = "1") AC_DEFINE_UNQUOTED(USE_PACEMAKERD_API, $HAVE_pacemakerd_api, Turn on synchronization between sbd & pacemakerd) AM_CONDITIONAL(USE_PACEMAKERD_API, test "$HAVE_pacemakerd_api" = "1") CONFIGDIR="" AC_ARG_WITH(configdir, [ --with-configdir=DIR Directory for SBD configuration file [${CONFIGDIR}]], [ CONFIGDIR="$withval" ] ) +dnl --runstatedir is available as of autoconf 2.70 (2020-12-08). When users +dnl have an older version, they can use our --with-runstatedir. +sbd_runstatedir="" +AC_ARG_WITH([runstatedir], + [AS_HELP_STRING([--with-runstatedir=DIR], + [modifiable per-process data @<:@LOCALSTATEDIR/run@:>@ (ignored if --runstatedir is available)])], + [ sbd_runstatedir="$withval" ] +) + SBD_WATCHDOG_TIMEOUT_DEFAULT="" AC_ARG_WITH(watchdog-timeout-default, [ --with-watchdog-timeout-default=SECONDS Timeout in seconds SBD will configure the watchdog per default], [ SBD_WATCHDOG_TIMEOUT_DEFAULT="$withval" ] ) SBD_SYNC_RESOURCE_STARTUP_DEFAULT="" AC_ARG_WITH(sync-resource-startup-default, [ --with-sync-resource-startup-default=yes|no Default for SBD_SYNC_RESOURCE_STARTUP if not given in SBD configuration file explicitly], [ SBD_SYNC_RESOURCE_STARTUP_DEFAULT="$withval" ] ) SBD_SYNC_RESOURCE_STARTUP_SYSCONFIG="" AC_ARG_WITH(sync-resource-startup-sysconfig, [ --with-sync-resource-startup-sysconfig=yes|no Value for SBD_SYNC_RESOURCE_STARTUP going into template SBD configuration file], [ SBD_SYNC_RESOURCE_STARTUP_SYSCONFIG="$withval" ] ) # # Where is dlopen? # if test "$ac_cv_lib_c_dlopen" = yes; then LIBADD_DL="" elif test "$ac_cv_lib_dl_dlopen" = yes; then LIBADD_DL=-ldl else LIBADD_DL=${lt_cv_dlopen_libs} fi dnl ********************************************************************** dnl Check for various argv[] replacing functions on various OSs dnl dnl Borrowed from Proftpd dnl Proftpd is Licenced under the terms of the GNU General Public Licence dnl and is available from http://www.proftpd.org/ dnl AC_CHECK_FUNCS(setproctitle) AC_CHECK_HEADERS(libutil.h) AC_CHECK_LIB(util, setproctitle, [AC_DEFINE(HAVE_SETPROCTITLE,1,[ ]) ac_cv_func_setproctitle="yes" ; LIBS="$LIBS -lutil"]) if test "$ac_cv_func_setproctitle" = "yes"; then pf_argv_set="PF_ARGV_NONE" fi if test "$pf_argv_set" = ""; then AC_CHECK_HEADERS(sys/pstat.h) if test "$ac_cv_header_pstat_h" = "yes"; then AC_CHECK_FUNCS(pstat) if test "$ac_cv_func_pstat" = "yes"; then pf_argv_set="PF_ARGV_PSTAT" else pf_argv_set="PF_ARGV_WRITEABLE" fi fi if test "$pf_argv_set" = ""; then AC_EGREP_HEADER([#define.*PS_STRINGS.*],sys/exec.h, have_psstrings="yes",have_psstrings="no") if test "$have_psstrings" = "yes"; then pf_argv_set="PF_ARGV_PSSTRINGS" fi fi if test "$pf_argv_set" = ""; then AC_CACHE_CHECK(whether __progname and __progname_full are available, pf_cv_var_progname, AC_TRY_LINK([extern char *__progname, *__progname_full;], [__progname = "foo"; __progname_full = "foo bar";], pf_cv_var_progname="yes", pf_cv_var_progname="no")) if test "$pf_cv_var_progname" = "yes"; then AC_DEFINE(HAVE___PROGNAME,1,[ ]) fi AC_CACHE_CHECK(which argv replacement method to use, pf_cv_argv_type, AC_EGREP_CPP(yes,[ #if defined(__GNU_HURD__) yes #endif ],pf_cv_argv_type="new", pf_cv_argv_type="writeable")) if test "$pf_cv_argv_type" = "new"; then pf_argv_set="PF_ARGV_NEW" fi if test "$pf_argv_set" = ""; then pf_argv_set="PF_ARGV_WRITEABLE" fi fi fi AC_DEFINE_UNQUOTED(PF_ARGV_TYPE, $pf_argv_set, mechanism to pretty-print ps output: setproctitle-equivalent) dnl End of tests borrowed from Proftpd AC_MSG_NOTICE(Sanitizing prefix: ${prefix}) case $prefix in NONE) prefix=/usr dnl Fix default variables - "prefix" variable if not specified if test "$localstatedir" = "\${prefix}/var"; then localstatedir="/var" fi if test "$sysconfdir" = "\${prefix}/etc"; then sysconfdir="/etc" fi ;; esac AC_MSG_NOTICE(Sanitizing exec_prefix: ${exec_prefix}) case $exec_prefix in dnl For consistency with Heartbeat, map NONE->$prefix NONE) exec_prefix=$prefix;; prefix) exec_prefix=$prefix;; esac -dnl Expand autoconf variables so that we dont end up with '${prefix}' -dnl in #defines and python scripts -dnl NOTE: Autoconf deliberately leaves them unexpanded to allow -dnl make exec_prefix=/foo install -dnl No longer being able to do this seems like no great loss to me... - -eval prefix="`eval echo ${prefix}`" -eval exec_prefix="`eval echo ${exec_prefix}`" -eval bindir="`eval echo ${bindir}`" -eval sbindir="`eval echo ${sbindir}`" -eval libexecdir="`eval echo ${libexecdir}`" -eval datadir="`eval echo ${datadir}`" -eval sysconfdir="`eval echo ${sysconfdir}`" -eval sharedstatedir="`eval echo ${sharedstatedir}`" -eval localstatedir="`eval echo ${localstatedir}`" -eval libdir="`eval echo ${libdir}`" -eval includedir="`eval echo ${includedir}`" -eval oldincludedir="`eval echo ${oldincludedir}`" -eval infodir="`eval echo ${infodir}`" -eval mandir="`eval echo ${mandir}`" +dnl Expand values of autoconf-provided directory options +expand_path_option prefix +expand_path_option exec_prefix +expand_path_option bindir +expand_path_option sbindir +expand_path_option libexecdir +expand_path_option datadir +expand_path_option sysconfdir +expand_path_option sharedstatedir +expand_path_option localstatedir +expand_path_option libdir +expand_path_option includedir +expand_path_option oldincludedir +expand_path_option infodir +expand_path_option mandir + +AS_IF([test x"${runstatedir}" = x""], [runstatedir="${sbd_runstatedir}"]) +expand_path_option runstatedir "${localstatedir}/run" +AC_SUBST(runstatedir) AC_SUBST(LIBADD_DL) dnl extra flags for dynamic linking libraries -if test x"${CONFIGDIR}" = x""; then - CONFIGDIR="${sysconfdir}/sysconfig" -fi +expand_path_option CONFIGDIR "${sysconfdir}/sysconfig" AC_SUBST(CONFIGDIR) if test x"${SBD_WATCHDOG_TIMEOUT_DEFAULT}" = x""; then case "$host_cpu" in s390|s390x) SBD_WATCHDOG_TIMEOUT_DEFAULT=15 ;; *) SBD_WATCHDOG_TIMEOUT_DEFAULT=5 ;; esac fi AC_SUBST(SBD_WATCHDOG_TIMEOUT_DEFAULT) AC_DEFINE_UNQUOTED(SBD_WATCHDOG_TIMEOUT_DEFAULT, $SBD_WATCHDOG_TIMEOUT_DEFAULT, Timeout in seconds SBD will configure the watchdog per default) if test x"${SBD_SYNC_RESOURCE_STARTUP_DEFAULT}" = x""; then SBD_SYNC_RESOURCE_STARTUP_DEFAULT=yes fi AC_SUBST(SBD_SYNC_RESOURCE_STARTUP_DEFAULT) dnl rather pass to C as a string and interpret there for consistent interpretation AC_DEFINE_UNQUOTED(SBD_SYNC_RESOURCE_STARTUP_DEFAULT, "${SBD_SYNC_RESOURCE_STARTUP_DEFAULT}", Default for SBD_SYNC_RESOURCE_STARTUP if not given in SBD configuration file explicitly) if test x"${SBD_SYNC_RESOURCE_STARTUP_SYSCONFIG}" = x""; then SBD_SYNC_RESOURCE_STARTUP_SYSCONFIG=${SBD_SYNC_RESOURCE_STARTUP_DEFAULT} fi AC_SUBST(SBD_SYNC_RESOURCE_STARTUP_SYSCONFIG) dnl The Makefiles and shell scripts we output AC_CONFIG_FILES([Makefile src/Makefile agent/Makefile man/Makefile agent/sbd src/sbd.service src/sbd_remote.service src/sbd.sh src/sbd.sysconfig sbd.pc]) AC_CONFIG_SUBDIRS([tests]) dnl Now process the entire list of files added by previous dnl calls to AC_CONFIG_FILES() AC_OUTPUT() diff --git a/man/Makefile.am b/man/Makefile.am index 995712d..ae4c14a 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1,13 +1,13 @@ dist_man_MANS = sbd.8 DISTCLEANFILES = sbd.8.pod sbd.8 sbd.sysconfig.pod sbd.sysconfig.pod: ../src/sbd.sysconfig sed -r -n -e "s/^## Type: (.*)/Allows C<\1>/;t type;s/^## Default: (.*)/ defaulting to C<\1>/;t default;s/^#*(.*)=.*/=item B<\1>\n/;t variable;s/^#*//;s/^ *//;H;d;:type;h;d;:default;H;x;s/\n//;x;d;:variable;G;p" $< > $@ sbd.8.pod: sbd.8.pod.in sbd.sysconfig.pod - sed -e "s/@environment_section@//;t insert;p;d;:insert;rsbd.sysconfig.pod" $< > $@ + sed -e "s,\@runstatedir\@,$(runstatedir)," $< |sed -e "s/@environment_section@//;t insert;p;d;:insert;rsbd.sysconfig.pod" > $@ sbd.8: sbd.8.pod @POD2MAN@ -s 8 -c "STONITH Block Device" -r "SBD" -n "SBD" $< $@ diff --git a/man/sbd.8.pod.in b/man/sbd.8.pod.in index e4ad5f8..21b3834 100644 --- a/man/sbd.8.pod.in +++ b/man/sbd.8.pod.in @@ -1,675 +1,675 @@ =head1 NAME sbd - STONITH Block Device daemon =head1 SYNOPSIS sbd <-d F> [options] C =head1 SUMMARY SBD provides a node fencing mechanism (Shoot the other node in the head, STONITH) for Pacemaker-based clusters through the exchange of messages via shared block storage such as for example a SAN, iSCSI, FCoE. This isolates the fencing mechanism from changes in firmware version or dependencies on specific firmware controllers, and it can be used as a STONITH mechanism in all configurations that have reliable shared storage. SBD can also be used without any shared storage. In this mode, the watchdog device will be used to reset the node if it loses quorum, if any monitored daemon is lost and not recovered or if Pacemaker decides that the node requires fencing. The F binary implements both the daemon that watches the message slots as well as the management tool for interacting with the block storage device(s). This mode of operation is specified via the C parameter; some of these modes take additional parameters. To use SBD with shared storage, you must first C the messaging layout on one to three block devices. Second, configure F to list those devices (and possibly adjust other options), and restart the cluster stack on each node to ensure that C is started. Third, configure the C fencing resource in the Pacemaker CIB. Each of these steps is documented in more detail below the description of the command options. C can only be used as root. =head2 GENERAL OPTIONS =over =item B<-d> F Specify the block device(s) to be used. If you have more than one, specify this option up to three times. This parameter is mandatory for all modes, since SBD always needs a block device to interact with. This man page uses F, F, and F as example device names for brevity. However, in your production environment, you should instead always refer to them by using the long, stable device name (e.g., F). =item B<-v|-vv|-vvv> Enable verbose|debug|debug-library logging (optional) =item B<-h> Display a concise summary of C options. =item B<-n> I Set local node name; defaults to C. This should not need to be set. =item B<-R> Do B enable realtime priority. By default, C runs at realtime priority, locks itself into memory, and also acquires highest IO priority to protect itself against interference from other processes on the system. This is a debugging-only option. =item B<-I> I Async IO timeout (defaults to 3 seconds, optional). You should not need to adjust this unless your IO setup is really very slow. (In daemon mode, the watchdog is refreshed when the majority of devices could be read within this time.) =back =head2 create Example usage: sbd -d /dev/sdc2 -d /dev/sdd3 create If you specify the I command, sbd will write a metadata header to the device(s) specified and also initialize the messaging slots for up to 255 nodes. B: This command will not prompt for confirmation. Roughly the first megabyte of the specified block device(s) will be overwritten immediately and without backup. This command accepts a few options to adjust the default timings that are written to the metadata (to ensure they are identical across all nodes accessing the device). =over =item B<-1> I Set watchdog timeout to N seconds. This depends mostly on your storage latency; the majority of devices must be successfully read within this time, or else the node will self-fence. If your sbd device(s) reside on a multipath setup or iSCSI, this should be the time required to detect a path failure. You may be able to reduce this if your device outages are independent, or if you are using the Pacemaker integration. =item B<-2> I Set slot allocation timeout to N seconds. You should not need to tune this. =item B<-3> I Set daemon loop timeout to N seconds. You should not need to tune this. =item B<-4> I Set I timeout to N seconds. This should be twice the I timeout. This is the time after which a message written to a node's slot will be considered delivered. (Or long enough for the node to detect that it needed to self-fence.) This also affects the I in Pacemaker's CIB; see below. =back =head2 list Example usage: # sbd -d /dev/sda1 list 0 hex-0 clear 1 hex-7 clear 2 hex-9 clear List all allocated slots on device, and messages. You should see all cluster nodes that have ever been started against this device. Nodes that are currently running should have a I state; nodes that have been fenced, but not yet restarted, will show the appropriate fencing message. =head2 dump Example usage: # sbd -d /dev/sda1 dump ==Dumping header on disk /dev/sda1 Header version : 2 Number of slots : 255 Sector size : 512 Timeout (watchdog) : 15 Timeout (allocate) : 2 Timeout (loop) : 1 Timeout (msgwait) : 30 ==Header on disk /dev/sda1 is dumped Dump meta-data header from device. =head2 watch Example usage: sbd -d /dev/sdc2 -d /dev/sdd3 -P watch This command will make C start in daemon mode. It will constantly monitor the message slot of the local node for incoming messages, reachability, and optionally take Pacemaker's state into account. C B be started on boot before the cluster stack! See below for enabling this according to your boot environment. The options for this mode are rarely specified directly on the commandline directly, but most frequently set via F. It also constantly monitors connectivity to the storage device, and self-fences in case the partition becomes unreachable, guaranteeing that it does not disconnect from fencing messages. A node slot is automatically allocated on the device(s) the first time the daemon starts watching the device; hence, manual allocation is not usually required. If a watchdog is used together with the C as is strongly recommended, the watchdog is activated at initial start of the sbd daemon. The watchdog is refreshed every time the majority of SBD devices has been successfully read. Using a watchdog provides additional protection against C crashing. If the Pacemaker integration is activated, C will B self-fence if device majority is lost, if: =over =item 1. The partition the node is in is still quorate according to the CIB; =item 2. it is still quorate according to Corosync's node count; =item 3. the node itself is considered online and healthy by Pacemaker. =back This allows C to survive temporary outages of the majority of devices. However, while the cluster is in such a degraded state, it can neither successfully fence nor be shutdown cleanly (as taking the cluster below the quorum threshold will immediately cause all remaining nodes to self-fence). In short, it will not tolerate any further faults. Please repair the system before continuing. There is one C process that acts as a master to which all watchers report; one per device to monitor the node's slot; and, optionally, one that handles the Pacemaker integration. =over =item B<-W> Enable or disable use of the system watchdog to protect against the sbd processes failing and the node being left in an undefined state. Specify this once to enable, twice to disable. Defaults to I. =item B<-w> F This can be used to override the default watchdog device used and should not usually be necessary. -=item B<-p> F +=item B<-p> F<@runstatedir@/sbd.pid> This option can be used to specify a pidfile for the main sbd process. =item B<-F> I Number of failures before a failing servant process will not be restarted immediately until the dampening delay has expired. If set to zero, servants will be restarted immediately and indefinitely. If set to one, a failed servant will be restarted once every B<-t> seconds. If set to a different value, the servant will be restarted that many times within the dampening period and then delay. Defaults to I<1>. =item B<-t> I Dampening delay before faulty servants are restarted. Combined with C<-F 1>, the most logical way to tune the restart frequency of servant processes. Default is 5 seconds. If set to zero, processes will be restarted indefinitely and immediately. =item B<-P> Enable Pacemaker integration which checks Pacemaker quorum and node health. Specify this once to enable, twice to disable. Defaults to I. =item B<-S> I Set the start mode. (Defaults to I<0>.) If this is set to zero, sbd will always start up unconditionally, regardless of whether the node was previously fenced or not. If set to one, sbd will only start if the node was previously shutdown cleanly (as indicated by an exit request message in the slot), or if the slot is empty. A reset, crashdump, or power-off request in any slot will halt the start up. This is useful to prevent nodes from rejoining if they were faulty. The node must be manually "unfenced" by sending an empty message to it: sbd -d /dev/sda1 message node1 clear =item B<-s> I Set the start-up wait time for devices. (Defaults to I<120>.) Dynamic block devices such as iSCSI might not be fully initialized and present yet. This allows one to set a timeout for waiting for devices to appear on start-up. If set to 0, start-up will be aborted immediately if no devices are available. =item B<-Z> Enable trace mode. B Specifying this once will turn all reboots or power-offs, be they caused by self-fence decisions or messages, into a crashdump. Specifying this twice will just log them but not continue running. =item B<-T> By default, the daemon will set the watchdog timeout as specified in the device metadata. However, this does not work for every watchdog device. In this case, you must manually ensure that the watchdog timeout used by the system correctly matches the SBD settings, and then specify this option to allow C to continue with start-up. =item B<-5> I Warn if the time interval for tickling the watchdog exceeds this many seconds. Since the node is unable to log the watchdog expiry (it reboots immediately without a chance to write its logs to disk), this is very useful for getting an indication that the watchdog timeout is too short for the IO load of the system. Default is about 3/5 of watchdog timeout, set to zero to disable. =item B<-C> I Watchdog timeout to set before crashdumping. If SBD is set to crashdump instead of reboot - either via the trace mode settings or the I fencing agent's parameter -, SBD will adjust the watchdog timeout to this setting before triggering the dump. Otherwise, the watchdog might trigger and prevent a successful crashdump from ever being written. Set to zero (= default) to disable. =item B<-r> I Actions to be executed when the watchers don't timely report to the sbd master process or one of the watchers detects that the master process has died. Set timeout-action to comma-separated combination of noflush|flush plus reboot|crashdump|off. If just one of both is given the other stays at the default. This doesn't affect actions like off, crashdump, reboot explicitly triggered via message slots. And it does as well not configure the action a watchdog would trigger should it run off (there is no generic interface). Defaults to flush,reboot. =back =head2 allocate Example usage: sbd -d /dev/sda1 allocate node1 Explicitly allocates a slot for the specified node name. This should rarely be necessary, as every node will automatically allocate itself a slot the first time it starts up on watch mode. =head2 message Example usage: sbd -d /dev/sda1 message node1 test Writes the specified message to node's slot. This is rarely done directly, but rather abstracted via the C fencing agent configured as a cluster resource. Supported message types are: =over =item test This only generates a log message on the receiving node and can be used to check if SBD is seeing the device. Note that this could overwrite a fencing request send by the cluster, so should not be used during production. =item reset Reset the target upon receipt of this message. =item off Power-off the target. =item crashdump Cause the target node to crashdump. =item exit This will make the C daemon exit cleanly on the target. You should B send this message manually; this is handled properly during shutdown of the cluster stack. Manually stopping the daemon means the node is unprotected! =item clear This message indicates that no real message has been sent to the node. You should not set this manually; C will clear the message slot automatically during start-up, and setting this manually could overwrite a fencing message by the cluster. =back =head2 query-watchdog Example usage: sbd query-watchdog Check for available watchdog devices and print some info. B: This command will arm the watchdog during query, and if your watchdog refuses disarming (for example, if its kernel module has the 'nowayout' parameter set) this will reset your system. =head2 test-watchdog Example usage: sbd test-watchdog [-w /dev/watchdog3] Test specified watchdog device (/dev/watchdog by default). B: This command will arm the watchdog and have your system reset in case your watchdog is working properly! If issued from an interactive session, it will prompt for confirmation. =head1 Base system configuration =head2 Configure a watchdog It is highly recommended that you configure your Linux system to load a watchdog driver with hardware assistance (as is available on most modern systems), such as I, I, or others. As a fall-back, you can use the I module. No other software must access the watchdog timer; it can only be accessed by one process at any given time. Some hardware vendors ship systems management software that use the watchdog for system resets (f.e. HP ASR daemon). Such software has to be disabled if the watchdog is to be used by SBD. =head2 Choosing and initializing the block device(s) First, you have to decide if you want to use one, two, or three devices. If you are using multiple ones, they should reside on independent storage setups. Putting all three of them on the same logical unit for example would not provide any additional redundancy. The SBD device can be connected via Fibre Channel, Fibre Channel over Ethernet, or even iSCSI. Thus, an iSCSI target can become a sort-of network-based quorum server; the advantage is that it does not require a smart host at your third location, just block storage. The SBD partitions themselves B be mirrored (via MD, DRBD, or the storage layer itself), since this could result in a split-mirror scenario. Nor can they reside on cLVM2 volume groups, since they must be accessed by the cluster stack before it has started the cLVM2 daemons; hence, these should be either raw partitions or logical units on (multipath) storage. The block device(s) must be accessible from all nodes. (While it is not necessary that they share the same path name on all nodes, this is considered a very good idea.) SBD will only use about one megabyte per device, so you can easily create a small partition, or very small logical units. (The size of the SBD device depends on the block size of the underlying device. Thus, 1MB is fine on plain SCSI devices and SAN storage with 512 byte blocks. On the IBM s390x architecture in particular, disks default to 4k blocks, and thus require roughly 4MB.) The number of devices will affect the operation of SBD as follows: =over =item One device In its most simple implementation, you use one device only. This is appropriate for clusters where all your data is on the same shared storage (with internal redundancy) anyway; the SBD device does not introduce an additional single point of failure then. If the SBD device is not accessible, the daemon will fail to start and inhibit startup of cluster services. =item Two devices This configuration is a trade-off, primarily aimed at environments where host-based mirroring is used, but no third storage device is available. SBD will not commit suicide if it loses access to one mirror leg; this allows the cluster to continue to function even in the face of one outage. However, SBD will not fence the other side while only one mirror leg is available, since it does not have enough knowledge to detect an asymmetric split of the storage. So it will not be able to automatically tolerate a second failure while one of the storage arrays is down. (Though you can use the appropriate crm command to acknowledge the fence manually.) It will not start unless both devices are accessible on boot. =item Three devices In this most reliable and recommended configuration, SBD will only self-fence if more than one device is lost; hence, this configuration is resilient against temporary single device outages (be it due to failures or maintenance). Fencing messages can still be successfully relayed if at least two devices remain accessible. This configuration is appropriate for more complex scenarios where storage is not confined to a single array. For example, host-based mirroring solutions could have one SBD per mirror leg (not mirrored itself), and an additional tie-breaker on iSCSI. It will only start if at least two devices are accessible on boot. =back After you have chosen the devices and created the appropriate partitions and perhaps multipath alias names to ease management, use the C command described above to initialize the SBD metadata on them. =head3 Sharing the block device(s) between multiple clusters It is possible to share the block devices between multiple clusters, provided the total number of nodes accessing them does not exceed I<255> nodes, and they all must share the same SBD timeouts (since these are part of the metadata). If you are using multiple devices this can reduce the setup overhead required. However, you should B share devices between clusters in different security domains. =head2 Configure SBD to start on boot On systems using C, the C or C system start-up scripts must handle starting or stopping C as required before starting the rest of the cluster stack. For C, sbd simply has to be enabled using systemctl enable sbd.service The daemon is brought online on each node before corosync and Pacemaker are started, and terminated only after all other cluster components have been shut down - ensuring that cluster resources are never activated without SBD supervision. =head2 Configuration via sysconfig The system instance of C is configured via F. In this file, you must specify the device(s) used, as well as any options to pass to the daemon: SBD_DEVICE="/dev/sda1;/dev/sdb1;/dev/sdc1" SBD_PACEMAKER="true" C will fail to start if no C is specified. See the installed template or section for configuration via environment for more options that can be configured here. In general configuration done via parameters takes precedence over the configuration from the configuration file. =head2 Configuration via environment =over @environment_section@ =back =head2 Testing the sbd installation After a restart of the cluster stack on this node, you can now try sending a test message to it as root, from this or any other node: sbd -d /dev/sda1 message node1 test The node will acknowledge the receipt of the message in the system logs: Aug 29 14:10:00 node1 sbd: [13412]: info: Received command test from node2 This confirms that SBD is indeed up and running on the node, and that it is ready to receive messages. Make B that F is identical on all cluster nodes, and that all cluster nodes are running the daemon. =head1 Pacemaker CIB integration =head2 Fencing resource Pacemaker can only interact with SBD to issue a node fence if there is a configure fencing resource. This should be a primitive, not a clone, as follows: primitive fencing-sbd stonith:external/sbd \ params pcmk_delay_max=30 This will automatically use the same devices as configured in F. While you should not configure this as a clone (as Pacemaker will register the fencing device on each node automatically), the I setting enables random fencing delay which ensures, in a scenario where a split-brain scenario did occur in a two node cluster, that one of the nodes has a better chance to survive to avoid double fencing. SBD also supports turning the reset request into a crash request, which may be helpful for debugging if you have kernel crashdumping configured; then, every fence request will cause the node to dump core. You can enable this via the C parameter on the fencing resource. This is B recommended for production use, but only for debugging phases. =head2 General cluster properties You must also enable STONITH in general, and set the STONITH timeout to be at least twice the I timeout you have configured, to allow enough time for the fencing message to be delivered. If your I timeout is 60 seconds, this is a possible configuration: property stonith-enabled="true" property stonith-timeout="120s" B: if I is too low for I and the system overhead, sbd will never be able to successfully complete a fence request. This will create a fencing loop. Note that the sbd fencing agent will try to detect this and automatically extend the I setting to a reasonable value, on the assumption that sbd modifying your configuration is preferable to not fencing. =head1 Management tasks =head2 Recovering from temporary SBD device outage If you have multiple devices, failure of a single device is not immediately fatal. C will retry to restart the monitor for the device every 5 seconds by default. However, you can tune this via the options to the I command. In case you wish the immediately force a restart of all currently disabled monitor processes, you can send a I to the SBD I process. =head1 LICENSE Copyright (C) 2008-2013 Lars Marowsky-Bree This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. For details see the GNU General Public License at http://www.gnu.org/licenses/gpl-2.0.html (version 2) and/or http://www.gnu.org/licenses/gpl.html (the newest as per "any later"). diff --git a/sbd.spec b/sbd.spec index 0498db1..7a0d1fb 100644 --- a/sbd.spec +++ b/sbd.spec @@ -1,289 +1,290 @@ # # spec file for package sbd # # Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # Copyright (c) 2013 Lars Marowsky-Bree # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ # %global longcommit 2a00ac70f7200ed238a5bc73392e6a59a06fe904 %global shortcommit %(echo %{longcommit}|cut -c1-8) %global modified %(echo %{longcommit}-|cut -f2 -d-) %global github_owner Clusterlabs %global commit_counter 0 %global build_counter 0 %global buildnum %(expr %{commit_counter} + %{build_counter}) %ifarch s390x s390 # minimum timeout on LPAR diag288 watchdog is 15s %global watchdog_timeout_default 15 %else %global watchdog_timeout_default 5 %endif # Be careful with sync_resource_startup_default # being enabled. This configuration has # to be in sync with configuration in pacemaker # where it is called sbd_sync - assure by e.g. # mutual rpm dependencies. %bcond_without sync_resource_startup_default # Syncing enabled per default will lead to # syncing enabled on upgrade without adaption # of the config. # Setting can still be overruled via sysconfig. # The setting in the config-template packaged # will follow the default if below is is left # empty. But it is possible to have the setting # in the config-template deviate from the default # by setting below to an explicit 'yes' or 'no'. %global sync_resource_startup_sysconfig "" Name: sbd Summary: Storage-based death License: GPLv2+ Group: System Environment/Daemons Version: 1.5.0 Release: 99.%{buildnum}.%{shortcommit}.%{modified}git%{?dist} Url: https://github.com/%{github_owner}/%{name} Source0: https://github.com/%{github_owner}/%{name}/archive/%{longcommit}/%{name}-%{longcommit}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: autoconf BuildRequires: automake BuildRequires: libuuid-devel BuildRequires: glib2-devel BuildRequires: libaio-devel BuildRequires: corosync-devel %if 0%{?suse_version} BuildRequires: libpacemaker-devel %else BuildRequires: pacemaker-libs-devel %endif BuildRequires: libtool BuildRequires: libuuid-devel BuildRequires: libxml2-devel BuildRequires: pkgconfig BuildRequires: make Conflicts: fence-agents-sbd < 4.5.0 %if 0%{?rhel} > 0 ExclusiveArch: i686 x86_64 s390x aarch64 ppc64le %endif %if %{defined systemd_requires} %systemd_requires %endif %description This package contains the storage-based death functionality. Available rpmbuild rebuild options: --with(out) : sync_resource_startup_default %package tests Summary: Storage-based death environment for regression tests License: GPLv2+ Group: System Environment/Daemons %description tests This package provides an environment + testscripts for regression-testing sbd. %prep ########################################################### # %setup -n sbd-%{version} -q %setup -q -n %{name}-%{longcommit} ########################################################### %build ./autogen.sh export CFLAGS="$RPM_OPT_FLAGS -Wall -Werror" %configure --with-watchdog-timeout-default=%{watchdog_timeout_default} \ --with-sync-resource-startup-default=%{?with_sync_resource_startup_default:yes}%{!?with_sync_resource_startup_default:no} \ - --with-sync-resource-startup-sysconfig=%{sync_resource_startup_sysconfig} + --with-sync-resource-startup-sysconfig=%{sync_resource_startup_sysconfig} \ + --with-runstatedir=%{_rundir} make %{?_smp_mflags} ########################################################### %install ########################################################### make DESTDIR=$RPM_BUILD_ROOT LIBDIR=%{_libdir} install rm -rf ${RPM_BUILD_ROOT}%{_libdir}/stonith install -D -m 0755 src/sbd.sh $RPM_BUILD_ROOT/usr/share/sbd/sbd.sh install -D -m 0755 tests/regressions.sh $RPM_BUILD_ROOT/usr/share/sbd/regressions.sh %if %{defined _unitdir} install -D -m 0644 src/sbd.service $RPM_BUILD_ROOT/%{_unitdir}/sbd.service install -D -m 0644 src/sbd_remote.service $RPM_BUILD_ROOT/%{_unitdir}/sbd_remote.service %endif mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig install -m 644 src/sbd.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/sbd # Don't package static libs find %{buildroot} -name '*.a' -type f -print0 | xargs -0 rm -f find %{buildroot} -name '*.la' -type f -print0 | xargs -0 rm -f %clean rm -rf %{buildroot} %if %{defined _unitdir} %post %systemd_post sbd.service %systemd_post sbd_remote.service %preun %systemd_preun sbd.service %systemd_preun sbd_remote.service %postun %systemd_postun sbd.service %systemd_postun sbd_remote.service %endif %files ########################################################### %defattr(-,root,root) %config(noreplace) %{_sysconfdir}/sysconfig/sbd %{_sbindir}/sbd %{_datadir}/sbd %{_datadir}/pkgconfig/sbd.pc %exclude %{_datadir}/sbd/regressions.sh %doc %{_mandir}/man8/sbd* %if %{defined _unitdir} %{_unitdir}/sbd.service %{_unitdir}/sbd_remote.service %endif %doc COPYING %files tests %defattr(-,root,root) %dir %{_datadir}/sbd %{_datadir}/sbd/regressions.sh %{_libdir}/libsbdtestbed* %changelog * Tue Jun 8 2021 - 1.5.0-99.0.2a00ac70.git - default to resource-syncing with pacemaker in spec-file and configure.ac This default has to match between sbd and pacemaker and thus qualifies this release for a minor-version-bump - fix some regressions introduced by adding configurability previously - adapt description of startup/shutdown sync with pacemaker - make watchdog warning messages more understandable * Wed Dec 2 2020 - 1.4.2-99.1.bfeee963.git - improve build/CI-friendlyness - * travis: switch to F32 as build-host - switch to F32 & leap-15.2 - changes for mock-2.0 - turn off loop-devices & device-mapper on x86_64 targets because - of changes in GCE - * regressions.sh: get timeouts from disk-header to go with proper defaults - for architecture - * use configure for watchdog-default-timeout & others - * ship sbd.pc with basic sbd build information for downstream packages - to use - * add number of commits since version-tag to build-counter - add robustness against misconfiguration / improve documentation - * add environment section to man-page previously just available in - template-config - * inform the user to restart the sbd service after disk-initialization - * refuse to start if any of the configured device names is invalid - * add handshake to sync startup/shutdown with pacemakerd - Previously sbd just waited for the cib-connnection to show up/go away - which isn't robust at all. - The new feature needs new pacemakerd-api as counterpart. - Thus build checks for presence of pacemakerd-api. - To simplify downstream adoption behavior is configurable at runtime - via configure-file with a build-time-configurable default. - * refuse to start if qdevice-sync_timeout doesn't match watchdog-timeout - Needed in particular as qdevice-sync_timeout delays quorum-state-update - and has a default of 30s that doesn't match the 5s watchdog-timeout - default. - Fix: sbd-pacemaker: handle new no_quorum_demote + robustness against new - policies added - Fix: agent: correctly compare string values when calculating timeout - Fix: scheduling: overhaul the whole thing - * prevent possible lockup when format in proc changes - * properly get and handle scheduler policy & prio - * on SCHED_RR failing push to the max with SCHED_OTHER * Tue Nov 19 2019 - 1.4.1-99.1.aca7907c.git - improvements/clarifications in documentation - properly finalize cmap connection when disconnected from cluster - make handling of cib-connection loss more robust - silence some coverity findings - overhaul log for reasonable prios and details - if current slice doesn't have rt-budget move to root-slice - periodically ping corosync daemon for liveness - actually use crashdump timeout if configured - avoid deprecated names for g_main-loop-funcitons - conflict with fence-agents-sbd < 4.5.0 - rather require corosync-devel provided by most distributions - make devices on cmdline overrule those coming via SBD_DEVICE - make 15s timeout on s390 be used consistently - improve build/test for CI-friendlyness - * add autogen.sh - * enable/improve out-of-tree-building - * make tar generation smarter - * don't modify sbd.spec - * make distcheck-target work - * Add tests/regressions.sh to check-target - * use unique devmapper names for multiple tests in parallel - * consistently use serial test-harness for visible progress - * package tests into separate package (not packaged before) - * add preload-library to intercept reboots while testing - * add tests for sbd in daemon-mode & watchdog-dev-handling - * make tests work in non-privileged containers * Mon Jan 14 2019 - 1.4.0-0.1.2d595fdd.git - updated travis-CI (ppc64le-build, fedora29, remove need for alectolytic-build-container) - make watchdog-device-query easier to be handled by an SELinux-policy - configurable delay value for SBD_DELAY_START - use pacemaker's new pe api with constructors/destructors - make timeout-action executed by sbd configurable - init script for sysv systems - version bump to v1.4.0 to denote Pacemaker 2.0.0 compatibility * Fri Jun 29 2018 - 1.3.1-0.1.e102d9ed.git - removed unneeded python-devel build-requirement - changed legacy corosync-devel to corosynclib-devel * Fri Nov 3 2017 - 1.3.1-0.1.a180176c.git - Add commands to test/query watchdogs - Allow 2-node-operation with a single shared-disk - Overhaul of the command-line options & config-file - Proper handling of off instead of reboot - Refactored disk-servant for more robust communication with parent - Fix config for Debian + configurable location of config - Fixes in sbd.sh - multiple SBD devices and others * Sun Mar 27 2016 - 1.3.0-0.1.4ee36fa3.git - Changes since v1.2.0 like adding the possibility to have a watchdog-only setup without shared-block-devices legitimate a bump to v1.3.0. * Mon Oct 13 2014 - 1.2.1-0.4.3de531ed.git - Fixes for suitability to the el7 environment * Tue Sep 30 2014 - 1.2.1-0.3.8f912945.git - Only build on archs supported by the HA Add-on * Fri Aug 29 2014 - 1.2.1-0.2.8f912945.git - Remove some additional SUSE-isms * Fri Aug 29 2014 - 1.2.1-0.1.8f912945.git - Prepare for package review Resolves: rhbz#1134245 diff --git a/src/sbd.service.in b/src/sbd.service.in index 94b0f99..a558a67 100644 --- a/src/sbd.service.in +++ b/src/sbd.service.in @@ -1,28 +1,28 @@ [Unit] Description=Shared-storage based fencing daemon Documentation=man:sbd(8) Before=pacemaker.service Before=dlm.service After=systemd-modules-load.service iscsi.service PartOf=corosync.service RefuseManualStop=true RefuseManualStart=true [Service] Type=forking -PIDFile=@localstatedir@/run/sbd.pid +PIDFile=@runstatedir@/sbd.pid EnvironmentFile=-@CONFIGDIR@/sbd -ExecStart=@sbindir@/sbd $SBD_OPTS -p @localstatedir@/run/sbd.pid watch +ExecStart=@sbindir@/sbd $SBD_OPTS -p @runstatedir@/sbd.pid watch ExecStop=@bindir@/kill -TERM $MAINPID # Could this benefit from exit codes for restart? # Does this need to be set to msgwait * 1.2? # TimeoutSec= # If SBD crashes, it'll very likely suicide immediately due to the # hardware watchdog. But one can always try. Restart=on-abort [Install] RequiredBy=corosync.service RequiredBy=pacemaker.service RequiredBy=dlm.service diff --git a/src/sbd.sh.in b/src/sbd.sh.in index cb867f1..f6ed9a8 100644 --- a/src/sbd.sh.in +++ b/src/sbd.sh.in @@ -1,135 +1,135 @@ #!/bin/bash # # Copyright (C) 2013 Lars Marowsky-Bree # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This software is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # ### BEGIN INIT INFO # Provides: sbd # Required-Start: $network $remote_fs # Should-Start: $syslog iscsi multipath-tools corosync # X-Start-Before: pacemaker # Required-Stop: $network $remote_fs # Should-Stop: iscsi multipath-tools corosync # X-Stop-After: pacemaker # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Shared-storage based fencing daemon # Description: SBD provides a node fencing mechanism for # Pacemaker-based clusters through the exchange of # messages via shared block storage such as for # example a SAN, iSCSI, FCoE. It can be used as # a STONITH mechanism in all configurations that # have reliable shared storage. ### END INIT INFO SBD_CONFIG=@CONFIGDIR@/sbd SBD_BIN="/usr/sbin/sbd" [ -e /lib/lsb/init-functions ] && . /lib/lsb/init-functions test -x $SBD_BIN || exit 1 test -f $SBD_CONFIG || exit 1 . $SBD_CONFIG unset LC_ALL; export LC_ALL unset LANGUAGE; export LANGUAGE : ${OCF_ROOT:=/usr/lib/ocf} : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs # Construct commandline for some common options if [ -z "$SBD_DEVICE" ]; then echo "No sbd devices defined" exit 1 fi SBD_DEVS=${SBD_DEVICE%;} SBD_DEVICE_ARGS="-d ${SBD_DEVS//;/ -d }" -: ${SBD_PIDFILE:=/var/run/sbd.pid} +: ${SBD_PIDFILE:=@runstatedir@/sbd.pid} SBD_OPTS+=" -p $SBD_PIDFILE" : ${SBD_PACEMAKER:="true"} if ocf_is_true "$SBD_PACEMAKER" ; then SBD_OPTS+=" -P" fi : ${SBD_WATCHDOG:="true"} if ! ocf_is_true "$SBD_WATCHDOG" ; then SBD_OPTS+=" -W -W" fi if [ -n "$SBD_WATCHDOG_DEV" ]; then SBD_OPTS+=" -w $SBD_WATCHDOG_DEV" fi : ${SBD_STARTMODE:="always"} case "$SBD_STARTMODE" in always) SBD_OPTS+=" -S 0" ;; clean) SBD_OPTS+=" -S 1" ;; esac : ${SBD_DELAY_START:="no"} start() { if ! pidofproc -p $SBD_PIDFILE $SBD_BIN >/dev/null 2>&1 ; then if ! $SBD_BIN $SBD_DEVICE_ARGS $SBD_OPTS watch ; then echo "SBD failed to start; aborting." exit 1 fi if ocf_is_true ${SBD_DELAY_START} ; then sleep $($SBD_BIN $SBD_DEVICE_ARGS dump | grep -m 1 msgwait | awk '{print $4}') 2>/dev/null fi else return 0 fi } stop() { if ! $SBD_BIN $SBD_DEVICE_ARGS -D $SBD_OPTS message LOCAL exit ; then echo "SBD failed to stop; aborting." exit 1 fi while pidofproc -p $SBD_PIDFILE $SBD_BIN >/dev/null 2>&1 ; do sleep 1 done } status() { if pidofproc -p $SBD_PIDFILE $SBD_BIN >/dev/null 2>&1 ; then echo "SBD is running." return 0 else echo "SBD is not running." return 1 fi } case "$1" in start|stop|status) $1 ;; restart|force-reload) stop; start ;; *) echo "Usage: $0 (start|stop|status|restart|force-reload)" exit 1 ;; esac # TODO: # - Make openais init script call out to this script too # - How to handle the former "force-start" option? # force-start) # SBD_OPTS="$SBD_OPTS -S 0" # start # ;; diff --git a/src/sbd_remote.service.in b/src/sbd_remote.service.in index cfcafb5..56675b1 100644 --- a/src/sbd_remote.service.in +++ b/src/sbd_remote.service.in @@ -1,25 +1,25 @@ [Unit] Description=Shared-storage based fencing daemon on pacemaker remote node Documentation=man:sbd(8) After=systemd-modules-load.service iscsi.service PartOf=pacemaker_remote.service RefuseManualStop=true RefuseManualStart=true [Service] Type=forking -PIDFile=@localstatedir@/run/sbd.pid +PIDFile=@runstatedir@/sbd.pid EnvironmentFile=-@CONFIGDIR@/sbd -ExecStart=@sbindir@/sbd $SBD_OPTS -p @localstatedir@/run/sbd.pid watch +ExecStart=@sbindir@/sbd $SBD_OPTS -p @runstatedir@/sbd.pid watch ExecStop=@bindir@/kill -TERM $MAINPID # Could this benefit from exit codes for restart? # Does this need to be set to msgwait * 1.2? # TimeoutSec= # If SBD crashes, it'll very likely suicide immediately due to the # hardware watchdog. But one can always try. Restart=on-abort [Install] RequiredBy=pacemaker_remote.service RequiredBy=dlm.service