Merge commit 'ronnie/master'
authorAndrew Tridgell <tridge@samba.org>
Tue, 7 Apr 2009 07:07:41 +0000 (17:07 +1000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 7 Apr 2009 07:07:41 +0000 (17:07 +1000)
38 files changed:
Makefile.in
client/ctdb_client.c
common/ctdb_util.c
common/system_aix.c
common/system_common.c [new file with mode: 0644]
common/system_linux.c
config/ctdb.init
config/ctdb.sysconfig
config/events.d/11.natgw [new file with mode: 0644]
config/events.d/50.samba
config/events.d/91.lvs
config/events.d/99.routing
config/functions
config/notify.sh [new file with mode: 0755]
doc/ctdb.1
doc/ctdb.1.html
doc/ctdb.1.xml
doc/ctdbd.1
doc/ctdbd.1.html
doc/ctdbd.1.xml
include/ctdb.h
include/ctdb_private.h
packaging/RPM/ctdb.spec
server/ctdb_control.c
server/ctdb_daemon.c
server/ctdb_logging.c
server/ctdb_ltdb_server.c
server/ctdb_monitor.c
server/ctdb_recover.c
server/ctdb_recoverd.c
server/ctdb_tunables.c
server/ctdbd.c
server/eventscript.c
tcp/tcp_connect.c
tcp/tcp_init.c
tools/ctdb.c
tools/ctdb_diagnostics
web/index.html

index 08f5bf4f9ef3c808f9286c887d31a2d1bd32a67c..b67818f81788d2ae20171b54fa7e688248e9d2f4 100755 (executable)
@@ -41,7 +41,7 @@ UTIL_OBJ = lib/util/idtree.o lib/util/db_wrap.o lib/util/strlist.o lib/util/util
 
 CTDB_COMMON_OBJ =  common/ctdb_io.o common/ctdb_util.o \
        common/ctdb_ltdb.o common/ctdb_message.o common/cmdline.o  \
-       lib/util/debug.o common/rb_tree.o @CTDB_SYSTEM_OBJ@
+       lib/util/debug.o common/rb_tree.o @CTDB_SYSTEM_OBJ@ common/system_common.o
 
 CTDB_TCP_OBJ = tcp/tcp_connect.o tcp/tcp_io.o tcp/tcp_init.o
 
@@ -206,6 +206,7 @@ install: all
        ${INSTALLCMD} -m 644 doc/recovery-process.txt $(DESTDIR)$(docdir)/ctdb/recovery-process.txt
        ${INSTALLCMD} -m 755 config/events.d/00.ctdb $(DESTDIR)$(etcdir)/ctdb/events.d
        ${INSTALLCMD} -m 755 config/events.d/10.interface $(DESTDIR)$(etcdir)/ctdb/events.d
+       ${INSTALLCMD} -m 755 config/events.d/11.natgw $(DESTDIR)$(etcdir)/ctdb/events.d
        ${INSTALLCMD} -m 755 config/events.d/20.multipathd $(DESTDIR)$(etcdir)/ctdb/events.d
        ${INSTALLCMD} -m 755 config/events.d/40.vsftpd $(DESTDIR)$(etcdir)/ctdb/events.d
        ${INSTALLCMD} -m 755 config/events.d/41.httpd $(DESTDIR)$(etcdir)/ctdb/events.d
@@ -222,6 +223,7 @@ install: all
        if [ -f doc/ctdb.1 ];then ${INSTALLCMD} -m 644 doc/ctdb.1 $(DESTDIR)$(mandir)/man1; fi
        if [ -f doc/ctdbd.1 ];then ${INSTALLCMD} -m 644 doc/ctdbd.1 $(DESTDIR)$(mandir)/man1; fi
        if [ -f doc/onnode.1 ];then ${INSTALLCMD} -m 644 doc/onnode.1 $(DESTDIR)$(mandir)/man1; fi
+       if [ ! -f $(DESTDIR)$(etcdir)/ctdb/notify.sh ];then ${INSTALLCMD} -m 644 config/notify.sh $(DESTDIR)$(etcdir)/ctdb; fi
 
 test: all
        tests/run_tests.sh
index 16fc03b48ab2a6878cd8104c6ae9aa90d0071e8a..3bdb4b2617d3ed38c7f06f8722b4501ef13aac4b 100644 (file)
@@ -3472,3 +3472,146 @@ int ctdb_ctrl_recd_ping(struct ctdb_context *ctdb)
 
        return 0;
 }
+
+/* when forking the main daemon and the child process needs to connect back
+ * to the daemon as a client process, this function can be used to change
+ * the ctdb context from daemon into client mode
+ */
+int switch_from_server_to_client(struct ctdb_context *ctdb)
+{
+       int ret;
+
+       /* shutdown the transport */
+       if (ctdb->methods) {
+               ctdb->methods->shutdown(ctdb);
+       }
+
+       /* get a new event context */
+       talloc_free(ctdb->ev);
+       ctdb->ev = event_context_init(ctdb);
+
+       close(ctdb->daemon.sd);
+       ctdb->daemon.sd = -1;
+
+       /* the client does not need to be realtime */
+       if (ctdb->do_setsched) {
+               ctdb_restore_scheduler(ctdb);
+       }
+
+       /* initialise ctdb */
+       ret = ctdb_socket_connect(ctdb);
+       if (ret != 0) {
+               DEBUG(DEBUG_ALERT, (__location__ " Failed to init ctdb client\n"));
+               return -1;
+       }
+
+        return 0;
+}
+
+/*
+  tell the main daemon we are starting a new monitor event script
+ */
+int ctdb_ctrl_event_script_init(struct ctdb_context *ctdb)
+{
+       int ret;
+       int32_t res;
+
+       ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, 0, CTDB_CONTROL_EVENT_SCRIPT_INIT, 0, tdb_null, 
+                          ctdb, NULL, &res, NULL, NULL);
+       if (ret != 0 || res != 0) {
+               DEBUG(DEBUG_ERR,("Failed to send event_script_init\n"));
+               return -1;
+       }
+
+       return 0;
+}
+
+/*
+  tell the main daemon we are starting a new monitor event script
+ */
+int ctdb_ctrl_event_script_finished(struct ctdb_context *ctdb)
+{
+       int ret;
+       int32_t res;
+
+       ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, 0, CTDB_CONTROL_EVENT_SCRIPT_FINISHED, 0, tdb_null, 
+                          ctdb, NULL, &res, NULL, NULL);
+       if (ret != 0 || res != 0) {
+               DEBUG(DEBUG_ERR,("Failed to send event_script_init\n"));
+               return -1;
+       }
+
+       return 0;
+}
+
+/*
+  tell the main daemon we are starting to run an eventscript
+ */
+int ctdb_ctrl_event_script_start(struct ctdb_context *ctdb, const char *name)
+{
+       int ret;
+       int32_t res;
+       TDB_DATA data;
+
+       data.dptr = discard_const(name);
+       data.dsize = strlen(name)+1;
+
+       ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, 0, CTDB_CONTROL_EVENT_SCRIPT_START, 0, data, 
+                          ctdb, NULL, &res, NULL, NULL);
+       if (ret != 0 || res != 0) {
+               DEBUG(DEBUG_ERR,("Failed to send event_script_start\n"));
+               return -1;
+       }
+
+       return 0;
+}
+
+/*
+  tell the main daemon the status of the script we ran
+ */
+int ctdb_ctrl_event_script_stop(struct ctdb_context *ctdb, int32_t result)
+{
+       int ret;
+       int32_t res;
+       TDB_DATA data;
+
+       data.dptr = (uint8_t *)&result;
+       data.dsize = sizeof(result);
+
+       ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, 0, CTDB_CONTROL_EVENT_SCRIPT_STOP, 0, data, 
+                          ctdb, NULL, &res, NULL, NULL);
+       if (ret != 0 || res != 0) {
+               DEBUG(DEBUG_ERR,("Failed to send event_script_stop\n"));
+               return -1;
+       }
+
+       return 0;
+}
+
+
+/*
+  get the status of running the monitor eventscripts
+ */
+int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb, 
+               struct timeval timeout, uint32_t destnode, 
+               TALLOC_CTX *mem_ctx,
+               struct ctdb_monitoring_wire **script_status)
+{
+       int ret;
+       TDB_DATA outdata;
+       int32_t res;
+
+       ret = ctdb_control(ctdb, destnode, 0, 
+                          CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS, 0, tdb_null, 
+                          mem_ctx, &outdata, &res, &timeout, NULL);
+       if (ret != 0 || res != 0 || outdata.dsize == 0) {
+               DEBUG(DEBUG_ERR,(__location__ " ctdb_control for getscriptstatus failed ret:%d res:%d\n", ret, res));
+               return -1;
+       }
+
+       *script_status = (struct ctdb_monitoring_wire *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
+       talloc_free(outdata.dptr);
+                   
+       return 0;
+}
+
index 33d30e2108447535d062154cd5661e308e8d52fb..a3f1731fa1370d188758a63ace1f2bcdb796ac67 100644 (file)
@@ -435,7 +435,7 @@ bool parse_ip_port(const char *addr, ctdb_sock_addr *saddr)
 
 
        /* now is this a ipv4 or ipv6 address ?*/
-       ret = parse_ip(s, NULL, addr);
+       ret = parse_ip(s, NULL, port, saddr);
 
        talloc_free(tmp_ctx);
        return ret;
@@ -444,7 +444,7 @@ bool parse_ip_port(const char *addr, ctdb_sock_addr *saddr)
 /*
   parse an ip
  */
-bool parse_ip(const char *addr, const char *iface, ctdb_sock_addr *saddr)
+bool parse_ip(const char *addr, const char *iface, unsigned port, ctdb_sock_addr *saddr)
 {
        char *p;
        bool ret;
@@ -452,9 +452,9 @@ bool parse_ip(const char *addr, const char *iface, ctdb_sock_addr *saddr)
        /* now is this a ipv4 or ipv6 address ?*/
        p = index(addr, ':');
        if (p == NULL) {
-               ret = parse_ipv4(addr, 0, &saddr->ip);
+               ret = parse_ipv4(addr, port, &saddr->ip);
        } else {
-               ret = parse_ipv6(addr, iface, 0, saddr);
+               ret = parse_ipv6(addr, iface, port, saddr);
        }
 
        return ret;
@@ -496,7 +496,7 @@ bool parse_ip_mask(const char *str, const char *iface, ctdb_sock_addr *addr, uns
 
 
        /* now is this a ipv4 or ipv6 address ?*/
-       ret = parse_ip(s, iface, addr);
+       ret = parse_ip(s, iface, 0, addr);
 
        talloc_free(tmp_ctx);
        return ret;
@@ -575,6 +575,21 @@ char *ctdb_addr_to_str(ctdb_sock_addr *addr)
        return cip;
 }
 
+unsigned ctdb_addr_to_port(ctdb_sock_addr *addr)
+{
+       switch (addr->sa.sa_family) {
+       case AF_INET:
+               return ntohs(addr->ip.sin_port);
+               break;
+       case AF_INET6:
+               return ntohs(addr->ip6.sin6_port);
+               break;
+       default:
+               DEBUG(DEBUG_ERR, (__location__ " ERROR, unknown family %u\n", addr->sa.sa_family));
+       }
+
+       return 0;
+}
 
 void ctdb_block_signal(int signum)
 {
index d5ca4778646a8e4c8619ad5af525bd018ba9e38b..5fe54130d423595d34523c71a120a4a20d850093 100644 (file)
@@ -66,23 +66,6 @@ int ctdb_sys_open_sending_socket(void)
 }
 #endif
 
-/*
-  uint16 checksum for n bytes
- */
-static uint32_t uint16_checksum(uint16_t *data, size_t n)
-{
-       uint32_t sum=0;
-       while (n>=2) {
-               sum += (uint32_t)ntohs(*data);
-               data++;
-               n -= 2;
-       }
-       if (n == 1) {
-               sum += (uint32_t)ntohs(*(uint8_t *)data);
-       }
-       return sum;
-}
-
 /*
   simple TCP checksum - assumes data is multiple of 2 bytes long
  */
@@ -187,41 +170,6 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
        return 0;
 }
 
-
-/*
-  see if we currently have an interface with the given IP
-
-  we try to bind to it, and if that fails then we don't have that IP
-  on an interface
- */
-bool ctdb_sys_have_ip(ctdb_sock_addr *_addr)
-{
-       int s;
-       int ret;
-       ctdb_sock_addr __addr = *_addr;
-       ctdb_sock_addr *addr = &__addr;
-       
-       switch (addr->sa.sa_family) {
-       case AF_INET:
-               addr->ip.sin_port = 0;
-               break;
-       case AF_INET6:
-               addr->ip6.sin6_port = 0;
-               break;
-       }
-
-       s = socket(addr->sa.sa_family, SOCK_STREAM, IPPROTO_TCP);
-       if (s == -1) {
-               return false;
-       }
-       ret = bind(s, (struct sockaddr *)addr, sizeof(ctdb_sock_addr));
-       close(s);
-       return ret == 0;
-}
-
-
-
-
 /* This function is used to open a raw socket to capture from
  */
 int ctdb_sys_open_capture_socket(const char *iface, void **private_data)
diff --git a/common/system_common.c b/common/system_common.c
new file mode 100644 (file)
index 0000000..9aa4620
--- /dev/null
@@ -0,0 +1,72 @@
+/* 
+   ctdb system specific code to manage raw sockets on linux
+
+   Copyright (C) Ronnie Sahlberg  2007
+   Copyright (C) Andrew Tridgell  2007
+
+   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 3 of the License, or
+   (at your option) any later version.
+   
+   This program 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "system/network.h"
+
+/*
+  uint16 checksum for n bytes
+ */
+uint32_t uint16_checksum(uint16_t *data, size_t n)
+{
+       uint32_t sum=0;
+       while (n>=2) {
+               sum += (uint32_t)ntohs(*data);
+               data++;
+               n -= 2;
+       }
+       if (n == 1) {
+               sum += (uint32_t)ntohs(*(uint8_t *)data);
+       }
+       return sum;
+}
+
+/*
+  see if we currently have an interface with the given IP
+
+  we try to bind to it, and if that fails then we don't have that IP
+  on an interface
+ */
+bool ctdb_sys_have_ip(ctdb_sock_addr *_addr)
+{
+       int s;
+       int ret;
+       ctdb_sock_addr __addr = *_addr;
+       ctdb_sock_addr *addr = &__addr;
+
+       switch (addr->sa.sa_family) {
+       case AF_INET:
+               addr->ip.sin_port = 0;
+               break;
+       case AF_INET6:
+               addr->ip6.sin6_port = 0;
+               break;
+       }
+
+       s = socket(addr->sa.sa_family, SOCK_STREAM, IPPROTO_TCP);
+       if (s == -1) {
+               return false;
+       }
+
+       ret = bind(s, (struct sockaddr *)addr, sizeof(ctdb_sock_addr));
+
+       close(s);
+       return ret == 0;
+}
index 0d5ea631b9d1118e3ae6346dee04952205886b96..a771e3ba04f377697bac8b4db93d79b8a9378b49 100644 (file)
 #define ETHERTYPE_IP6 0x86dd
 #endif
 
-/*
-  uint16 checksum for n bytes
- */
-static uint32_t uint16_checksum(uint16_t *data, size_t n)
-{
-       uint32_t sum=0;
-       while (n>=2) {
-               sum += (uint32_t)ntohs(*data);
-               data++;
-               n -= 2;
-       }
-       if (n == 1) {
-               sum += (uint32_t)ntohs(*(uint8_t *)data);
-       }
-       return sum;
-}
-
 /*
   calculate the tcp checksum for tcp over ipv6
 */
@@ -404,40 +387,6 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
        return 0;
 }
 
-
-/*
-  see if we currently have an interface with the given IP
-
-  we try to bind to it, and if that fails then we don't have that IP
-  on an interface
-
-  ifname, if non-NULL, will return the name of the interface this ip is tied to
- */
-bool ctdb_sys_have_ip(ctdb_sock_addr *_addr)
-{
-       int s;
-       int ret;
-       ctdb_sock_addr __addr = *_addr;
-       ctdb_sock_addr *addr = &__addr;
-
-       switch (addr->sa.sa_family) {
-       case AF_INET:
-               addr->ip.sin_port = 0;
-               break;
-       case AF_INET6:
-               addr->ip6.sin6_port = 0;
-               break;
-       }
-       s = socket(addr->sa.sa_family, SOCK_STREAM, IPPROTO_TCP);
-       if (s == -1) {
-               return false;
-       }
-       ret = bind(s, (struct sockaddr *)addr, sizeof(ctdb_sock_addr));
-
-       close(s);
-       return ret == 0;
-}
-
 /* 
    This function is used to open a raw socket to capture from
  */
index 046bc5208e862c504f92c2aa4ade9e4b5a741ba3..24a206dbbfda9dbeb4a83d7c41bf888c6728001a 100755 (executable)
@@ -64,6 +64,7 @@ CTDB_OPTIONS="$CTDB_OPTIONS --reclock=$CTDB_RECOVERY_LOCK"
 [ -z "$CTDB_EVENT_SCRIPT_DIR" ] || CTDB_OPTIONS="$CTDB_OPTIONS --event-script-dir $CTDB_EVENT_SCRIPT_DIR"
 [ -z "$CTDB_TRANSPORT" ]        || CTDB_OPTIONS="$CTDB_OPTIONS --transport $CTDB_TRANSPORT"
 [ -z "$CTDB_DEBUGLEVEL" ]       || CTDB_OPTIONS="$CTDB_OPTIONS -d $CTDB_DEBUGLEVEL"
+[ -z "$CTDB_NOTIFY_SCRIPT" ]       || CTDB_OPTIONS="$CTDB_OPTIONS --notification-script=$CTDB_NOTIFY_SCRIPT"
 [ -z "$CTDB_START_AS_DISABLED" ] || [ "$CTDB_START_AS_DISABLED" != "yes" ] || {
        CTDB_OPTIONS="$CTDB_OPTIONS --start-as-disabled"
 }
@@ -74,7 +75,7 @@ CTDB_OPTIONS="$CTDB_OPTIONS --reclock=$CTDB_RECOVERY_LOCK"
        CTDB_OPTIONS="$CTDB_OPTIONS --no-lmaster"
 }
 [ -z "$CTDB_LVS_PUBLIC_IP" ] || {
-       CTDB_OPTIONS="$CTDB_OPTIONS --lvs"
+       CTDB_OPTIONS="$CTDB_OPTIONS --lvs --single-public-ip=$CTDB_LVS_PUBLIC_IP"
 }
 [ -z "$CTDB_SCRIPT_LOG_LEVEL" ] || {
        CTDB_OPTIONS="$CTDB_OPTIONS --script-log-level=$CTDB_SCRIPT_LOG_LEVEL"
index db5d16c3fec84573560a3e80f9bfff50af140118..f1f367636f87ce1dc150e98f9636900df37da79f 100644 (file)
 # should ctdb manage starting/stopping the NFS service
 # CTDB_MANAGES_NFS=yes
 
+# should ctdb manage starting/stopping the Apache web server httpd?
+# CTDB_MANAGES_HTTPD
+
+# The init style (redhat/suse/ubuntu...) is usually auto-detected.
+# The names of init scripts of services managed by CTDB are set
+# based on the detected init style. You can override the init style
+# auto-detection here to explicitly use a scheme. This might be
+# useful when you have installed a packages (for instance samba
+# packages) with a different init script layout.
+# There is no default.
+# CTDB_INIT_STYLE=redhat
+
+# The following are specific Samba init scripts / services that you
+# can override from auto-detection.
+# There are no defaults.
+# CTDB_SERVICE_SMB=smb
+# CTDB_SERVICE_NMB=nmb
+# CTDB_SERVICE_WINBIND=winbind
 
 # you may wish to raise the file descriptor limit for ctdb
 # use a ulimit command here. ctdb needs one file descriptor per
@@ -77,6 +95,9 @@
 # defaults to /etc/ctdb/nodes
 # CTDB_NODES=/etc/ctdb/nodes
 
+# a script to run when node health changes
+# CTDB_NOTIFY_SCRIPT=/etc/ctdb/notify.sh
+
 # the directory to put the local ctdb database files in
 # defaults to /var/ctdb
 # CTDB_DBDIR=/var/ctdb
 # CTDB_CAPABILITY_RECMASTER=yes
 # CTDB_CAPABILITY_LMASTER=yes
 
+# NAT-GW configuration
+# Some services running on nthe CTDB node may need to originate traffic to
+# remote servers before the node is assigned any IP addresses,
+# This is problematic since before the node has public addresses the node might
+# not be able to route traffic to the public networks.
+# One solution is to have static public addresses assigned with routing
+# in addition to the public address interfaces, thus guaranteeing that
+# a node always can route traffic to the external network.
+# This is the most simple solution but it uses up a large number of 
+# additional ip addresses.
+#
+# A more complex solution is NAT-GW.
+# In this mode we only need one additional ip address for the cluster from
+# the exsternal public network.
+# One of the nodes in the cluster is elected to be hosting this ip address
+# so it can reach the external services. This node is also configured
+# to use NAT MASQUERADING for all traffic from the internal private network
+# to the external network. This node is the NAT-GW node.
+#
+# All other nodes are set up with a default rote with a metric of 10 to point
+# to the nat-gw node.
+# 
+# The effect of this is that only when a node does not have a public address
+# and thus no proper routes to the external world it will instead
+# route all packets through the nat-gw node.
+#
+# NATGW_NODES is the list of nodes that belong to this natgw group.
+# You can have multiple natgw groups in one cluster but each node
+# can only belong to one single natgw group.
+#
+# NATGW_PUBLIC_IP=10.0.0.227/24
+# NATGW_PUBLIC_IFACE=eth0
+# NATGW_DEFAULT_GATEWAY=10.0.0.1
+# NATGW_PRIVATE_IFACE=eth1
+# NATGW_PRIVATE_NETWORK=10.1.1.0/24
+# NATGW_NODES=/etc/ctdb/natgw_nodes
+
 # where to log messages
 # the default is /var/log/log.ctdb
 # CTDB_LOGFILE=/var/log/log.ctdb
diff --git a/config/events.d/11.natgw b/config/events.d/11.natgw
new file mode 100644 (file)
index 0000000..2d256ba
--- /dev/null
@@ -0,0 +1,66 @@
+#!/bin/sh
+# Script to set up one of the nodes as a NAT gateway for all other nodes.
+# This is used to ensure that all nodes in the cluster can still originate
+# traffic to the external network even if there are no public addresses
+# available.
+#
+
+. $CTDB_BASE/functions
+loadconfig ctdb
+
+[ -z "$NATGW_PUBLIC_IFACE" ] && exit 0
+
+cmd="$1"
+shift
+PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
+
+delete_all() {
+       ip addr add $NATGW_PUBLIC_IP dev $NATGW_PUBLIC_IFACE >/dev/null 2>/dev/null
+       ip addr del $NATGW_PUBLIC_IP_HOST dev $NATGW_PRIVATE_IFACE >/dev/null 2>/dev/null
+       ip route del 0.0.0.0/0 metric 10 >/dev/null 2>/dev/null
+
+       # Delete the masquerading setup from a previous iteration where we
+       # were the NAT-GW
+       iptables -D POSTROUTING -t nat -s $NATGW_PRIVATE_NETWORK -d ! $NATGW_PRIVATE_NETWORK -j MASQUERADE >/dev/null 2>/dev/null
+
+       ip addr del $NATGW_PUBLIC_IP dev $NATGW_PUBLIC_IFACE >/dev/null 2>/dev/null
+}
+
+case $cmd in 
+     recovered)
+       MYPNN=`ctdb pnn | cut -d: -f2`
+       NATGWMASTER=`ctdb natgwlist | head -1`
+       NATGWIP=`ctdb natgwlist | tail --lines=+2 | head -1 | cut -d: -f3`
+
+       NATGW_PUBLIC_IP_HOST=`echo $NATGW_PUBLIC_IP | sed -e "s/\/.*/\/32/"`
+
+       delete_all
+
+       if [ "$MYPNN" == "$NATGWMASTER" ]; then
+               # This is the first node, set it up as the NAT GW
+               echo 1 >/proc/sys/net/ipv4/ip_forward
+               iptables -A POSTROUTING -t nat -s $NATGW_PRIVATE_NETWORK -d ! $NATGW_PRIVATE_NETWORK -j MASQUERADE
+               ip addr add $NATGW_PUBLIC_IP dev $NATGW_PUBLIC_IFACE
+               ip route add 0.0.0.0/0 via $NATGW_DEFAULT_GATEWAY >/dev/null 2>/dev/null
+       else
+               # This is not the NAT-GW
+               # Assign the public ip to the private interface and make
+               # sure we dont respond to ARPs.
+               # We do this so that the ip address will exist on a
+               # non-loopback interface so that samba may send it along in the
+               # KDC requests.
+               ip addr add $NATGW_PUBLIC_IP_HOST dev $NATGW_PRIVATE_IFACE
+               ip route add 0.0.0.0/0 via $NATGWIP metric 10
+       fi
+
+       # flush our route cache
+       echo 1 > /proc/sys/net/ipv4/route/flush
+       ;;
+
+     shutdown)
+       delete_all
+       ;;
+
+esac
+
+exit 0
index 3e7164abaf3186220a695543792706fef291baf0..e0e2ad7bb5b307d68844d43228b9798980a7b42c 100755 (executable)
@@ -11,25 +11,25 @@ detect_init_style
 
 case $CTDB_INIT_STYLE in
        suse)
-               CTDB_SERVICE_SMB="smb"
-               CTDB_SERVICE_NMB="nmb"
-               CTDB_SERVICE_WINBIND="winbind"
+               CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb}
+               CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-nmb}
+               CTDB_SERVICE_WINBIND=${CTDB_SERVICE_WINBIND:-winbind}
                ;;
        ubuntu)
-               CTDB_SERVICE_SMB="samba"
-               CTDB_SERVICE_NMB=""
-               CTDB_SERVICE_WINBIND="winbind"
+               CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-samba}
+               CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-""}
+               CTDB_SERVICE_WINBIND=${CTDB_SERVICE_WINBIND:-winbind}
                ;;
        redhat)
-               CTDB_SERVICE_SMB="smb"
-               CTDB_SERVICE_NMB=""
-               CTDB_SERVICE_WINBIND="winbind"
+               CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb}
+               CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-""}
+               CTDB_SERVICE_WINBIND=${CTDB_SERVICE_WINBIND:-winbind}
                ;;
        *)
                # should not happen, but for now use redhat style as default:
-               CTDB_SERVICE_SMB="smb"
-               CTDB_SERVICE_NMB=""
-               CTDB_SERVICE_WINBIND="winbind"
+               CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb}
+               CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-""}
+               CTDB_SERVICE_WINBIND=${CTDB_SERVICE_WINBIND:-winbind}
                ;;
 esac
 
index 4860030aeab6ef0b4a10808ca2e25b4359ff7da8..2411d1e0bf634a298593423da5be5414edcf901e 100755 (executable)
@@ -52,7 +52,7 @@ case $cmd in
        # kill off any tcp connections
        ipvsadm -D -t $CTDB_LVS_PUBLIC_IP:0
        ipvsadm -D -u $CTDB_LVS_PUBLIC_IP:0
-       kill_tcp_connections $CTDB_LVS_PUBLIC_IP
+       kill_tcp_connections_local_only $CTDB_LVS_PUBLIC_IP
 
        PNN=`ctdb pnn | sed -e "s/.*PNN://"`
        LVSMASTER=`ctdb lvsmaster | sed -e "s/.*Node //" -e "s/ .*//"`
index ec0a7bf29c3267f849f363d30ad04e57483d894e..06741939e53c832b320c81f916c9c8144f12f9ea 100755 (executable)
@@ -24,10 +24,10 @@ shift
 PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
 
 case $cmd in 
-     takeip)
+     takeip|releaseip)
        iface=$1
        cat $CTDB_BASE/static-routes | egrep "^$iface " | while read IFACE DEST GW; do
-               route add -net $DEST gw $GW
+           ip route add $DEST via $GW dev $IFACE >/dev/null 2>/dev/null
        done
 
        ;;
index 1073055f9bbf48cd25c0231f2ed96d464a46d116..2f0b01fe242883489882892c134ee247b4ba15a7 100644 (file)
@@ -311,6 +311,48 @@ kill_tcp_connections() {
     echo "killed $_killcount TCP connections to released IP $_IP"
 }
 
+##################################################################
+# kill off the local end for any TCP connections with the given IP
+##################################################################
+kill_tcp_connections_local_only() {
+    _IP="$1"    
+    _failed=0
+
+    _killcount=0
+    connfile="$CTDB_BASE/state/connections.$_IP"
+    netstat -tn |egrep "^tcp.*[[:space:]]+$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' > $connfile
+    netstat -tn |egrep "^tcp.*[[:space:]]+::ffff:$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' >> $connfile
+
+    while read dest src; do
+       srcip=`echo $src | sed -e "s/:[^:]*$//"`
+       srcport=`echo $src | sed -e "s/^.*://"`
+       destip=`echo $dest | sed -e "s/:[^:]*$//"`
+       destport=`echo $dest | sed -e "s/^.*://"`
+       echo "Killing TCP connection $srcip:$srcport $destip:$destport"
+       ctdb killtcp $srcip:$srcport $destip:$destport >/dev/null 2>&1 || _failed=1
+       _killcount=`expr $_killcount + 1`
+     done < $connfile
+    /bin/rm -f $connfile
+
+    [ $_failed = 0 ] || {
+       echo "Failed to send killtcp control"
+       return;
+    }
+    [ $_killcount -gt 0 ] || {
+       return;
+    }
+    _count=0
+    while netstat -tn |egrep "^tcp.*[[:space:]]+$_IP:.*ESTABLISHED" > /dev/null; do
+       sleep 1
+       _count=`expr $_count + 1`
+       [ $_count -gt 3 ] && {
+           echo "Timed out killing tcp connections for IP $_IP"
+           return;
+       }
+    done
+    echo "killed $_killcount TCP connections to released IP $_IP"
+}
+
 ########################################################
 # start/stop the nfs service on different platforms
 ########################################################
diff --git a/config/notify.sh b/config/notify.sh
new file mode 100755 (executable)
index 0000000..9c97ab9
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+# This script is activated by setting CTDB_NOTIFY_SCRIPT=/etc/ctdb/notify.sh
+# in /etc/sysconfig/ctdb
+
+# This is script is invoked from ctdb when node UNHEALTHY flag changes.
+# and can be used to send SNMPtraps, email, etc
+# when the status of a node changes
+
+
+event="$1"
+shift
+
+case $event in
+       unhealthy)
+#
+#               Send an snmptrap that the node is unhealthy :
+#              snmptrap -m ALL -v 1 -c public 10.1.1.105 ctdb `hostname` 0 0 `date +"%s"` ctdb.nodeHealth.0 i 1
+#
+#               or send an email :
+#               mail foo@bar -s "`hostname` is UNHEALTHY"   ...
+#
+#               or do something else ...
+               ;;
+       healthy)
+#
+#               Send an snmptrap that the node is healthy again :
+#              snmptrap -m ALL -v 1 -c public 10.1.1.105 ctdb `hostname` 0 0 `date +"%s"` ctdb.nodeHealth.0 i 0
+#
+#               or send an email :
+#               mail foo@bar -s "`hostname` is HEALTHY"   ...
+#
+#               or do something else ...
+               ;;
+esac
+
+exit 0
index 5da61bf69ed22fe2aed885970ecf6509d300e8af..91c1b645e2fdaf3bdc69bce4c947e5571b305873 100644 (file)
@@ -1,11 +1,11 @@
 .\"     Title: ctdb
 .\"    Author: 
 .\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
-.\"      Date: 09/15/2008
+.\"      Date: 03/24/2009
 .\"    Manual: 
 .\"    Source: 
 .\"
-.TH "CTDB" "1" "09/15/2008" "" ""
+.TH "CTDB" "1" "03/24/2009" "" ""
 .\" disable hyphenation
 .nh
 .\" disable justification (adjust text to left margin only)
@@ -169,6 +169,43 @@ hash:3 lmaster:3
 Recovery mode:NORMAL (0)
 Recovery master:0
       
+.fi
+.RE
+.SS "recmaster"
+.PP
+This command shows the pnn of the node which is currently the recmaster\.
+.SS "uptime"
+.PP
+This command shows the uptime for the ctdb daemon\. When the last recovery completed and how long the last recovery took\. If the "duration" is shown as a negative number, this indicates that there is a recovery in progress and it started that many seconds ago\.
+.PP
+Example: ctdb uptime
+.PP
+Example output:
+.sp
+.RS 4
+.nf
+Current time of node  : Tue Mar 24 18:27:54 2009
+Ctdbd start time      : (000 00:00:05) Tue Mar 24 18:27:49 2009
+Time of last recovery : (000 00:00:05) Tue Mar 24 18:27:49 2009
+Duration of last recovery : 0\.000000 seconds
+      
+.fi
+.RE
+.SS "listnodes"
+.PP
+This command shows lists the ip addresses of all the nodes in the cluster\.
+.PP
+Example: ctdb listnodes
+.PP
+Example output:
+.sp
+.RS 4
+.nf
+10\.0\.0\.71
+10\.0\.0\.72
+10\.0\.0\.73
+10\.0\.0\.74
+      
 .fi
 .RE
 .SS "ping"
@@ -190,7 +227,7 @@ response from 3 time=0\.000114 sec  (2 clients)
 .RE
 .SS "ip"
 .PP
-This command will display the list of public addresses that are provided by the cluster and which physical node is currently serving this ip\.
+This command will display the list of public addresses that are provided by the cluster and which physical node is currently serving this ip\. By default this command will ONLY show those public addresses that are known to the node itself\. To see the full list of all public ips across the cluster you must use "ctdb ip \-n all"\.
 .PP
 Example: ctdb ip
 .PP
@@ -204,6 +241,28 @@ Number of addresses:4
 12\.1\.1\.3         2
 12\.1\.1\.4         3
       
+.fi
+.RE
+.SS "scriptstatus"
+.PP
+This command displays which scripts where run in the previous monitoring cycle and the result of each script\. If a script failed with an error, causing the node to become unhealthy, the output from that script is also shown\.
+.PP
+Example: ctdb scriptstatus
+.PP
+Example output:
+.sp
+.RS 4
+.nf
+7 scripts were executed last monitoring cycle
+00\.ctdb              Status:OK    Duration:0\.056 Tue Mar 24 18:56:57 2009
+10\.interface         Status:OK    Duration:0\.077 Tue Mar 24 18:56:57 2009
+11\.natgw             Status:OK    Duration:0\.039 Tue Mar 24 18:56:57 2009
+20\.multipathd        Status:OK    Duration:0\.038 Tue Mar 24 18:56:57 2009
+40\.vsftpd            Status:OK    Duration:0\.045 Tue Mar 24 18:56:57 2009
+41\.httpd             Status:OK    Duration:0\.039 Tue Mar 24 18:56:57 2009
+50\.samba             Status:ERROR    Duration:0\.082 Tue Mar 24 18:56:57 2009
+   OUTPUT:ERROR: Samba tcp port 445 is not responding
+      
 .fi
 .RE
 .SS "getvar <name>"
@@ -374,6 +433,16 @@ Administratively ban a node for bantime seconds\. A bantime of 0 means that the
 A banned node does not participate in the cluster and does not host any records for the clustered TDB\. Its ip address has been taken over by an other node and no services are hosted\.
 .PP
 Nodes are automatically banned if they are the cause of too many cluster recoveries\.
+.SS "addip <public_ip/mask> <iface>"
+.PP
+This command is used to add a new public ip to a node during runtime\. This allows public addresses to be added to a cluster without having to restart the ctdb daemons\.
+.PP
+Note that this only updates the runtime instance of ctdb\. Any changes will be lost next time ctdb is restarted and the public addresses file is re\-read\. If you want this change to be permanent you must also update the public addresses file manually\.
+.SS "delip <public_ip>"
+.PP
+This command is used to remove a public ip from a node during runtime\. If this public ip is currently hosted by the node it being removed from, the ip will first be failed over to another node, if possible, before it is removed\.
+.PP
+Note that this only updates the runtime instance of ctdb\. Any changes will be lost next time ctdb is restarted and the public addresses file is re\-read\. If you want this change to be permanent you must also update the public addresses file manually\.
 .SS "moveip <public_ip> <node>"
 .PP
 This command can be used to manually fail a public ip address to a specific node\.
@@ -394,7 +463,10 @@ This command will shutdown a specific CTDB daemon\.
 This command will trigger the recovery daemon to do a cluster recovery\.
 .SS "killtcp <srcip:port> <dstip:port>"
 .PP
-This command will kill the specified TCP connection by issuing a TCP RST to the srcip:port endpoint\.
+This command will kill the specified TCP connection by issuing a TCP RST to the srcip:port endpoint\. This is a command used by the ctdb eventscripts\.
+.SS "gratiousarp <ip> <interface>"
+.PP
+This command will send out a gratious arp for the specified interface through the specified interface\. This command is mainly used by the ctdb eventscripts\.
 .SS "reloadnodes"
 .PP
 This command is used when adding new nodes to an existing cluster and to reduce the disruption of this operation\. This command should never be used except when expanding an existing cluster\. This can only be used to expand a cluster\. To remove a node from the cluster you still need to shut down ctdb on all nodes, edit the nodes file and restart ctdb\.
@@ -417,6 +489,9 @@ Procedure:
 This command will will send a TCP tickle to the source host for the specified TCP connection\. A TCP tickle is a TCP ACK packet with an invalid sequence and acknowledge number and will when received by the source host result in it sending an immediate correct ACK back to the other end\.
 .PP
 TCP tickles are useful to "tickle" clients after a IP failover has occured since this will make the client immediately recognize the TCP connection has been disrupted and that the client will need to reestablish\. This greatly speeds up the time it takes for a client to detect and reestablish after an IP failover in the ctdb cluster\.
+.SS "gettickles <ip>"
+.PP
+This command is used to show which TCP connections are registered with CTDB to be "tickled" if there is a failover\.
 .SS "repack [max_freelist]"
 .PP
 Over time, when records are created and deleted in a TDB, the TDB list of free space will become fragmented\. This can lead to a slowdown in accessing TDB records\. This command is used to defragment a TDB database and pruning the freelist\.
@@ -493,6 +568,9 @@ This is a debugging command\. This command will make the CTDB daemon create a ne
 .SS "dumpmemory"
 .PP
 This is a debugging command\. This command will make the ctdb daemon to write a fill memory allocation map to standard output\.
+.SS "rddumpmemory"
+.PP
+This is a debugging command\. This command will dump the talloc memory allocation tree for the recovery daemon to standard output\.
 .SS "freeze"
 .PP
 This command will lock all the local TDB databases causing clients that are accessing these TDBs such as samba3 to block until the databases are thawed\.
@@ -501,6 +579,15 @@ This is primarily used by the recovery daemon to stop all samba daemons from acc
 .SS "thaw"
 .PP
 Thaw a previously frozen node\.
+.SS "eventscript <arguments>"
+.PP
+This is a debugging command\. This command can be used to manually invoke and run the eventscritps with arbitrary arguments\.
+.SS "backupdb <database> <file>"
+.PP
+This command can be used to copy the entire content of a database out to a file\. This file can later be read back into ctdb using the restoredb command\. This is mainly useful for backing up persistent databases such as secrets\.tdb and similar\.
+.SS "restoredb <file>"
+.PP
+This command restores a persistent database that was previously backed up using backupdb\.
 .SH "SEE ALSO"
 .PP
 ctdbd(1), onnode(1)
index 3e9aef61c047b987110dd9df8ff36df9bb06301f..f75d28ca72e35ee6d47e0d0b461a6420ad41fe23 100644 (file)
@@ -112,7 +112,27 @@ hash:2 lmaster:2
 hash:3 lmaster:3
 Recovery mode:NORMAL (0)
 Recovery master:0
-      </pre></div><div class="refsect2" lang="en"><a name="id2528540"></a><h3>ping</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528540"></a><h3>recmaster</h3><p>
+        This command shows the pnn of the node which is currently the recmaster.
+      </p></div><div class="refsect2" lang="en"><a name="id2528550"></a><h3>uptime</h3><p>
+        This command shows the uptime for the ctdb daemon. When the last recovery completed and how long the last recovery took. If the "duration" is shown as a negative number, this indicates that there is a recovery in progress and it started that many seconds ago.
+      </p><p>
+       Example: ctdb uptime
+      </p><p>Example output:</p><pre class="screen">
+Current time of node  : Tue Mar 24 18:27:54 2009
+Ctdbd start time      : (000 00:00:05) Tue Mar 24 18:27:49 2009
+Time of last recovery : (000 00:00:05) Tue Mar 24 18:27:49 2009
+Duration of last recovery : 0.000000 seconds
+      </pre></div><div class="refsect2" lang="en"><a name="id2528580"></a><h3>listnodes</h3><p>
+        This command shows lists the ip addresses of all the nodes in the cluster.
+      </p><p>
+       Example: ctdb listnodes
+      </p><p>Example output:</p><pre class="screen">
+10.0.0.71
+10.0.0.72
+10.0.0.73
+10.0.0.74
+      </pre></div><div class="refsect2" lang="en"><a name="id2528604"></a><h3>ping</h3><p>
         This command will "ping" all CTDB daemons in the cluster to verify that they are processing commands correctly.
       </p><p>
        Example: ctdb ping
@@ -123,8 +143,8 @@ response from 0 time=0.000054 sec  (3 clients)
 response from 1 time=0.000144 sec  (2 clients)
 response from 2 time=0.000105 sec  (2 clients)
 response from 3 time=0.000114 sec  (2 clients)
-      </pre></div><div class="refsect2" lang="en"><a name="id2528566"></a><h3>ip</h3><p>
-        This command will display the list of public addresses that are provided by the cluster and which physical node is currently serving this ip.
+      </pre></div><div class="refsect2" lang="en"><a name="id2528630"></a><h3>ip</h3><p>
+        This command will display the list of public addresses that are provided by the cluster and which physical node is currently serving this ip. By default this command will ONLY show those public addresses that are known to the node itself. To see the full list of all public ips across the cluster you must use "ctdb ip -n all".
       </p><p>
        Example: ctdb ip
       </p><p>
@@ -135,7 +155,23 @@ Number of addresses:4
 12.1.1.2         1
 12.1.1.3         2
 12.1.1.4         3
-      </pre></div><div class="refsect2" lang="en"><a name="id2528591"></a><h3>getvar &lt;name&gt;</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528658"></a><h3>scriptstatus</h3><p>
+        This command displays which scripts where run in the previous monitoring cycle and the result of each script. If a script failed with an error, causing the node to become unhealthy, the output from that script is also shown.
+      </p><p>
+       Example: ctdb scriptstatus
+      </p><p>
+       Example output:
+      </p><pre class="screen">
+7 scripts were executed last monitoring cycle
+00.ctdb              Status:OK    Duration:0.056 Tue Mar 24 18:56:57 2009
+10.interface         Status:OK    Duration:0.077 Tue Mar 24 18:56:57 2009
+11.natgw             Status:OK    Duration:0.039 Tue Mar 24 18:56:57 2009
+20.multipathd        Status:OK    Duration:0.038 Tue Mar 24 18:56:57 2009
+40.vsftpd            Status:OK    Duration:0.045 Tue Mar 24 18:56:57 2009
+41.httpd             Status:OK    Duration:0.039 Tue Mar 24 18:56:57 2009
+50.samba             Status:ERROR    Duration:0.082 Tue Mar 24 18:56:57 2009
+   OUTPUT:ERROR: Samba tcp port 445 is not responding
+      </pre></div><div class="refsect2" lang="en"><a name="id2479836"></a><h3>getvar &lt;name&gt;</h3><p>
         Get the runtime value of a tuneable variable.
       </p><p>
        Example: ctdb getvar MaxRedirectCount
@@ -143,11 +179,11 @@ Number of addresses:4
        Example output:
       </p><pre class="screen">
 MaxRedirectCount    = 3
-      </pre></div><div class="refsect2" lang="en"><a name="id2528610"></a><h3>setvar &lt;name&gt; &lt;value&gt;</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528713"></a><h3>setvar &lt;name&gt; &lt;value&gt;</h3><p>
         Set the runtime value of a tuneable variable.
       </p><p>
        Example: ctdb setvar MaxRedirectCount 5
-      </p></div><div class="refsect2" lang="en"><a name="id2528625"></a><h3>listvars</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2528728"></a><h3>listvars</h3><p>
         List all tuneable variables.
       </p><p>
        Example: ctdb listvars
@@ -169,7 +205,7 @@ MonitorInterval     = 15
 EventScriptTimeout  = 20
 RecoveryGracePeriod = 60
 RecoveryBanPeriod   = 300
-      </pre></div><div class="refsect2" lang="en"><a name="id2528653"></a><h3>lvsmaster</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528755"></a><h3>lvsmaster</h3><p>
       This command shows which node is currently the LVSMASTER. The
       LVSMASTER is the node in the cluster which drives the LVS system and
       which receives all incoming traffic from clients.
@@ -180,7 +216,7 @@ RecoveryBanPeriod   = 300
       evenly onto the other nodes in the cluster. This is an alternative to using
       public ip addresses. See the manpage for ctdbd for more information
       about LVS.
-      </p></div><div class="refsect2" lang="en"><a name="id2528675"></a><h3>lvs</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2528778"></a><h3>lvs</h3><p>
       This command shows which nodes in the cluster are currently active in the
       LVS configuration. I.e. which nodes we are currently loadbalancing
       the single ip address across.
@@ -194,7 +230,7 @@ RecoveryBanPeriod   = 300
       </p><pre class="screen">
 2:10.0.0.13
 3:10.0.0.14
-      </pre></div><div class="refsect2" lang="en"><a name="id2528705"></a><h3>getcapabilities</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528807"></a><h3>getcapabilities</h3><p>
       This command shows the capabilities of the current node.
       Please see manpage for ctdbd for a full list of all capabilities and
       more detailed description.
@@ -213,7 +249,7 @@ RecoveryBanPeriod   = 300
 RECMASTER: YES
 LMASTER: YES
 LVS: NO
-      </pre></div><div class="refsect2" lang="en"><a name="id2528741"></a><h3>statistics</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528844"></a><h3>statistics</h3><p>
         Collect statistics from the CTDB daemon about how many calls it has served.
       </p><p>
        Example: ctdb statistics
@@ -255,11 +291,11 @@ CTDB version 1
  max_hop_count                      0
  max_call_latency                   4.948321 sec
  max_lockwait_latency               0.000000 sec
-      </pre></div><div class="refsect2" lang="en"><a name="id2528784"></a><h3>statisticsreset</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528887"></a><h3>statisticsreset</h3><p>
         This command is used to clear all statistics counters in a node.
       </p><p>
        Example: ctdb statisticsreset
-      </p></div><div class="refsect2" lang="en"><a name="id2528799"></a><h3>getdebug</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2528901"></a><h3>getdebug</h3><p>
         Get the current debug level for the node. the debug level controls what information is written to the log file.
       </p><p>
        The debug levels are mapped to the corresponding syslog levels.
@@ -269,27 +305,40 @@ CTDB version 1
        The list of debug levels from highest to lowest are :
       </p><p>
        EMERG ALERT CRIT ERR WARNING NOTICE INFO DEBUG
-      </p></div><div class="refsect2" lang="en"><a name="id2528825"></a><h3>setdebug &lt;debuglevel&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2528927"></a><h3>setdebug &lt;debuglevel&gt;</h3><p>
         Set the debug level of a node. This controls what information will be logged.
       </p><p>
        The debuglevel is one of EMERG ALERT CRIT ERR WARNING NOTICE INFO DEBUG
-      </p></div><div class="refsect2" lang="en"><a name="id2528840"></a><h3>getpid</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2528943"></a><h3>getpid</h3><p>
         This command will return the process id of the ctdb daemon.
-      </p></div><div class="refsect2" lang="en"><a name="id2528850"></a><h3>disable</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2528953"></a><h3>disable</h3><p>
         This command is used to administratively disable a node in the cluster.
         A disabled node will still participate in the cluster and host
         clustered TDB records but its public ip address has been taken over by
         a different node and it no longer hosts any services.
-      </p></div><div class="refsect2" lang="en"><a name="id2528864"></a><h3>enable</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2528967"></a><h3>enable</h3><p>
         Re-enable a node that has been administratively disabled.
-      </p></div><div class="refsect2" lang="en"><a name="id2528874"></a><h3>ban &lt;bantime|0&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2528977"></a><h3>ban &lt;bantime|0&gt;</h3><p>
         Administratively ban a node for bantime seconds. A bantime of 0 means that the node should be permanently banned. 
       </p><p>
         A banned node does not participate in the cluster and does not host any records for the clustered TDB. Its ip address has been taken over by an other node and no services are hosted.
       </p><p>
         Nodes are automatically banned if they are the cause of too many
         cluster recoveries.
-      </p></div><div class="refsect2" lang="en"><a name="id2528898"></a><h3>moveip &lt;public_ip&gt; &lt;node&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529000"></a><h3>addip &lt;public_ip/mask&gt; &lt;iface&gt;</h3><p>
+       This command is used to add a new public ip to a node during runtime.
+       This allows public addresses to be added to a cluster without having
+       to restart the ctdb daemons.
+      </p><p>
+       Note that this only updates the runtime instance of ctdb. Any changes will be lost next time ctdb is restarted and the public addresses file is re-read.
+ If you want this change to be permanent you must also update the public addresses file manually.
+      </p></div><div class="refsect2" lang="en"><a name="id2529021"></a><h3>delip &lt;public_ip&gt;</h3><p>
+       This command is used to remove a public ip from a node during runtime.
+       If this public ip is currently hosted by the node it being removed from, the ip will first be failed over to another node, if possible, before it is removed.
+      </p><p>
+       Note that this only updates the runtime instance of ctdb. Any changes will be lost next time ctdb is restarted and the public addresses file is re-read.
+ If you want this change to be permanent you must also update the public addresses file manually.
+      </p></div><div class="refsect2" lang="en"><a name="id2529042"></a><h3>moveip &lt;public_ip&gt; &lt;node&gt;</h3><p>
       This command can be used to manually fail a public ip address to a
       specific node.
       </p><p>
@@ -300,19 +349,24 @@ CTDB version 1
       DeterministicIPs = 0
       </p><p>
       NoIPFailback = 1
-      </p></div><div class="refsect2" lang="en"><a name="id2528922"></a><h3>unban</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529066"></a><h3>unban</h3><p>
         This command is used to unban a node that has either been 
         administratively banned using the ban command or has been automatically
         banned by the recovery daemon.
-      </p></div><div class="refsect2" lang="en"><a name="id2528934"></a><h3>shutdown</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529078"></a><h3>shutdown</h3><p>
         This command will shutdown a specific CTDB daemon.
-      </p></div><div class="refsect2" lang="en"><a name="id2528944"></a><h3>recover</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529088"></a><h3>recover</h3><p>
         This command will trigger the recovery daemon to do a cluster
         recovery.
-      </p></div><div class="refsect2" lang="en"><a name="id2528955"></a><h3>killtcp &lt;srcip:port&gt; &lt;dstip:port&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529099"></a><h3>killtcp &lt;srcip:port&gt; &lt;dstip:port&gt;</h3><p>
         This command will kill the specified TCP connection by issuing a
-        TCP RST to the srcip:port endpoint.
-      </p></div><div class="refsect2" lang="en"><a name="id2528966"></a><h3>reloadnodes</h3><p>
+        TCP RST to the srcip:port endpoint. This is a command used by the 
+       ctdb eventscripts.
+      </p></div><div class="refsect2" lang="en"><a name="id2529111"></a><h3>gratiousarp &lt;ip&gt; &lt;interface&gt;</h3><p>
+       This command will send out a gratious arp for the specified interface
+       through the specified interface. This command is mainly used by the
+       ctdb eventscripts.
+      </p></div><div class="refsect2" lang="en"><a name="id2529124"></a><h3>reloadnodes</h3><p>
       This command is used when adding new nodes to an existing cluster and
       to reduce the disruption of this operation. This command should never
       be used except when expanding an existing cluster.
@@ -336,7 +390,7 @@ CTDB version 1
       5, Use 'ctdb status' on all nodes and verify that they now show the additional node.
       </p><p>
       6, Install and configure the new node and bring it online.
-      </p></div><div class="refsect2" lang="en"><a name="id2529018"></a><h3>tickle &lt;srcip:port&gt; &lt;dstip:port&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529176"></a><h3>tickle &lt;srcip:port&gt; &lt;dstip:port&gt;</h3><p>
         This command will will send a TCP tickle to the source host for the
         specified TCP connection.
        A TCP tickle is a TCP ACK packet with an invalid sequence and 
@@ -348,7 +402,10 @@ CTDB version 1
         TCP connection has been disrupted and that the client will need
         to reestablish. This greatly speeds up the time it takes for a client
         to detect and reestablish after an IP failover in the ctdb cluster.
-      </p></div><div class="refsect2" lang="en"><a name="id2529043"></a><h3>repack [max_freelist]</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529200"></a><h3>gettickles &lt;ip&gt;</h3><p>
+       This command is used to show which TCP connections are registered with
+       CTDB to be "tickled" if there is a failover.
+      </p></div><div class="refsect2" lang="en"><a name="id2529212"></a><h3>repack [max_freelist]</h3><p>
        Over time, when records are created and deleted in a TDB, the TDB list of free space will become fragmented. This can lead to a slowdown in accessing TDB records.
        This command is used to defragment a TDB database and pruning the freelist.
       </p><p>
@@ -363,7 +420,7 @@ CTDB version 1
        Example: ctdb repack 1000
       </p><p>
         By default, this operation is issued from the 00.ctdb event script every 5 minutes.
-      </p></div><div class="refsect2" lang="en"><a name="id2529089"></a><h3>vacuum [max_records]</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529258"></a><h3>vacuum [max_records]</h3><p>
        Over time CTDB databases will fill up with empty deleted records which will lead to a progressive slow down of CTDB database access.
        This command is used to prune all databases and delete all empty records from the cluster.
       </p><p>
@@ -379,12 +436,12 @@ CTDB version 1
        Example: ctdb vacuum
       </p><p>
         By default, this operation is issued from the 00.ctdb event script every 5 minutes.
-      </p></div></div><div class="refsect1" lang="en"><a name="id2529126"></a><h2>Debugging Commands</h2><p>
+      </p></div></div><div class="refsect1" lang="en"><a name="id2529295"></a><h2>Debugging Commands</h2><p>
       These commands are primarily used for CTDB development and testing and
       should not be used for normal administration.
-    </p><div class="refsect2" lang="en"><a name="id2529136"></a><h3>process-exists &lt;pid&gt;</h3><p>
+    </p><div class="refsect2" lang="en"><a name="id2529305"></a><h3>process-exists &lt;pid&gt;</h3><p>
         This command checks if a specific process exists on the CTDB host. This is mainly used by Samba to check if remote instances of samba are still running or not.
-      </p></div><div class="refsect2" lang="en"><a name="id2529149"></a><h3>getdbmap</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529317"></a><h3>getdbmap</h3><p>
         This command lists all clustered TDB databases that the CTDB daemon has attached to. Some databases are flagged as PERSISTENT, this means that the database stores data persistently and the data will remain across reboots. One example of such a database is secrets.tdb where information about how the cluster was joined to the domain is stored.
        </p><p>
        Most databases are not persistent and only store the state information that the currently running samba daemons need. These databases are always wiped when ctdb/samba starts and when a node is rebooted.
@@ -403,22 +460,25 @@ dbid:0x2672a57f name:idmap2.tdb path:/var/ctdb/persistent/idmap2.tdb.0 PERSISTEN
 dbid:0xb775fff6 name:secrets.tdb path:/var/ctdb/persistent/secrets.tdb.0 PERSISTENT
 dbid:0xe98e08b6 name:group_mapping.tdb path:/var/ctdb/persistent/group_mapping.tdb.0 PERSISTENT
 dbid:0x7bbbd26c name:passdb.tdb path:/var/ctdb/persistent/passdb.tdb.0 PERSISTENT
-      </pre></div><div class="refsect2" lang="en"><a name="id2529195"></a><h3>catdb &lt;dbname&gt;</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2529364"></a><h3>catdb &lt;dbname&gt;</h3><p>
         This command will dump a clustered TDB database to the screen. This is a debugging command.
-      </p></div><div class="refsect2" lang="en"><a name="id2529206"></a><h3>getmonmode</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529374"></a><h3>getmonmode</h3><p>
         This command returns the monutoring mode of a node. The monitoring mode is either ACTIVE or DISABLED. Normally a node will continously monitor that all other nodes that are expected are in fact connected and that they respond to commands.
       </p><p>
         ACTIVE - This is the normal mode. The node is actively monitoring all other nodes, both that the transport is connected and also that the node responds to commands. If a node becomes unavailable, it will be marked as DISCONNECTED and a recovery is initiated to restore the cluster.
       </p><p>
         DISABLED - This node is not monitoring that other nodes are available. In this mode a node failure will not be detected and no recovery will be performed. This mode is useful when for debugging purposes one wants to attach GDB to a ctdb process but wants to prevent the rest of the cluster from marking this node as DISCONNECTED and do a recovery.
-      </p></div><div class="refsect2" lang="en"><a name="id2529236"></a><h3>setmonmode &lt;0|1&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529405"></a><h3>setmonmode &lt;0|1&gt;</h3><p>
         This command can be used to explicitely disable/enable monitoring mode on a node. The main purpose is if one wants to attach GDB to a running ctdb daemon but wants to prevent the other nodes from marking it as DISCONNECTED and issuing a recovery. To do this, set monitoring mode to 0 on all nodes before attaching with GDB. Remember to set monitoring mode back to 1 afterwards.
-      </p></div><div class="refsect2" lang="en"><a name="id2529252"></a><h3>attach &lt;dbname&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529421"></a><h3>attach &lt;dbname&gt;</h3><p>
         This is a debugging command. This command will make the CTDB daemon create a new CTDB database and attach to it.
-      </p></div><div class="refsect2" lang="en"><a name="id2529263"></a><h3>dumpmemory</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529432"></a><h3>dumpmemory</h3><p>
         This is a debugging command. This command will make the ctdb
         daemon to write a fill memory allocation map to standard output.
-      </p></div><div class="refsect2" lang="en"><a name="id2529275"></a><h3>freeze</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529444"></a><h3>rddumpmemory</h3><p>
+        This is a debugging command. This command will dump the talloc memory
+       allocation tree for the recovery daemon to standard output.
+      </p></div><div class="refsect2" lang="en"><a name="id2529455"></a><h3>freeze</h3><p>
         This command will lock all the local TDB databases causing clients 
         that are accessing these TDBs such as samba3 to block until the
         databases are thawed.
@@ -426,12 +486,20 @@ dbid:0x7bbbd26c name:passdb.tdb path:/var/ctdb/persistent/passdb.tdb.0 PERSISTEN
         This is primarily used by the recovery daemon to stop all samba
         daemons from accessing any databases while the database is recovered
         and rebuilt.
-      </p></div><div class="refsect2" lang="en"><a name="id2529293"></a><h3>thaw</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529473"></a><h3>thaw</h3><p>
         Thaw a previously frozen node.
-      </p></div></div><div class="refsect1" lang="en"><a name="id2529304"></a><h2>SEE ALSO</h2><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529483"></a><h3>eventscript &lt;arguments&gt;</h3><p>
+        This is a debugging command. This command can be used to manually
+       invoke and run the eventscritps with arbitrary arguments.
+      </p></div><div class="refsect2" lang="en"><a name="id2529495"></a><h3>backupdb &lt;database&gt; &lt;file&gt;</h3><p>
+        This command can be used to copy the entire content of a database out to a file. This file can later be read back into ctdb using the restoredb command.
+This is mainly useful for backing up persistent databases such as secrets.tdb and similar.
+      </p></div><div class="refsect2" lang="en"><a name="id2529509"></a><h3>restoredb &lt;file&gt;</h3><p>
+        This command restores a persistent database that was previously backed up using backupdb.
+      </p></div></div><div class="refsect1" lang="en"><a name="id2529521"></a><h2>SEE ALSO</h2><p>
       ctdbd(1), onnode(1)
       <a class="ulink" href="http://ctdb.samba.org/" target="_top">http://ctdb.samba.org/</a>
-    </p></div><div class="refsect1" lang="en"><a name="id2529317"></a><h2>COPYRIGHT/LICENSE</h2><div class="literallayout"><p><br>
+    </p></div><div class="refsect1" lang="en"><a name="id2529534"></a><h2>COPYRIGHT/LICENSE</h2><div class="literallayout"><p><br>
 Copyright (C) Andrew Tridgell 2007<br>
 Copyright (C) Ronnie sahlberg 2007<br>
 <br>
index b777327225afc0e56fe1405db8b7dda63791c42c..a88e8ad9ccbae35086c401e99af6dadf51ba7432 100644 (file)
@@ -256,6 +256,46 @@ Recovery master:0
       </screen>
     </refsect2>
 
+    <refsect2><title>recmaster</title>
+      <para>
+        This command shows the pnn of the node which is currently the recmaster.
+      </para>
+    </refsect2>
+
+    <refsect2><title>uptime</title>
+      <para>
+        This command shows the uptime for the ctdb daemon. When the last recovery completed and how long the last recovery took. If the "duration" is shown as a negative number, this indicates that there is a recovery in progress and it started that many seconds ago.
+      </para>
+
+      <para>
+       Example: ctdb uptime
+      </para>
+      <para>Example output:</para>
+      <screen format="linespecific">
+Current time of node  : Tue Mar 24 18:27:54 2009
+Ctdbd start time      : (000 00:00:05) Tue Mar 24 18:27:49 2009
+Time of last recovery : (000 00:00:05) Tue Mar 24 18:27:49 2009
+Duration of last recovery : 0.000000 seconds
+      </screen>
+    </refsect2>
+
+    <refsect2><title>listnodes</title>
+      <para>
+        This command shows lists the ip addresses of all the nodes in the cluster.
+      </para>
+
+      <para>
+       Example: ctdb listnodes
+      </para>
+      <para>Example output:</para>
+      <screen format="linespecific">
+10.0.0.71
+10.0.0.72
+10.0.0.73
+10.0.0.74
+      </screen>
+    </refsect2>
+
     <refsect2><title>ping</title>
       <para>
         This command will "ping" all CTDB daemons in the cluster to verify that they are processing commands correctly.
@@ -276,7 +316,7 @@ response from 3 time=0.000114 sec  (2 clients)
 
     <refsect2><title>ip</title>
       <para>
-        This command will display the list of public addresses that are provided by the cluster and which physical node is currently serving this ip.
+        This command will display the list of public addresses that are provided by the cluster and which physical node is currently serving this ip. By default this command will ONLY show those public addresses that are known to the node itself. To see the full list of all public ips across the cluster you must use "ctdb ip -n all".
       </para>
       <para>
        Example: ctdb ip
@@ -293,6 +333,29 @@ Number of addresses:4
       </screen>
     </refsect2>
 
+    <refsect2><title>scriptstatus</title>
+      <para>
+        This command displays which scripts where run in the previous monitoring cycle and the result of each script. If a script failed with an error, causing the node to become unhealthy, the output from that script is also shown.
+      </para>
+      <para>
+       Example: ctdb scriptstatus
+      </para>
+      <para>
+       Example output:
+      </para>
+      <screen format="linespecific">
+7 scripts were executed last monitoring cycle
+00.ctdb              Status:OK    Duration:0.056 Tue Mar 24 18:56:57 2009
+10.interface         Status:OK    Duration:0.077 Tue Mar 24 18:56:57 2009
+11.natgw             Status:OK    Duration:0.039 Tue Mar 24 18:56:57 2009
+20.multipathd        Status:OK    Duration:0.038 Tue Mar 24 18:56:57 2009
+40.vsftpd            Status:OK    Duration:0.045 Tue Mar 24 18:56:57 2009
+41.httpd             Status:OK    Duration:0.039 Tue Mar 24 18:56:57 2009
+50.samba             Status:ERROR    Duration:0.082 Tue Mar 24 18:56:57 2009
+   OUTPUT:ERROR: Samba tcp port 445 is not responding
+      </screen>
+    </refsect2>
+
     <refsect2><title>getvar &lt;name&gt;</title>
       <para>
         Get the runtime value of a tuneable variable.
@@ -536,6 +599,29 @@ CTDB version 1
       </para>
     </refsect2>
 
+    <refsect2><title>addip &lt;public_ip/mask&gt; &lt;iface&gt;</title>
+      <para>
+       This command is used to add a new public ip to a node during runtime.
+       This allows public addresses to be added to a cluster without having
+       to restart the ctdb daemons.
+      </para>
+      <para>
+       Note that this only updates the runtime instance of ctdb. Any changes will be lost next time ctdb is restarted and the public addresses file is re-read.
+ If you want this change to be permanent you must also update the public addresses file manually.
+      </para>
+    </refsect2>
+
+    <refsect2><title>delip &lt;public_ip&gt;</title>
+      <para>
+       This command is used to remove a public ip from a node during runtime.
+       If this public ip is currently hosted by the node it being removed from, the ip will first be failed over to another node, if possible, before it is removed.
+      </para>
+      <para>
+       Note that this only updates the runtime instance of ctdb. Any changes will be lost next time ctdb is restarted and the public addresses file is re-read.
+ If you want this change to be permanent you must also update the public addresses file manually.
+      </para>
+    </refsect2>
+
     <refsect2><title>moveip &lt;public_ip&gt; &lt;node&gt;</title>
       <para>
       This command can be used to manually fail a public ip address to a
@@ -578,7 +664,16 @@ CTDB version 1
     <refsect2><title>killtcp &lt;srcip:port&gt; &lt;dstip:port&gt;</title>
       <para>
         This command will kill the specified TCP connection by issuing a
-        TCP RST to the srcip:port endpoint.
+        TCP RST to the srcip:port endpoint. This is a command used by the 
+       ctdb eventscripts.
+      </para>
+    </refsect2>
+
+    <refsect2><title>gratiousarp &lt;ip&gt; &lt;interface&gt;</title>
+      <para>
+       This command will send out a gratious arp for the specified interface
+       through the specified interface. This command is mainly used by the
+       ctdb eventscripts.
       </para>
     </refsect2>
 
@@ -634,6 +729,12 @@ CTDB version 1
       </para>
     </refsect2>
 
+    <refsect2><title>gettickles &lt;ip&gt;</title>
+      <para>
+       This command is used to show which TCP connections are registered with
+       CTDB to be "tickled" if there is a failover.
+      </para>
+    </refsect2>
     <refsect2><title>repack [max_freelist]</title>
       <para>
        Over time, when records are created and deleted in a TDB, the TDB list of free space will become fragmented. This can lead to a slowdown in accessing TDB records.
@@ -772,6 +873,13 @@ dbid:0x7bbbd26c name:passdb.tdb path:/var/ctdb/persistent/passdb.tdb.0 PERSISTEN
       </para>
     </refsect2>
 
+    <refsect2><title>rddumpmemory</title>
+      <para>
+        This is a debugging command. This command will dump the talloc memory
+       allocation tree for the recovery daemon to standard output.
+      </para>
+    </refsect2>
+
     <refsect2><title>freeze</title>
       <para>
         This command will lock all the local TDB databases causing clients 
@@ -791,8 +899,29 @@ dbid:0x7bbbd26c name:passdb.tdb path:/var/ctdb/persistent/passdb.tdb.0 PERSISTEN
       </para>
     </refsect2>
 
-  </refsect1>
 
+    <refsect2><title>eventscript &lt;arguments&gt;</title>
+      <para>
+        This is a debugging command. This command can be used to manually
+       invoke and run the eventscritps with arbitrary arguments.
+      </para>
+    </refsect2>
+
+    <refsect2><title>backupdb &lt;database&gt; &lt;file&gt;</title>
+      <para>
+        This command can be used to copy the entire content of a database out to a file. This file can later be read back into ctdb using the restoredb command.
+This is mainly useful for backing up persistent databases such as secrets.tdb and similar.
+      </para>
+    </refsect2>
+
+    <refsect2><title>restoredb &lt;file&gt;</title>
+      <para>
+        This command restores a persistent database that was previously backed up using backupdb.
+      </para>
+    </refsect2>
+
+
+  </refsect1>
 
   <refsect1><title>SEE ALSO</title>
     <para>
index 38ba41a51767a823d767965be960031265e02f48..13e4a6b1da74358e9ad6aa384088285f52b2ecbd 100644 (file)
 .\"     Title: ctdbd
-.\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author]
-.\" Generator: DocBook XSL Stylesheets v1.74.0 <http://docbook.sf.net/>
-.\"      Date: 10/14/2008
-.\"    Manual: [FIXME: manual]
-.\"    Source: [FIXME: source]
-.\"  Language: English
+.\"    Author: 
+.\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
+.\"      Date: 03/25/2009
+.\"    Manual: 
+.\"    Source: 
 .\"
-.TH "CTDBD" "1" "10/14/2008" "[FIXME: source]" "[FIXME: manual]"
-.\" -----------------------------------------------------------------
-.\" * (re)Define some macros
-.\" -----------------------------------------------------------------
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" toupper - uppercase a string (locale-aware)
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.de toupper
-.tr aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ
-\\$*
-.tr aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz
-..
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" SH-xref - format a cross-reference to an SH section
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.de SH-xref
-.ie n \{\
-.\}
-.toupper \\$*
-.el \{\
-\\$*
-.\}
-..
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" SH - level-one heading that works better for non-TTY output
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.de1 SH
-.\" put an extra blank line of space above the head in non-TTY output
-.if t \{\
-.sp 1
-.\}
-.sp \\n[PD]u
-.nr an-level 1
-.set-an-margin
-.nr an-prevailing-indent \\n[IN]
-.fi
-.in \\n[an-margin]u
-.ti 0
-.HTML-TAG ".NH \\n[an-level]"
-.it 1 an-trap
-.nr an-no-space-flag 1
-.nr an-break-flag 1
-.\" make the size of the head bigger
-.ps +3
-.ft B
-.ne (2v + 1u)
-.ie n \{\
-.\" if n (TTY output), use uppercase
-.toupper \\$*
-.\}
-.el \{\
-.nr an-break-flag 0
-.\" if not n (not TTY), use normal case (not uppercase)
-\\$1
-.in \\n[an-margin]u
-.ti 0
-.\" if not n (not TTY), put a border/line under subheading
-.sp -.6
-\l'\n(.lu'
-.\}
-..
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" SS - level-two heading that works better for non-TTY output
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.de1 SS
-.sp \\n[PD]u
-.nr an-level 1
-.set-an-margin
-.nr an-prevailing-indent \\n[IN]
-.fi
-.in \\n[IN]u
-.ti \\n[SN]u
-.it 1 an-trap
-.nr an-no-space-flag 1
-.nr an-break-flag 1
-.ps \\n[PS-SS]u
-.\" make the size of the head bigger
-.ps +2
-.ft B
-.ne (2v + 1u)
-.if \\n[.$] \&\\$*
-..
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" BB/BE - put background/screen (filled box) around block of text
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.de BB
-.if t \{\
-.sp -.5
-.br
-.in +2n
-.ll -2n
-.gcolor red
-.di BX
-.\}
-..
-.de EB
-.if t \{\
-.if "\\$2"adjust-for-leading-newline" \{\
-.sp -1
-.\}
-.br
-.di
-.in
-.ll
-.gcolor
-.nr BW \\n(.lu-\\n(.i
-.nr BH \\n(dn+.5v
-.ne \\n(BHu+.5v
-.ie "\\$2"adjust-for-leading-newline" \{\
-\M[\\$1]\h'1n'\v'+.5v'\D'P \\n(BWu 0 0 \\n(BHu -\\n(BWu 0 0 -\\n(BHu'\M[]
-.\}
-.el \{\
-\M[\\$1]\h'1n'\v'-.5v'\D'P \\n(BWu 0 0 \\n(BHu -\\n(BWu 0 0 -\\n(BHu'\M[]
-.\}
-.in 0
-.sp -.5v
-.nf
-.BX
-.in
-.sp .5v
-.fi
-.\}
-..
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" BM/EM - put colored marker in margin next to block of text
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.de BM
-.if t \{\
-.br
-.ll -2n
-.gcolor red
-.di BX
-.\}
-..
-.de EM
-.if t \{\
-.br
-.di
-.ll
-.gcolor
-.nr BH \\n(dn
-.ne \\n(BHu
-\M[\\$1]\D'P -.75n 0 0 \\n(BHu -(\\n[.i]u - \\n(INu - .75n) 0 0 -\\n(BHu'\M[]
-.in 0
-.nf
-.BX
-.in
-.fi
-.\}
-..
-.\" -----------------------------------------------------------------
-.\" * set default formatting
-.\" -----------------------------------------------------------------
+.TH "CTDBD" "1" "03/25/2009" "" ""
 .\" disable hyphenation
 .nh
 .\" disable justification (adjust text to left margin only)
 .ad l
-.\" -----------------------------------------------------------------
-.\" * MAIN CONTENT STARTS HERE *
-.\" -----------------------------------------------------------------
-.SH "Name"
-ctdbd \- The CTDB cluster daemon
-.SH "Synopsis"
-.fam C
-.HP \w'\fBctdbd\fR\ 'u
+.SH "NAME"
+ctdbd - The CTDB cluster daemon
+.SH "SYNOPSIS"
+.HP 6
 \fBctdbd\fR
-.fam
-.fam C
-.HP \w'\fBctdbd\fR\ 'u
+.HP 6
 \fBctdbd\fR [\-?\ \-\-help] [\-d\ \-\-debug=<INTEGER>] {\-\-dbdir=<directory>} {\-\-dbdir\-persistent=<directory>} [\-\-event\-script\-dir=<directory>] [\-i\ \-\-interactive] [\-\-listen=<address>] [\-\-logfile=<filename>] [\-\-lvs] {\-\-nlist=<filename>} [\-\-no\-lmaster] [\-\-no\-recmaster] [\-\-nosetsched] [\-\-public\-addresses=<filename>] [\-\-public\-interface=<interface>] {\-\-reclock=<filename>} [\-\-single\-public\-ip=<address>] [\-\-socket=<filename>] [\-\-start\-as\-disabled] [\-\-syslog] [\-\-torture] [\-\-transport=<STRING>] [\-\-usage]
-.fam
 .SH "DESCRIPTION"
 .PP
-ctdbd is the main ctdb daemon\&.
+ctdbd is the main ctdb daemon\.
 .PP
-ctdbd provides a clustered version of the TDB database with automatic rebuild/recovery of the databases upon nodefailures\&.
+ctdbd provides a clustered version of the TDB database with automatic rebuild/recovery of the databases upon nodefailures\.
 .PP
-Combined with a cluster filesystem ctdbd provides a full HA environment for services such as clustered Samba and NFS as well as other services\&.
+Combined with a cluster filesystem ctdbd provides a full HA environment for services such as clustered Samba and NFS as well as other services\.
 .PP
-ctdbd provides monitoring of all nodes in the cluster and automatically reconfigures the cluster and recovers upon node failures\&.
+ctdbd provides monitoring of all nodes in the cluster and automatically reconfigures the cluster and recovers upon node failures\.
 .PP
-ctdbd is the main component in clustered Samba that provides a high\-availability load\-sharing CIFS server cluster\&.
+ctdbd is the main component in clustered Samba that provides a high\-availability load\-sharing CIFS server cluster\.
 .SH "OPTIONS"
 .PP
 \-? \-\-help
 .RS 4
-Print some help text to the screen\&.
+Print some help text to the screen\.
 .RE
 .PP
 \-d \-\-debug=<DEBUGLEVEL>
 .RS 4
-This option sets the debuglevel on the ctdbd daemon which controls what will be written to the logfile\&. The default is 0 which will only log important events and errors\&. A larger number will provide additional logging\&.
+This option sets the debuglevel on the ctdbd daemon which controls what will be written to the logfile\. The default is 0 which will only log important events and errors\. A larger number will provide additional logging\.
 .RE
 .PP
 \-\-dbdir=<directory>
 .RS 4
-This is the directory on local storage where ctdbd keeps the local copy of the TDB databases\&. This directory is local for each node and should not be stored on the shared cluster filesystem\&.
+This is the directory on local storage where ctdbd keeps the local copy of the TDB databases\. This directory is local for each node and should not be stored on the shared cluster filesystem\.
 .sp
-This directory would usually be /var/ctdb \&.
+This directory would usually be /var/ctdb \.
 .RE
 .PP
 \-\-dbdir\-persistent=<directory>
 .RS 4
-This is the directory on local storage where ctdbd keeps the local copy of the persistent TDB databases\&. This directory is local for each node and should not be stored on the shared cluster filesystem\&.
+This is the directory on local storage where ctdbd keeps the local copy of the persistent TDB databases\. This directory is local for each node and should not be stored on the shared cluster filesystem\.
 .sp
-This directory would usually be /etc/ctdb/persistent \&.
+This directory would usually be /etc/ctdb/persistent \.
 .RE
 .PP
 \-\-event\-script\-dir=<directory>
 .RS 4
-This option is used to specify the directory where the CTDB event scripts are stored\&.
+This option is used to specify the directory where the CTDB event scripts are stored\.
 .sp
-This will normally be /etc/ctdb/events\&.d which is part of the ctdb distribution\&.
+This will normally be /etc/ctdb/events\.d which is part of the ctdb distribution\.
 .RE
 .PP
 \-i \-\-interactive
 .RS 4
-By default ctdbd will detach itself from the shell and run in the background as a daemon\&. This option makes ctdbd to start in interactive mode\&.
+By default ctdbd will detach itself from the shell and run in the background as a daemon\. This option makes ctdbd to start in interactive mode\.
 .RE
 .PP
 \-\-listen=<address>
 .RS 4
-This specifies which ip address ctdb will bind to\&. By default ctdbd will bind to the first address it finds in the /etc/ctdb/nodes file and which is also present on the local system in which case you do not need to provide this option\&.
+This specifies which ip address ctdb will bind to\. By default ctdbd will bind to the first address it finds in the /etc/ctdb/nodes file and which is also present on the local system in which case you do not need to provide this option\.
 .sp
-This option is only required when you want to run multiple ctdbd daemons/nodes on the same physical host in which case there would be multiple entries in /etc/ctdb/nodes what would match a local interface\&.
+This option is only required when you want to run multiple ctdbd daemons/nodes on the same physical host in which case there would be multiple entries in /etc/ctdb/nodes what would match a local interface\.
 .RE
 .PP
 \-\-logfile=<filename>
 .RS 4
-This is the file where ctdbd will write its log\&. This is usually /var/log/log\&.ctdb \&.
+This is the file where ctdbd will write its log\. This is usually /var/log/log\.ctdb \.
 .RE
 .PP
 \-\-lvs
 .RS 4
-This option is used to activate the LVS capability on a CTDB node\&. Please see the LVS section\&.
+This option is used to activate the LVS capability on a CTDB node\. Please see the LVS section\.
 .RE
 .PP
 \-\-nlist=<filename>
 .RS 4
-This file contains a list of the private ip addresses of every node in the cluster\&. There is one line/ip address for each node\&. This file must be the same for all nodes in the cluster\&.
+This file contains a list of the private ip addresses of every node in the cluster\. There is one line/ip address for each node\. This file must be the same for all nodes in the cluster\.
 .sp
-This file is usually /etc/ctdb/nodes \&.
+This file is usually /etc/ctdb/nodes \.
 .RE
 .PP
 \-\-no\-lmaster
 .RS 4
-This argument specifies that this node can NOT become an lmaster for records in the database\&. This means that it will never show up in the vnnmap\&. This feature is primarily used for making a cluster span across a WAN link and use CTDB as a WAN\-accelerator\&.
+This argument specifies that this node can NOT become an lmaster for records in the database\. This means that it will never show up in the vnnmap\. This feature is primarily used for making a cluster span across a WAN link and use CTDB as a WAN\-accelerator\.
 .sp
-Please see the "remote cluster nodes" section for more information\&.
+Please see the "remote cluster nodes" section for more information\.
 .RE
 .PP
 \-\-no\-recmaster
 .RS 4
-This argument specifies that this node can NOT become a recmaster for the database\&. This feature is primarily used for making a cluster span across a WAN link and use CTDB as a WAN\-accelerator\&.
+This argument specifies that this node can NOT become a recmaster for the database\. This feature is primarily used for making a cluster span across a WAN link and use CTDB as a WAN\-accelerator\.
 .sp
-Please see the "remote cluster nodes" section for more information\&.
+Please see the "remote cluster nodes" section for more information\.
 .RE
 .PP
 \-\-nosetsched
 .RS 4
-This is a ctdbd debugging option\&. this option is only used when debugging ctdbd\&.
+This is a ctdbd debugging option\. this option is only used when debugging ctdbd\.
 .sp
-Normally ctdb will change its scheduler to run as a real\-time process\&. This is the default mode for a normal ctdbd operation to gurarantee that ctdbd always gets the cpu cycles that it needs\&.
+Normally ctdb will change its scheduler to run as a real\-time process\. This is the default mode for a normal ctdbd operation to gurarantee that ctdbd always gets the cpu cycles that it needs\.
 .sp
-This option is used to tell ctdbd to NOT run as a real\-time process and instead run ctdbd as a normal userspace process\&. This is useful for debugging and when you want to run ctdbd under valgrind or gdb\&. (You dont want to attach valgrind or gdb to a real\-time process\&.)
+This option is used to tell ctdbd to NOT run as a real\-time process and instead run ctdbd as a normal userspace process\. This is useful for debugging and when you want to run ctdbd under valgrind or gdb\. (You dont want to attach valgrind or gdb to a real\-time process\.)
 .RE
 .PP
 \-\-public_addresses=<filename>
 .RS 4
-When used with IP takeover this specifies a file containing the public ip addresses to use on the cluster\&. This file contains a list of ip addresses netmasks and interfaces\&. When ctdb is operational it will distribute these public ip addresses evenly across the available nodes\&.
+When used with IP takeover this specifies a file containing the public ip addresses to use on the cluster\. This file contains a list of ip addresses netmasks and interfaces\. When ctdb is operational it will distribute these public ip addresses evenly across the available nodes\.
 .sp
 This is usually the file /etc/ctdb/public_addresses
 .RE
 .PP
 \-\-public\-interface=<interface>
 .RS 4
-This option tells ctdb which interface to attach public\-addresses to and also where to attach the single\-public\-ip when used\&.
+This option tells ctdb which interface to attach public\-addresses to and also where to attach the single\-public\-ip when used\.
 .sp
-This is only required when using public ip addresses and only when you dont specify the interface explicitly in /etc/ctdb/public_addresses or when you are using \-\-single\-public\-ip\&.
+This is only required when using public ip addresses and only when you dont specify the interface explicitly in /etc/ctdb/public_addresses or when you are using \-\-single\-public\-ip\.
 .sp
-If you omit this argument when using public addresses or single public ip, ctdb will not be able to send out Gratious ARPs correctly or be able to kill tcp connections correctly which will lead to application failures\&.
+If you omit this argument when using public addresses or single public ip, ctdb will not be able to send out Gratious ARPs correctly or be able to kill tcp connections correctly which will lead to application failures\.
 .RE
 .PP
 \-\-reclock=<filename>
 .RS 4
-This is the name of the lock file stored of the shared cluster filesystem that ctdbd uses to arbitrate which node has the role of recovery\-master\&. This file must be stored on shared storage\&.
+This is the name of the lock file stored of the shared cluster filesystem that ctdbd uses to arbitrate which node has the role of recovery\-master\. This file must be stored on shared storage\.
 .RE
 .PP
 \-\-single\-public\-ip=<address>
 .RS 4
-This option is used to activate the "ipmux" or the "lvs" functionality of ctdb where the cluster provides a single public ip address for the entire cluster\&. When using this option you must also use the \-\-public\-interface option\&.
+This option is used to activate the "ipmux" or the "lvs" functionality of ctdb where the cluster provides a single public ip address for the entire cluster\. When using this option you must also use the \-\-public\-interface option\.
 .sp
-In this mode, all nodes of the cluster will expose a single ip address from all nodes with all incoming traffic to the cluster being passed through the current recmaster\&. This functionality is similar to using a load\-balancing switch\&.
+In this mode, all nodes of the cluster will expose a single ip address from all nodes with all incoming traffic to the cluster being passed through the current recmaster\. This functionality is similar to using a load\-balancing switch\.
 .sp
-All incoming packets are sent to the recmaster which will multiplex the clients across all available nodes and pass the packets on to a different node in the cluster to manage the connection based on the clients ip address\&. Outgoing packets however are sent directly from the node that was choosen back to the client\&. Since all incoming packets are sent through the recmaster this will have a throughput and performance impact when used\&. This impact in performance primarily affects write\-performance while read\-performance should be mainly unaffected\&. Only use this feature if your environment is mostly\-read (i\&.e\&. most traffic is from the nodes back to the clients) or if it is not important to get maximum write\-performance to the cluster\&.
+All incoming packets are sent to the recmaster which will multiplex the clients across all available nodes and pass the packets on to a different node in the cluster to manage the connection based on the clients ip address\. Outgoing packets however are sent directly from the node that was choosen back to the client\. Since all incoming packets are sent through the recmaster this will have a throughput and performance impact when used\. This impact in performance primarily affects write\-performance while read\-performance should be mainly unaffected\. Only use this feature if your environment is mostly\-read (i\.e\. most traffic is from the nodes back to the clients) or if it is not important to get maximum write\-performance to the cluster\.
 .sp
-This feature is completely controlled from the eventscripts and does not require any CTDBD involvement\&. However, the CTDBD daemon does need to know that the "single public ip" exists so that the CTDBD daemon will allow clients to set up killtcp to work on this ip address\&.
+This feature is completely controlled from the eventscripts and does not require any CTDBD involvement\. However, the CTDBD daemon does need to know that the "single public ip" exists so that the CTDBD daemon will allow clients to set up killtcp to work on this ip address\.
 .sp
-CTDBD only allows clients to use killtcp to kill off (RST) tcp connections to/from an ip address that is either a normal public address or to/from the ip address specified by \-\-single\-public\-ip\&. No other tcp connections are allowed to be specified with killtcp\&.
+CTDBD only allows clients to use killtcp to kill off (RST) tcp connections to/from an ip address that is either a normal public address or to/from the ip address specified by \-\-single\-public\-ip\. No other tcp connections are allowed to be specified with killtcp\.
 .sp
-Please note that ipmux is obsolete\&. Use LVS, not ipmux\&. Please see the LVS section in this manpage for instructions on how to configure and use CTDB with LVS\&.
+Please note that ipmux is obsolete\. Use LVS, not ipmux\. Please see the LVS section in this manpage for instructions on how to configure and use CTDB with LVS\.
 .RE
 .PP
 \-\-socket=<filename>
 .RS 4
-This specifies the name of the domain socket that ctdbd will create\&. This socket is used for local clients to attach to and communicate with the ctdbd daemon\&.
+This specifies the name of the domain socket that ctdbd will create\. This socket is used for local clients to attach to and communicate with the ctdbd daemon\.
 .sp
-The default is /tmp/ctdb\&.socket \&. You only need to use this option if you plan to run multiple ctdbd daemons on the same physical host\&.
+The default is /tmp/ctdb\.socket \. You only need to use this option if you plan to run multiple ctdbd daemons on the same physical host\.
 .RE
 .PP
 \-\-start\-as\-disabled
 .RS 4
-This makes the ctdb daemon to be DISABLED when it starts up\&.
+This makes the ctdb daemon to be DISABLED when it starts up\.
 .sp
-As it is DISABLED it will not get any of the public ip addresses allocated to it, and thus this allow you to start ctdb on a node without causing any ip address to failover from other nodes onto the new node\&.
+As it is DISABLED it will not get any of the public ip addresses allocated to it, and thus this allow you to start ctdb on a node without causing any ip address to failover from other nodes onto the new node\.
 .sp
-When used, the administrator must keep track of when nodes start and manually enable them again using the "ctdb enable" command, or else the node will not host any services\&.
+When used, the administrator must keep track of when nodes start and manually enable them again using the "ctdb enable" command, or else the node will not host any services\.
 .sp
-A node that is DISABLED will not host any services and will not be reachable/used by any clients\&.
+A node that is DISABLED will not host any services and will not be reachable/used by any clients\.
 .RE
 .PP
 \-\-syslog
 .RS 4
-Send all log messages to syslog instead of to the ctdb logfile\&.
+Send all log messages to syslog instead of to the ctdb logfile\.
 .RE
 .PP
 \-\-torture
 .RS 4
-This option is only used for development and testing of ctdbd\&. It adds artificial errors and failures to the common codepaths in ctdbd to verify that ctdbd can recover correctly for failures\&.
+This option is only used for development and testing of ctdbd\. It adds artificial errors and failures to the common codepaths in ctdbd to verify that ctdbd can recover correctly for failures\.
 .sp
-You do NOT want to use this option unless you are developing and testing new functionality in ctdbd\&.
+You do NOT want to use this option unless you are developing and testing new functionality in ctdbd\.
 .RE
 .PP
 \-\-transport=<STRING>
 .RS 4
-This option specifies which transport to use for ctdbd internode communications\&. The default is "tcp"\&.
+This option specifies which transport to use for ctdbd internode communications\. The default is "tcp"\.
 .sp
-Currently only "tcp" is supported but "infiniband" might be implemented in the future\&.
+Currently only "tcp" is supported but "infiniband" might be implemented in the future\.
 .RE
 .PP
 \-\-usage
 .RS 4
-Print useage information to the screen\&.
+Print useage information to the screen\.
 .RE
-.SH "Private vs Public addresses"
+.SH "PRIVATE VS PUBLIC ADDRESSES"
 .PP
-When used for ip takeover in a HA environment, each node in a ctdb cluster has multiple ip addresses assigned to it\&. One private and one or more public\&.
+When used for ip takeover in a HA environment, each node in a ctdb cluster has multiple ip addresses assigned to it\. One private and one or more public\.
 .SS "Private address"
 .PP
-This is the physical ip address of the node which is configured in linux and attached to a physical interface\&. This address uniquely identifies a physical node in the cluster and is the ip addresses that ctdbd will use to communicate with the ctdbd daemons on the other nodes in the cluster\&.
+This is the physical ip address of the node which is configured in linux and attached to a physical interface\. This address uniquely identifies a physical node in the cluster and is the ip addresses that ctdbd will use to communicate with the ctdbd daemons on the other nodes in the cluster\.
 .PP
-The private addresses are configured in /etc/ctdb/nodes (unless the \-\-nlist option is used) and contain one line for each node in the cluster\&. Each line contains the private ip address for one node in the cluster\&. This file must be the same on all nodes in the cluster\&.
+The private addresses are configured in /etc/ctdb/nodes (unless the \-\-nlist option is used) and contain one line for each node in the cluster\. Each line contains the private ip address for one node in the cluster\. This file must be the same on all nodes in the cluster\.
 .PP
-Since the private addresses are only available to the network when the corresponding node is up and running you should not use these addresses for clients to connect to services provided by the cluster\&. Instead client applications should only attach to the public addresses since these are guaranteed to always be available\&.
+Since the private addresses are only available to the network when the corresponding node is up and running you should not use these addresses for clients to connect to services provided by the cluster\. Instead client applications should only attach to the public addresses since these are guaranteed to always be available\.
 .PP
-When using ip takeover, it is strongly recommended that the private addresses are configured on a private network physically separated from the rest of the network and that this private network is dedicated to CTDB traffic\&.
+When using ip takeover, it is strongly recommended that the private addresses are configured on a private network physically separated from the rest of the network and that this private network is dedicated to CTDB traffic\.
 
       Example /etc/ctdb/nodes for a four node cluster:
       
 .sp
-.if n \{\
 .RS 4
-.\}
-.fam C
-.ps -1
 .nf
-.if t \{\
-.sp -1
-.\}
-.BB lightgray adjust-for-leading-newline
-.sp -1
-
-        10\&.1\&.1\&.1
-        10\&.1\&.1\&.2
-        10\&.1\&.1\&.3
-        10\&.1\&.1\&.4
+        10\.1\.1\.1
+        10\.1\.1\.2
+        10\.1\.1\.3
+        10\.1\.1\.4
       
-.EB lightgray adjust-for-leading-newline
-.if t \{\
-.sp 1
-.\}
 .fi
-.fam
-.ps +1
-.if n \{\
 .RE
-.\}
 .SS "Public address"
 .PP
-A public address on the other hand is not attached to an interface\&. This address is managed by ctdbd itself and is attached/detached to a physical node at runtime\&.
+A public address on the other hand is not attached to an interface\. This address is managed by ctdbd itself and is attached/detached to a physical node at runtime\.
 .PP
-The ctdb cluster will assign/reassign these public addresses across the available healthy nodes in the cluster\&. When one node fails, its public address will be migrated to and taken over by a different node in the cluster to ensure that all public addresses are always available to clients as long as there are still nodes available capable of hosting this address\&.
+The ctdb cluster will assign/reassign these public addresses across the available healthy nodes in the cluster\. When one node fails, its public address will be migrated to and taken over by a different node in the cluster to ensure that all public addresses are always available to clients as long as there are still nodes available capable of hosting this address\.
 .PP
-These addresses are not physically attached to a specific node\&. The \'ctdb ip\' command can be used to view the current assignment of public addresses and which physical node is currently serving it\&.
+These addresses are not physically attached to a specific node\. The \'ctdb ip\' command can be used to view the current assignment of public addresses and which physical node is currently serving it\.
 .PP
-On each node this file contains a list of the public addresses that this node is capable of hosting\&. The list also contain the netmask and the interface where this address should be attached for the case where you may want to serve data out through multiple different interfaces\&.
+On each node this file contains a list of the public addresses that this node is capable of hosting\. The list also contain the netmask and the interface where this address should be attached for the case where you may want to serve data out through multiple different interfaces\.
 
       Example /etc/ctdb/public_addresses for a node that can host 4 public addresses:
       
 .sp
-.if n \{\
 .RS 4
-.\}
-.fam C
-.ps -1
 .nf
-.if t \{\
-.sp -1
-.\}
-.BB lightgray adjust-for-leading-newline
-.sp -1
-
-        11\&.1\&.1\&.1/24 eth0
-        11\&.1\&.1\&.2/24 eth0
-        11\&.1\&.2\&.1/24 eth1
-        11\&.1\&.2\&.2/24 eth1
+        11\.1\.1\.1/24 eth0
+        11\.1\.1\.2/24 eth0
+        11\.1\.2\.1/24 eth1
+        11\.1\.2\.2/24 eth1
       
-.EB lightgray adjust-for-leading-newline
-.if t \{\
-.sp 1
-.\}
 .fi
-.fam
-.ps +1
-.if n \{\
 .RE
-.\}
 .PP
-In most cases this file would be the same on all nodes in a cluster but there are exceptions when one may want to use different files on different nodes\&.
+In most cases this file would be the same on all nodes in a cluster but there are exceptions when one may want to use different files on different nodes\.
 
        Example: 4 nodes partitioned into two subgroups :
        
 .sp
-.if n \{\
 .RS 4
-.\}
-.fam C
-.ps -1
 .nf
-.if t \{\
-.sp -1
-.\}
-.BB lightgray adjust-for-leading-newline
-.sp -1
-
        Node 0:/etc/ctdb/public_addresses
-               10\&.1\&.1\&.1/24 eth0
-               10\&.1\&.1\&.2/24 eth0
+               10\.1\.1\.1/24 eth0
+               10\.1\.1\.2/24 eth0
 
        Node 1:/etc/ctdb/public_addresses
-               10\&.1\&.1\&.1/24 eth0
-               10\&.1\&.1\&.2/24 eth0
+               10\.1\.1\.1/24 eth0
+               10\.1\.1\.2/24 eth0
 
        Node 2:/etc/ctdb/public_addresses
-               10\&.2\&.1\&.1/24 eth0
-               10\&.2\&.1\&.2/24 eth0
+               10\.2\.1\.1/24 eth0
+               10\.2\.1\.2/24 eth0
 
        Node 3:/etc/ctdb/public_addresses
-               10\&.2\&.1\&.1/24 eth0
-               10\&.2\&.1\&.2/24 eth0
+               10\.2\.1\.1/24 eth0
+               10\.2\.1\.2/24 eth0
        
-.EB lightgray adjust-for-leading-newline
-.if t \{\
-.sp 1
-.\}
 .fi
-.fam
-.ps +1
-.if n \{\
 .RE
-.\}
 .PP
-In this example nodes 0 and 1 host two public addresses on the 10\&.1\&.1\&.x network while nodes 2 and 3 host two public addresses for the 10\&.2\&.1\&.x network\&.
+In this example nodes 0 and 1 host two public addresses on the 10\.1\.1\.x network while nodes 2 and 3 host two public addresses for the 10\.2\.1\.x network\.
 .PP
-Ip address 10\&.1\&.1\&.1 can be hosted by either of nodes 0 or 1 and will be available to clients as long as at least one of these two nodes are available\&. If both nodes 0 and node 1 become unavailable 10\&.1\&.1\&.1 also becomes unavailable\&. 10\&.1\&.1\&.1 can not be failed over to node 2 or node 3 since these nodes do not have this ip address listed in their public addresses file\&.
-.SH "Node status"
+Ip address 10\.1\.1\.1 can be hosted by either of nodes 0 or 1 and will be available to clients as long as at least one of these two nodes are available\. If both nodes 0 and node 1 become unavailable 10\.1\.1\.1 also becomes unavailable\. 10\.1\.1\.1 can not be failed over to node 2 or node 3 since these nodes do not have this ip address listed in their public addresses file\.
+.SH "NODE STATUS"
 .PP
-The current status of each node in the cluster can be viewed by the \'ctdb status\' command\&.
+The current status of each node in the cluster can be viewed by the \'ctdb status\' command\.
 .PP
-There are five possible states for a node\&.
+There are five possible states for a node\.
 .PP
-OK \- This node is fully functional\&.
+OK \- This node is fully functional\.
 .PP
-DISCONNECTED \- This node could not be connected through the network and is currently not particpating in the cluster\&. If there is a public IP address associated with this node it should have been taken over by a different node\&. No services are running on this node\&.
+DISCONNECTED \- This node could not be connected through the network and is currently not particpating in the cluster\. If there is a public IP address associated with this node it should have been taken over by a different node\. No services are running on this node\.
 .PP
-DISABLED \- This node has been administratively disabled\&. This node is still functional and participates in the CTDB cluster but its IP addresses have been taken over by a different node and no services are currently being hosted\&.
+DISABLED \- This node has been administratively disabled\. This node is still functional and participates in the CTDB cluster but its IP addresses have been taken over by a different node and no services are currently being hosted\.
 .PP
-UNHEALTHY \- A service provided by this node is malfunctioning and should be investigated\&. The CTDB daemon itself is operational and participates in the cluster\&. Its public IP address has been taken over by a different node and no services are currently being hosted\&. All unhealthy nodes should be investigated and require an administrative action to rectify\&.
+UNHEALTHY \- A service provided by this node is malfunctioning and should be investigated\. The CTDB daemon itself is operational and participates in the cluster\. Its public IP address has been taken over by a different node and no services are currently being hosted\. All unhealthy nodes should be investigated and require an administrative action to rectify\.
 .PP
-BANNED \- This node failed too many recovery attempts and has been banned from participating in the cluster for a period of RecoveryBanPeriod seconds\&. Any public IP address has been taken over by other nodes\&. This node does not provide any services\&. All banned nodes should be investigated and require an administrative action to rectify\&. This node does not perticipate in the CTDB cluster but can still be communicated with\&. I\&.e\&. ctdb commands can be sent to it\&.
+BANNED \- This node failed too many recovery attempts and has been banned from participating in the cluster for a period of RecoveryBanPeriod seconds\. Any public IP address has been taken over by other nodes\. This node does not provide any services\. All banned nodes should be investigated and require an administrative action to rectify\. This node does not perticipate in the CTDB cluster but can still be communicated with\. I\.e\. ctdb commands can be sent to it\.
 .SH "PUBLIC TUNABLES"
 .PP
-These are the public tuneables that can be used to control how ctdb behaves\&.
+These are the public tuneables that can be used to control how ctdb behaves\.
 .SS "KeepaliveInterval"
 .PP
 Default: 1
 .PP
-How often should the nodes send keepalives to eachother\&.
+How often should the nodes send keepalives to eachother\.
 .SS "KeepaliveLimit"
 .PP
 Default: 5
 .PP
-After how many keepalive intervals without any traffic should a node wait until marking the peer as DISCONNECTED\&.
+After how many keepalive intervals without any traffic should a node wait until marking the peer as DISCONNECTED\.
 .SS "MonitorInterval"
 .PP
 Default: 15
 .PP
-How often should ctdb run the event scripts to check for a nodes health\&.
+How often should ctdb run the event scripts to check for a nodes health\.
 .SS "TickleUpdateInterval"
 .PP
 Default: 20
 .PP
-How often will ctdb record and store the "tickle" information used to kickstart stalled tcp connections after a recovery\&.
+How often will ctdb record and store the "tickle" information used to kickstart stalled tcp connections after a recovery\.
 .SS "EventScriptTimeout"
 .PP
 Default: 20
 .PP
-How long should ctdb let an event script run before aborting it and marking the node unhealthy\&.
+How long should ctdb let an event script run before aborting it and marking the node unhealthy\.
 .SS "RecoveryBanPeriod"
 .PP
 Default: 300
 .PP
-If a node becomes banned causing repetitive recovery failures\&. The node will eventually become banned from the cluster\&. This controls how long the culprit node will be banned from the cluster before it is allowed to try to join the cluster again\&. Dont set to small\&. A node gets banned for a reason and it is usually due to real problems with the node\&.
+If a node becomes banned causing repetitive recovery failures\. The node will eventually become banned from the cluster\. This controls how long the culprit node will be banned from the cluster before it is allowed to try to join the cluster again\. Dont set to small\. A node gets banned for a reason and it is usually due to real problems with the node\.
 .SS "DatabaseHashSize"
 .PP
 Default: 100000
 .PP
-Size of the hash chains for the local store of the tdbs that ctdb manages\&.
+Size of the hash chains for the local store of the tdbs that ctdb manages\.
 .SS "RerecoveryTimeout"
 .PP
 Default: 10
 .PP
-Once a recovery has completed, no additional recoveries are permitted until this timeout has expired\&.
+Once a recovery has completed, no additional recoveries are permitted until this timeout has expired\.
 .SS "EnableBans"
 .PP
 Default: 1
 .PP
-When set to 0, this disables BANNING completely in the cluster and thus nodes can not get banned, even it they break\&. Dont set to 0\&.
+When set to 0, this disables BANNING completely in the cluster and thus nodes can not get banned, even it they break\. Dont set to 0\.
 .SS "DeterministicIPs"
 .PP
 Default: 1
 .PP
-When enabled, this tunable makes ctdb try to keep public IP addresses locked to specific nodes as far as possible\&. This makes it easier for debugging since you can know that as long as all nodes are healthy public IP X will always be hosted by node Y\&.
+When enabled, this tunable makes ctdb try to keep public IP addresses locked to specific nodes as far as possible\. This makes it easier for debugging since you can know that as long as all nodes are healthy public IP X will always be hosted by node Y\.
 .PP
-The cost of using deterministic IP address assignment is that it disables part of the logic where ctdb tries to reduce the number of public IP assignment changes in the cluster\&. This tunable may increase the number of IP failover/failbacks that are performed on the cluster by a small margin\&.
+The cost of using deterministic IP address assignment is that it disables part of the logic where ctdb tries to reduce the number of public IP assignment changes in the cluster\. This tunable may increase the number of IP failover/failbacks that are performed on the cluster by a small margin\.
 .SS "DisableWhenUnhealthy"
 .PP
 Default: 0
 .PP
-When set, As soon as a node becomes unhealthy, that node will also automatically become permanently DISABLED\&. Once a node is DISABLED, the only way to make it participate in the cluster again and host services is by manually enabling the node again using \'ctdb enable\'\&.
+When set, As soon as a node becomes unhealthy, that node will also automatically become permanently DISABLED\. Once a node is DISABLED, the only way to make it participate in the cluster again and host services is by manually enabling the node again using \'ctdb enable\'\.
 .PP
-This disables parts of the resilience and robustness of the cluster and should ONLY be used when the system administrator is actively monitoring the cluster, so that nodes can be enabled again\&.
+This disables parts of the resilience and robustness of the cluster and should ONLY be used when the system administrator is actively monitoring the cluster, so that nodes can be enabled again\.
 .SS "NoIPFailback"
 .PP
 Default: 0
 .PP
-When set to 1, ctdb will not perform failback of IP addresses when a node becomes healthy\&. Ctdb WILL perform failover of public IP addresses when a node becomes UNHEALTHY, but when the node becomes HEALTHY again, ctdb will not fail the addresses back\&.
+When set to 1, ctdb will not perform failback of IP addresses when a node becomes healthy\. Ctdb WILL perform failover of public IP addresses when a node becomes UNHEALTHY, but when the node becomes HEALTHY again, ctdb will not fail the addresses back\.
 .PP
-Use with caution! Normally when a node becomes available to the cluster ctdb will try to reassign public IP addresses onto the new node as a way to distribute the workload evenly across the clusternode\&. Ctdb tries to make sure that all running nodes have approximately the same number of public addresses it hosts\&.
+Use with caution! Normally when a node becomes available to the cluster ctdb will try to reassign public IP addresses onto the new node as a way to distribute the workload evenly across the clusternode\. Ctdb tries to make sure that all running nodes have approximately the same number of public addresses it hosts\.
 .PP
-When you enable this tunable, CTDB will no longer attempt to rebalance the cluster by failing IP addresses back to the new nodes\&. An unbalanced cluster will therefore remain unbalanced until there is manual intervention from the administrator\&. When this parameter is set, you can manually fail public IP addresses over to the new node(s) using the \'ctdb moveip\' command\&.
+When you enable this tunable, CTDB will no longer attempt to rebalance the cluster by failing IP addresses back to the new nodes\. An unbalanced cluster will therefore remain unbalanced until there is manual intervention from the administrator\. When this parameter is set, you can manually fail public IP addresses over to the new node(s) using the \'ctdb moveip\' command\.
 .SH "LVS"
 .PP
-LVS is a mode where CTDB presents one single IP address for the entire cluster\&. This is an alternative to using public IP addresses and round\-robin DNS to loadbalance clients across the cluster\&.
+LVS is a mode where CTDB presents one single IP address for the entire cluster\. This is an alternative to using public IP addresses and round\-robin DNS to loadbalance clients across the cluster\.
 .PP
-This is similar to using a layer\-4 loadbalancing switch but with some restrictions\&.
+This is similar to using a layer\-4 loadbalancing switch but with some restrictions\.
 .PP
-In this mode the cluster select a set of nodes in the cluster and loadbalance all client access to the LVS address across this set of nodes\&. This set of nodes are all LVS capable nodes that are HEALTHY, or if no HEALTHY nodes exists all LVS capable nodes regardless of health status\&. LVS will however never loadbalance traffic to nodes that are BANNED, DISABLED or DISCONNECTED\&. The "ctdb lvs" command is used to show which nodes are currently load\-balanced across\&.
+In this mode the cluster select a set of nodes in the cluster and loadbalance all client access to the LVS address across this set of nodes\. This set of nodes are all LVS capable nodes that are HEALTHY, or if no HEALTHY nodes exists all LVS capable nodes regardless of health status\. LVS will however never loadbalance traffic to nodes that are BANNED, DISABLED or DISCONNECTED\. The "ctdb lvs" command is used to show which nodes are currently load\-balanced across\.
 .PP
-One of the these nodes are elected as the LVSMASTER\&. This node receives all traffic from clients coming in to the LVS address and multiplexes it across the internal network to one of the nodes that LVS is using\&. When responding to the client, that node will send the data back directly to the client, bypassing the LVSMASTER node\&. The command "ctdb lvsmaster" will show which node is the current LVSMASTER\&.
+One of the these nodes are elected as the LVSMASTER\. This node receives all traffic from clients coming in to the LVS address and multiplexes it across the internal network to one of the nodes that LVS is using\. When responding to the client, that node will send the data back directly to the client, bypassing the LVSMASTER node\. The command "ctdb lvsmaster" will show which node is the current LVSMASTER\.
 .PP
 The path used for a client i/o is thus :
 .sp
-.if n \{\
 .RS 4
-.\}
-.fam C
-.ps -1
 .nf
-.if t \{\
-.sp -1
-.\}
-.BB lightgray adjust-for-leading-newline
-.sp -1
-
        (1) Client sends request packet to LVSMASTER
-       (2) LVSMASTER passes the request on to one node across the internal network\&.
-       (3) Selected node processes the request\&.
-       (4) Node responds back to client\&.
+       (2) LVSMASTER passes the request on to one node across the internal network\.
+       (3) Selected node processes the request\.
+       (4) Node responds back to client\.
     
-.EB lightgray adjust-for-leading-newline
-.if t \{\
-.sp 1
-.\}
 .fi
-.fam
-.ps +1
-.if n \{\
 .RE
-.\}
 .PP
-This means that all incoming traffic to the cluster will pass through one physical node, which limits scalability\&. You can send more data to the LVS address that one physical node can multiplex\&. This means that you should not use LVS if your I/O pattern is write\-intensive since you will be limited in the available network bandwidth that node can handle\&. LVS does work wery well for read\-intensive workloads where only smallish READ requests are going through the LVSMASTER bottleneck and the majority of the traffic volume (the data in the read replies) goes straight from the processing node back to the clients\&. For read\-intensive i/o patterns you can acheive very high throughput rates in this mode\&.
+This means that all incoming traffic to the cluster will pass through one physical node, which limits scalability\. You can send more data to the LVS address that one physical node can multiplex\. This means that you should not use LVS if your I/O pattern is write\-intensive since you will be limited in the available network bandwidth that node can handle\. LVS does work wery well for read\-intensive workloads where only smallish READ requests are going through the LVSMASTER bottleneck and the majority of the traffic volume (the data in the read replies) goes straight from the processing node back to the clients\. For read\-intensive i/o patterns you can acheive very high throughput rates in this mode\.
 .PP
-Note: you can use LVS and public addresses at the same time\&.
+Note: you can use LVS and public addresses at the same time\.
 .SS "Configuration"
 .PP
-To activate LVS on a CTDB node you must specify CTDB_PUBLIC_INTERFACE and CTDB_LVS_PUBLIC_ADDRESS in /etc/sysconfig/ctdb\&.
+To activate LVS on a CTDB node you must specify CTDB_PUBLIC_INTERFACE and CTDB_LVS_PUBLIC_ADDRESS in /etc/sysconfig/ctdb\.
 .PP
-You must also specify the "\-\-lvs" command line argument to ctdbd to activete LVS as a capability of the node\&. This should be done automatically for you by the /etc/init\&.d/ctdb script\&.
+You must also specify the "\-\-lvs" command line argument to ctdbd to activete LVS as a capability of the node\. This should be done automatically for you by the /etc/init\.d/ctdb script\.
 .PP
 Example:
 .sp
-.if n \{\
 .RS 4
-.\}
-.fam C
-.ps -1
 .nf
-.if t \{\
-.sp -1
-.\}
-.BB lightgray adjust-for-leading-newline
-.sp -1
-
        CTDB_PUBLIC_INTERFACE=eth0
-       CTDB_LVS_PUBLIC_IP=10\&.0\&.0\&.237
+       CTDB_LVS_PUBLIC_IP=10\.0\.0\.237
        
-.EB lightgray adjust-for-leading-newline
-.if t \{\
-.sp 1
-.\}
 .fi
-.fam
-.ps +1
-.if n \{\
 .RE
-.\}
 .PP
-If you use LVS, you must still have a real/permanent address configured for the public interface on each node\&. This address must be routable and the cluster nodes must be configured so that all traffic back to client hosts are routed through this interface\&. This is also required in order to allow samba/winbind on the node to talk to the domain controller\&. (we can not use the lvs IP address to initiate outgoing traffic)
+If you use LVS, you must still have a real/permanent address configured for the public interface on each node\. This address must be routable and the cluster nodes must be configured so that all traffic back to client hosts are routed through this interface\. This is also required in order to allow samba/winbind on the node to talk to the domain controller\. (we can not use the lvs IP address to initiate outgoing traffic)
 .PP
-I\&.e\&. make sure that you can "ping" both the domain controller and also all of the clients from the node BEFORE you enable LVS\&. Also make sure that when you ping these hosts that the traffic is routed out through the eth0 interface\&.
+I\.e\. make sure that you can "ping" both the domain controller and also all of the clients from the node BEFORE you enable LVS\. Also make sure that when you ping these hosts that the traffic is routed out through the eth0 interface\.
 .SH "REMOTE CLUSTER NODES"
 .PP
-It is possible to have a CTDB cluster that spans across a WAN link\&. For example where you have a CTDB cluster in your datacentre but you also want to have one additional CTDB node located at a remote branch site\&. This is similar to how a WAN accelerator works but with the difference that while a WAN\-accelerator often acts as a Proxy or a MitM, in the ctdb remote cluster node configuration the Samba instance at the remote site IS the genuine server, not a proxy and not a MitM, and thus provides 100% correct CIFS semantics to clients\&.
+It is possible to have a CTDB cluster that spans across a WAN link\. For example where you have a CTDB cluster in your datacentre but you also want to have one additional CTDB node located at a remote branch site\. This is similar to how a WAN accelerator works but with the difference that while a WAN\-accelerator often acts as a Proxy or a MitM, in the ctdb remote cluster node configuration the Samba instance at the remote site IS the genuine server, not a proxy and not a MitM, and thus provides 100% correct CIFS semantics to clients\.
 .PP
-See the cluster as one single multihomed samba server where one of the NICs (the remote node) is very far away\&.
+See the cluster as one single multihomed samba server where one of the NICs (the remote node) is very far away\.
 .PP
-NOTE: This does require that the cluster filesystem you use can cope with WAN\-link latencies\&. Not all cluster filesystems can handle WAN\-link latencies! Whether this will provide very good WAN\-accelerator performance or it will perform very poorly depends entirely on how optimized your cluster filesystem is in handling high latency for data and metadata operations\&.
+NOTE: This does require that the cluster filesystem you use can cope with WAN\-link latencies\. Not all cluster filesystems can handle WAN\-link latencies! Whether this will provide very good WAN\-accelerator performance or it will perform very poorly depends entirely on how optimized your cluster filesystem is in handling high latency for data and metadata operations\.
 .PP
 To activate a node as being a remote cluster node you need to set the following two parameters in /etc/sysconfig/ctdb for the remote node:
 .sp
-.if n \{\
 .RS 4
-.\}
-.fam C
-.ps -1
 .nf
-.if t \{\
-.sp -1
-.\}
-.BB lightgray adjust-for-leading-newline
-.sp -1
-
 CTDB_CAPABILITY_LMASTER=no
 CTDB_CAPABILITY_RECMASTER=no
        
-.EB lightgray adjust-for-leading-newline
-.if t \{\
-.sp 1
-.\}
 .fi
-.fam
-.ps +1
-.if n \{\
 .RE
-.\}
 .PP
-Verify with the command "ctdb getcapabilities" that that node no longer has the recmaster or the lmaster capabilities\&.
+Verify with the command "ctdb getcapabilities" that that node no longer has the recmaster or the lmaster capabilities\.
+.SH "NAT-GW"
+.PP
+Sometimes it is desireable to run services on the CTDB node which will need to originate outgoing traffic to external servers\. This might be contacting NIS servers, LDAP servers etc\. etc\.
+.PP
+This can sometimes be problematic since there are situations when a node does not have any public ip addresses assigned\. This could be due to the nobe just being started up and no addresses have been assigned yet or it could be that the node is UNHEALTHY in which case all public addresses have been migrated off\.
+.PP
+If then the service status of CTDB depends on such services being able to always being able to originate traffic to external resources this becomes extra troublesome\. The node might be UNHEALTHY because the service can not be reached, and the service can not be reached because the node is UNHEALTHY\.
+.PP
+There are two ways to solve this problem\. The first is by assigning a static ip address for one public interface on every node which will allow every node to be able to route traffic to the public network even if there are no public addresses assigned to the node\. This is the simplest way but it uses up a lot of ip addresses since you have to assign both static and also public addresses to each node\.
+.SS "NAT\-GW"
+.PP
+A second way is to use the built in NAT\-GW feature in CTDB\. With NAT\-GW you assign one public NATGW address for each natgw group\. Each NATGW group is a set of nodes in the cluster that shares the same NATGW address to talk to the outside world\. Normally there would only be one NATGW group spanning the entire cluster, but in situations where one ctdb cluster spans multiple physical sites it is useful to have one NATGW group for each of the two sites\.
+.PP
+There can be multiple NATGW groups in one cluster but each node can only be member of one NATGW group\.
+.PP
+In each NATGW group, one of the nodes is designated the NAT Gateway through which all traffic that is originated by nodes in this group will be routed through if a public addresses are not available\.
+.SS "Configuration"
+.PP
+NAT\-GW is configured in /etc/sysconfigctdb by setting the following variables:
+.sp
+.RS 4
+.nf
+# NAT\-GW configuration
+# Some services running on nthe CTDB node may need to originate traffic to
+# remote servers before the node is assigned any IP addresses,
+# This is problematic since before the node has public addresses the node might
+# not be able to route traffic to the public networks\.
+# One solution is to have static public addresses assigned with routing
+# in addition to the public address interfaces, thus guaranteeing that
+# a node always can route traffic to the external network\.
+# This is the most simple solution but it uses up a large number of 
+# additional ip addresses\.
+#
+# A more complex solution is NAT\-GW\.
+# In this mode we only need one additional ip address for the cluster from
+# the exsternal public network\.
+# One of the nodes in the cluster is elected to be hosting this ip address
+# so it can reach the external services\. This node is also configured
+# to use NAT MASQUERADING for all traffic from the internal private network
+# to the external network\. This node is the NAT\-GW node\.
+#
+# All other nodes are set up with a default rote with a metric of 10 to point
+# to the nat\-gw node\.
+# 
+# The effect of this is that only when a node does not have a public address
+# and thus no proper routes to the external world it will instead
+# route all packets through the nat\-gw node\.
+#
+# NATGW_NODES is the list of nodes that belong to this natgw group\.
+# You can have multiple natgw groups in one cluster but each node
+# can only belong to one single natgw group\.
+#
+# NATGW_PUBLIC_IP=10\.0\.0\.227/24
+# NATGW_PUBLIC_IFACE=eth0
+# NATGW_DEFAULT_GATEWAY=10\.0\.0\.1
+# NATGW_PRIVATE_IFACE=eth1
+# NATGW_PRIVATE_NETWORK=10\.1\.1\.0/24
+# NATGW_NODES=/etc/ctdb/natgw_nodes
+    
+.fi
+.RE
+.SS "NATGW_PUBLIC_IP"
+.PP
+This is an ip address in the public network that is used for all outgoing traffic when the public addresses are not assigned\. This address will be assigned to one of the nodes in the cluster which will masquerade all traffic for the other nodes\.
+.PP
+Format of this parameter is IPADDRESS/NETMASK
+.SS "NATGW_PUBLIC_IFACE"
+.PP
+This is the physical interface where the NATGW_PUBLIC_IP will be assigned to\. This should be an interface connected to the public network\.
+.PP
+Format of this parameter is INTERFACE
+.SS "NATGW_DEFAULT_GATEWAY"
+.PP
+This is the default gateway to use on the node that is elected to host the NATGW_PUBLIC_IP\. This is the default gateway on the public network\.
+.PP
+Format of this parameter is IPADDRESS
+.SS "NATGW_PRIVATE_IFACE"
+.PP
+This is the interface used for the interal private network\.
+.PP
+Format of this parameter is INTERFACE
+.SS "NATGW_PRIVATE_NETWORK"
+.PP
+This is the network/netmask used for the interal private network\.
+.PP
+Format of this parameter is IPADDRESS/NETMASK
+.SS "NATGW_NODES"
+.PP
+This is the list of all nodes that belong to the same NATGW group as this node\. The default is /etc/ctdb/natgw_nodes\.
+.SS "Operation"
+.PP
+When the NAT\-GW fiunctionality is used, one of the nodes is elected to act as a NAT router for all the other nodes in the group when they need to originate traffic to the external public network\.
+.PP
+The NAT\-GW node is assigned the NATGW_PUBLIC_IP to the designated interface and the provided default route\. The NAT\-GW is configured to act as a router and to masquerade all traffic it receives from the internal private network and which is destined to the external network(s)\.
+.PP
+All other nodes in the group are configured with a default route of metric 10 pointing to the designated NAT GW node\.
+.PP
+This is implemented in the 11\.natgw eventscript\. Please see the eventscript for further information\.
 .SH "SEE ALSO"
 .PP
 ctdb(1), onnode(1)
-\m[blue]\fB\%http://ctdb.samba.org/\fR\m[]
+\fI\%http://ctdb.samba.org/\fR
 .SH "COPYRIGHT/LICENSE"
 .sp
-.if n \{\
 .RS 4
-.\}
-.fam C
-.ps -1
 .nf
-.if t \{\
-.sp -1
-.\}
-.BB lightgray adjust-for-leading-newline
-.sp -1
-
 Copyright (C) Andrew Tridgell 2007
 Copyright (C) Ronnie sahlberg 2007
 
 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 3 of the License, or (at
-your option) any later version\&.
+your option) any later version\.
 
 This program 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\&.
+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, see http://www\&.gnu\&.org/licenses/\&.
-.EB lightgray adjust-for-leading-newline
-.if t \{\
-.sp 1
-.\}
+along with this program; if not, see http://www\.gnu\.org/licenses/\.
 .fi
-.fam
-.ps +1
-.if n \{\
 .RE
-.\}
index 874308e0f7a4540ad0ecaf8d6a882395e570cccb..678147765609541f2b641b9da64b3868b2f0e4a9 100644 (file)
@@ -415,10 +415,131 @@ CTDB_CAPABILITY_RECMASTER=no
     </p><p>
        Verify with the command "ctdb getcapabilities" that that node no longer
        has the recmaster or the lmaster capabilities.
-    </p></div><div class="refsect1" lang="en"><a name="id2529453"></a><h2>SEE ALSO</h2><p>
+    </p></div><div class="refsect1" lang="en"><a name="id2529453"></a><h2>NAT-GW</h2><p>
+      Sometimes it is desireable to run services on the CTDB node which will
+      need to originate outgoing traffic to external servers. This might
+      be contacting NIS servers, LDAP servers etc. etc.
+    </p><p>
+      This can sometimes be problematic since there are situations when a
+      node does not have any public ip addresses assigned. This could
+      be due to the nobe just being started up and no addresses have been
+      assigned yet or it could be that the node is UNHEALTHY in which
+      case all public addresses have been migrated off.
+    </p><p>
+      If then the service status of CTDB depends on such services being
+      able to always being able to originate traffic to external resources
+      this becomes extra troublesome. The node might be UNHEALTHY because
+      the service can not be reached, and the service can not be reached
+      because the node is UNHEALTHY.
+    </p><p>
+      There are two ways to solve this problem. The first is by assigning a
+      static ip address for one public interface on every node which will allow
+      every node to be able to route traffic to the public network even
+      if there are no public addresses assigned to the node.
+      This is the simplest way but it uses up a lot of ip addresses since you
+      have to assign both static and also public addresses to each node.
+    </p><div class="refsect2" lang="en"><a name="id2529493"></a><h3>NAT-GW</h3><p>
+      A second way is to use the built in NAT-GW feature in CTDB.
+      With NAT-GW you assign one public NATGW address for each natgw group.
+      Each NATGW group is a set of nodes in the cluster that shares the same
+      NATGW address to talk to the outside world. Normally there would only be
+      one NATGW group spanning the entire cluster, but in situations where one
+      ctdb cluster spans multiple physical sites it is useful to have one
+      NATGW group for each of the two sites.
+    </p><p>
+      There can be multiple NATGW groups in one cluster but each node can only
+      be member of one NATGW group.
+    </p><p>
+      In each NATGW group, one of the nodes is designated the NAT Gateway
+      through which all traffic that is originated by nodes in this group
+      will be routed through if a public addresses are not available. 
+    </p></div><div class="refsect2" lang="en"><a name="id2529523"></a><h3>Configuration</h3><p>
+      NAT-GW is configured in /etc/sysconfigctdb by setting the following
+      variables:
+    </p><pre class="screen">
+# NAT-GW configuration
+# Some services running on nthe CTDB node may need to originate traffic to
+# remote servers before the node is assigned any IP addresses,
+# This is problematic since before the node has public addresses the node might
+# not be able to route traffic to the public networks.
+# One solution is to have static public addresses assigned with routing
+# in addition to the public address interfaces, thus guaranteeing that
+# a node always can route traffic to the external network.
+# This is the most simple solution but it uses up a large number of 
+# additional ip addresses.
+#
+# A more complex solution is NAT-GW.
+# In this mode we only need one additional ip address for the cluster from
+# the exsternal public network.
+# One of the nodes in the cluster is elected to be hosting this ip address
+# so it can reach the external services. This node is also configured
+# to use NAT MASQUERADING for all traffic from the internal private network
+# to the external network. This node is the NAT-GW node.
+#
+# All other nodes are set up with a default rote with a metric of 10 to point
+# to the nat-gw node.
+# 
+# The effect of this is that only when a node does not have a public address
+# and thus no proper routes to the external world it will instead
+# route all packets through the nat-gw node.
+#
+# NATGW_NODES is the list of nodes that belong to this natgw group.
+# You can have multiple natgw groups in one cluster but each node
+# can only belong to one single natgw group.
+#
+# NATGW_PUBLIC_IP=10.0.0.227/24
+# NATGW_PUBLIC_IFACE=eth0
+# NATGW_DEFAULT_GATEWAY=10.0.0.1
+# NATGW_PRIVATE_IFACE=eth1
+# NATGW_PRIVATE_NETWORK=10.1.1.0/24
+# NATGW_NODES=/etc/ctdb/natgw_nodes
+    </pre></div><div class="refsect2" lang="en"><a name="id2476123"></a><h3>NATGW_PUBLIC_IP</h3><p>
+      This is an ip address in the public network that is used for all outgoing
+      traffic when the public addresses are not assigned.
+      This address will be assigned to one of the nodes in the cluster which
+      will masquerade all traffic for the other nodes.
+    </p><p>
+      Format of this parameter is IPADDRESS/NETMASK
+    </p></div><div class="refsect2" lang="en"><a name="id2476141"></a><h3>NATGW_PUBLIC_IFACE</h3><p>
+      This is the physical interface where the NATGW_PUBLIC_IP will be
+      assigned to. This should be an interface connected to the public network.
+    </p><p>
+      Format of this parameter is INTERFACE
+    </p></div><div class="refsect2" lang="en"><a name="id2476157"></a><h3>NATGW_DEFAULT_GATEWAY</h3><p>
+      This is the default gateway to use on the node that is elected to host
+      the NATGW_PUBLIC_IP. This is the default gateway on the public network.
+    </p><p>
+      Format of this parameter is IPADDRESS
+    </p></div><div class="refsect2" lang="en"><a name="id2476172"></a><h3>NATGW_PRIVATE_IFACE</h3><p>
+      This is the interface used for the interal private network.
+    </p><p>
+      Format of this parameter is INTERFACE
+    </p></div><div class="refsect2" lang="en"><a name="id2476187"></a><h3>NATGW_PRIVATE_NETWORK</h3><p>
+      This is the network/netmask used for the interal private network.
+    </p><p>
+      Format of this parameter is IPADDRESS/NETMASK
+    </p></div><div class="refsect2" lang="en"><a name="id2476201"></a><h3>NATGW_NODES</h3><p>
+      This is the list of all nodes that belong to the same NATGW group
+      as this node. The default is /etc/ctdb/natgw_nodes.
+    </p></div><div class="refsect2" lang="en"><a name="id2476212"></a><h3>Operation</h3><p>
+      When the NAT-GW fiunctionality is used, one of the nodes is elected
+      to act as a NAT router for all the other nodes in the group when
+      they need to originate traffic to the external public network.
+    </p><p>
+      The NAT-GW node is assigned the NATGW_PUBLIC_IP to the designated
+      interface and the provided default route. The NAT-GW is configured
+      to act as a router and to masquerade all traffic it receives from the
+      internal private network and which is destined to the external network(s).
+    </p><p>
+      All other nodes in the group are configured with a default route of
+      metric 10 pointing to the designated NAT GW node.
+    </p><p>
+      This is implemented in the 11.natgw eventscript. Please see the
+      eventscript for further information.
+    </p></div></div><div class="refsect1" lang="en"><a name="id2476245"></a><h2>SEE ALSO</h2><p>
       ctdb(1), onnode(1)
       <a class="ulink" href="http://ctdb.samba.org/" target="_top">http://ctdb.samba.org/</a>
-    </p></div><div class="refsect1" lang="en"><a name="id2529466"></a><h2>COPYRIGHT/LICENSE</h2><div class="literallayout"><p><br>
+    </p></div><div class="refsect1" lang="en"><a name="id2476258"></a><h2>COPYRIGHT/LICENSE</h2><div class="literallayout"><p><br>
 Copyright (C) Andrew Tridgell 2007<br>
 Copyright (C) Ronnie sahlberg 2007<br>
 <br>
index d69d3dcbc85b2867548446e1a90507893be58a6b..f90b671bc5b4c4522c5d3b3d57b49354be83e23c 100644 (file)
@@ -780,6 +780,183 @@ CTDB_CAPABILITY_RECMASTER=no
   </refsect1>
 
 
+  <refsect1><title>NAT-GW</title>
+    <para>
+      Sometimes it is desireable to run services on the CTDB node which will
+      need to originate outgoing traffic to external servers. This might
+      be contacting NIS servers, LDAP servers etc. etc.
+    </para>
+    <para>
+      This can sometimes be problematic since there are situations when a
+      node does not have any public ip addresses assigned. This could
+      be due to the nobe just being started up and no addresses have been
+      assigned yet or it could be that the node is UNHEALTHY in which
+      case all public addresses have been migrated off.
+    </para>
+    <para>
+      If then the service status of CTDB depends on such services being
+      able to always being able to originate traffic to external resources
+      this becomes extra troublesome. The node might be UNHEALTHY because
+      the service can not be reached, and the service can not be reached
+      because the node is UNHEALTHY.
+    </para>
+    <para>
+      There are two ways to solve this problem. The first is by assigning a
+      static ip address for one public interface on every node which will allow
+      every node to be able to route traffic to the public network even
+      if there are no public addresses assigned to the node.
+      This is the simplest way but it uses up a lot of ip addresses since you
+      have to assign both static and also public addresses to each node.
+    </para>
+    <refsect2><title>NAT-GW</title>
+    <para>
+      A second way is to use the built in NAT-GW feature in CTDB.
+      With NAT-GW you assign one public NATGW address for each natgw group.
+      Each NATGW group is a set of nodes in the cluster that shares the same
+      NATGW address to talk to the outside world. Normally there would only be
+      one NATGW group spanning the entire cluster, but in situations where one
+      ctdb cluster spans multiple physical sites it is useful to have one
+      NATGW group for each of the two sites.
+    </para>
+    <para>
+      There can be multiple NATGW groups in one cluster but each node can only
+      be member of one NATGW group.
+    </para>
+    <para>
+      In each NATGW group, one of the nodes is designated the NAT Gateway
+      through which all traffic that is originated by nodes in this group
+      will be routed through if a public addresses are not available. 
+    </para>
+    </refsect2>
+
+    <refsect2><title>Configuration</title>
+    <para>
+      NAT-GW is configured in /etc/sysconfigctdb by setting the following
+      variables:
+    </para>
+    <screen format="linespecific">
+# NAT-GW configuration
+# Some services running on nthe CTDB node may need to originate traffic to
+# remote servers before the node is assigned any IP addresses,
+# This is problematic since before the node has public addresses the node might
+# not be able to route traffic to the public networks.
+# One solution is to have static public addresses assigned with routing
+# in addition to the public address interfaces, thus guaranteeing that
+# a node always can route traffic to the external network.
+# This is the most simple solution but it uses up a large number of 
+# additional ip addresses.
+#
+# A more complex solution is NAT-GW.
+# In this mode we only need one additional ip address for the cluster from
+# the exsternal public network.
+# One of the nodes in the cluster is elected to be hosting this ip address
+# so it can reach the external services. This node is also configured
+# to use NAT MASQUERADING for all traffic from the internal private network
+# to the external network. This node is the NAT-GW node.
+#
+# All other nodes are set up with a default rote with a metric of 10 to point
+# to the nat-gw node.
+# 
+# The effect of this is that only when a node does not have a public address
+# and thus no proper routes to the external world it will instead
+# route all packets through the nat-gw node.
+#
+# NATGW_NODES is the list of nodes that belong to this natgw group.
+# You can have multiple natgw groups in one cluster but each node
+# can only belong to one single natgw group.
+#
+# NATGW_PUBLIC_IP=10.0.0.227/24
+# NATGW_PUBLIC_IFACE=eth0
+# NATGW_DEFAULT_GATEWAY=10.0.0.1
+# NATGW_PRIVATE_IFACE=eth1
+# NATGW_PRIVATE_NETWORK=10.1.1.0/24
+# NATGW_NODES=/etc/ctdb/natgw_nodes
+    </screen>
+    </refsect2>
+
+    <refsect2><title>NATGW_PUBLIC_IP</title>
+    <para>
+      This is an ip address in the public network that is used for all outgoing
+      traffic when the public addresses are not assigned.
+      This address will be assigned to one of the nodes in the cluster which
+      will masquerade all traffic for the other nodes.
+    </para>
+    <para>
+      Format of this parameter is IPADDRESS/NETMASK
+    </para>
+    </refsect2>
+
+    <refsect2><title>NATGW_PUBLIC_IFACE</title>
+    <para>
+      This is the physical interface where the NATGW_PUBLIC_IP will be
+      assigned to. This should be an interface connected to the public network.
+    </para>
+    <para>
+      Format of this parameter is INTERFACE
+    </para>
+    </refsect2>
+
+    <refsect2><title>NATGW_DEFAULT_GATEWAY</title>
+    <para>
+      This is the default gateway to use on the node that is elected to host
+      the NATGW_PUBLIC_IP. This is the default gateway on the public network.
+    </para>
+    <para>
+      Format of this parameter is IPADDRESS
+    </para>
+    </refsect2>
+
+    <refsect2><title>NATGW_PRIVATE_IFACE</title>
+    <para>
+      This is the interface used for the interal private network.
+    </para>
+    <para>
+      Format of this parameter is INTERFACE
+    </para>
+    </refsect2>
+
+    <refsect2><title>NATGW_PRIVATE_NETWORK</title>
+    <para>
+      This is the network/netmask used for the interal private network.
+    </para>
+    <para>
+      Format of this parameter is IPADDRESS/NETMASK
+    </para>
+    </refsect2>
+
+    <refsect2><title>NATGW_NODES</title>
+    <para>
+      This is the list of all nodes that belong to the same NATGW group
+      as this node. The default is /etc/ctdb/natgw_nodes.
+    </para>
+    </refsect2>
+
+    <refsect2><title>Operation</title>
+    <para>
+      When the NAT-GW fiunctionality is used, one of the nodes is elected
+      to act as a NAT router for all the other nodes in the group when
+      they need to originate traffic to the external public network.
+    </para>
+    <para>
+      The NAT-GW node is assigned the NATGW_PUBLIC_IP to the designated
+      interface and the provided default route. The NAT-GW is configured
+      to act as a router and to masquerade all traffic it receives from the
+      internal private network and which is destined to the external network(s).
+    </para>
+    <para>
+      All other nodes in the group are configured with a default route of
+      metric 10 pointing to the designated NAT GW node.
+    </para>
+    <para>
+      This is implemented in the 11.natgw eventscript. Please see the
+      eventscript for further information.
+    </para>
+
+    </refsect2>
+
+  </refsect1>
+
+
 
   <refsect1><title>SEE ALSO</title>
     <para>
index 2ec477f608f591b31a6a37412ad1b9b512e45345..866ba76e2a8edd4a450bdd11ce712308bbf40787 100644 (file)
@@ -610,4 +610,30 @@ int ctdb_transaction_commit(struct ctdb_transaction_handle *h);
 
 int ctdb_ctrl_recd_ping(struct ctdb_context *ctdb);
 
+int switch_from_server_to_client(struct ctdb_context *ctdb);
+
+#define MONITOR_SCRIPT_OK      0
+#define MONITOR_SCRIPT_TIMEOUT 1
+
+#define MAX_SCRIPT_NAME 31
+#define MAX_SCRIPT_OUTPUT 511
+struct ctdb_monitoring_script_wire {
+       char name[MAX_SCRIPT_NAME+1];
+       struct timeval start;
+       struct timeval finished;
+       int32_t status;
+       int32_t timedout;
+       char output[MAX_SCRIPT_OUTPUT+1];
+};
+
+struct ctdb_monitoring_wire {
+       uint32_t num_scripts;
+       struct ctdb_monitoring_script_wire scripts[1];
+};
+
+int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb, 
+                   struct timeval timeout, uint32_t destnode, 
+                   TALLOC_CTX *mem_ctx, struct ctdb_monitoring_wire **script_status);
+
+
 #endif
index ceac3842bd72c10ac7352a81d79dd7c11849fcde..88e686bc9bab863e4eeb81391f0d839192dcfcc9 100644 (file)
@@ -77,7 +77,7 @@ struct ctdb_tcp_array {
 /* all tunable variables go in here */
 struct ctdb_tunable {
        uint32_t max_redirect_count;
-       uint32_t seqnum_frequency;
+       uint32_t seqnum_interval; /* unit is ms */
        uint32_t control_timeout;
        uint32_t traverse_timeout;
        uint32_t keepalive_interval;
@@ -400,6 +400,7 @@ struct ctdb_context {
        void *saved_scheduler_param;
        struct _trbt_tree_t *server_ids;        
        const char *event_script_dir;
+       const char *notification_script;
        const char *default_public_interface;
        pid_t ctdbd_pid;
        pid_t recoverd_pid;
@@ -412,6 +413,8 @@ struct ctdb_context {
        TALLOC_CTX *eventscripts_ctx; /* a context to hold data for the RUN_EVENTSCRIPTS control */
        uint32_t *recd_ping_count;
        TALLOC_CTX *release_ips_ctx; /* a context used to automatically drop all IPs if we fail to recover the node */
+       TALLOC_CTX *script_monitoring_ctx; /* a context where we store results while running the monitor event */
+       TALLOC_CTX *last_monitoring_ctx; 
 };
 
 struct ctdb_db_context {
@@ -550,6 +553,11 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
                    CTDB_CONTROL_TAKEOVER_IP             = 89,
                    CTDB_CONTROL_GET_PUBLIC_IPS          = 90,
                    CTDB_CONTROL_GET_NODEMAP             = 91,
+                   CTDB_CONTROL_EVENT_SCRIPT_INIT       = 92,
+                   CTDB_CONTROL_EVENT_SCRIPT_START      = 93,
+                   CTDB_CONTROL_EVENT_SCRIPT_STOP       = 94,
+                   CTDB_CONTROL_EVENT_SCRIPT_FINISHED   = 95,
+                   CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS = 96,
 };     
 
 /*
@@ -1120,7 +1128,6 @@ int daemon_deregister_message_handler(struct ctdb_context *ctdb, uint32_t client
 
 int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context *ctdb, uint32_t db_id);
 int32_t ctdb_ltdb_update_seqnum(struct ctdb_context *ctdb, uint32_t db_id, uint32_t srcnode);
-int32_t ctdb_ltdb_set_seqnum_frequency(struct ctdb_context *ctdb, uint32_t frequency);
 
 struct ctdb_rec_data *ctdb_marshall_record(TALLOC_CTX *mem_ctx, uint32_t reqid,        
                                           TDB_DATA key, struct ctdb_ltdb_header *, TDB_DATA data);
@@ -1224,6 +1231,7 @@ int ctdb_ctrl_get_public_ipsv4(struct ctdb_context *ctdb,
 
 
 /* from takeover/system.c */
+uint32_t uint16_checksum(uint16_t *data, size_t n);
 int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface);
 bool ctdb_sys_have_ip(ctdb_sock_addr *addr);
 int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, 
@@ -1233,6 +1241,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 int ctdb_set_public_addresses(struct ctdb_context *ctdb, const char *alist);
 int ctdb_set_event_script(struct ctdb_context *ctdb, const char *script);
 int ctdb_set_event_script_dir(struct ctdb_context *ctdb, const char *script_dir);
+int ctdb_set_notification_script(struct ctdb_context *ctdb, const char *script);
 int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap);
 
 int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id, 
@@ -1283,7 +1292,7 @@ void ctdb_start_freeze(struct ctdb_context *ctdb);
 
 bool parse_ip_mask(const char *s, const char *iface, ctdb_sock_addr *addr, unsigned *mask);
 bool parse_ip_port(const char *s, ctdb_sock_addr *addr);
-bool parse_ip(const char *s, const char *iface, ctdb_sock_addr *addr);
+bool parse_ip(const char *s, const char *iface, unsigned port, ctdb_sock_addr *addr);
 bool parse_ipv4(const char *s, unsigned port, struct sockaddr_in *sin);
  
 
@@ -1394,6 +1403,7 @@ int32_t ctdb_control_trans2_error(struct ctdb_context *ctdb,
                                  struct ctdb_req_control *c);
 
 char *ctdb_addr_to_str(ctdb_sock_addr *addr);
+unsigned ctdb_addr_to_port(ctdb_sock_addr *addr);
 void ctdb_canonicalize_ip(const ctdb_sock_addr *ip, ctdb_sock_addr *cip);
 
 int32_t ctdb_control_recd_ping(struct ctdb_context *ctdb);
@@ -1401,4 +1411,19 @@ int32_t ctdb_control_set_recmaster(struct ctdb_context *ctdb, uint32_t opcode, T
 
 extern int script_log_level;
 
+int ctdb_ctrl_event_script_init(struct ctdb_context *ctdb);
+int ctdb_ctrl_event_script_start(struct ctdb_context *ctdb, const char *name);
+int ctdb_ctrl_event_script_stop(struct ctdb_context *ctdb, int32_t res);
+int ctdb_ctrl_event_script_finished(struct ctdb_context *ctdb);
+
+int32_t ctdb_control_event_script_init(struct ctdb_context *ctdb);
+int32_t ctdb_control_event_script_start(struct ctdb_context *ctdb, TDB_DATA indata);
+int32_t ctdb_control_event_script_stop(struct ctdb_context *ctdb, TDB_DATA indata);
+int32_t ctdb_control_event_script_finished(struct ctdb_context *ctdb);
+
+
+int32_t ctdb_control_get_event_script_status(struct ctdb_context *ctdb, TDB_DATA *outdata);
+
+int ctdb_log_event_script_output(struct ctdb_context *ctdb, char *str, uint16_t len);
+
 #endif
index 66ca3301c9d979ea1a7f14bbaf7b31c12bea7260..7422150765be7ba8d4f22fd56b67475e3e6af2db 100644 (file)
@@ -4,7 +4,7 @@ Summary: Clustered TDB
 Vendor: Samba Team
 Packager: Samba Team <samba@samba.org>
 Name: ctdb
-Version: 1.0.73
+Version: 1.0.78
 Release: 1
 Epoch: 0
 License: GNU GPL version 3
@@ -97,6 +97,7 @@ fi
 %defattr(-,root,root)
 
 %config(noreplace) %{_sysconfdir}/sysconfig/ctdb
+%config(noreplace) %{_sysconfdir}/ctdb/notify.sh
 %config(noreplace) %{_sysconfdir}/ctdb/functions
 %attr(755,root,root) %{initdir}/ctdb
 
@@ -104,6 +105,7 @@ fi
 %{_docdir}/ctdb/recovery-process.txt
 %{_sysconfdir}/ctdb/events.d/00.ctdb
 %{_sysconfdir}/ctdb/events.d/10.interface
+%{_sysconfdir}/ctdb/events.d/11.natgw
 %{_sysconfdir}/ctdb/events.d/20.multipathd
 %{_sysconfdir}/ctdb/events.d/40.vsftpd
 %{_sysconfdir}/ctdb/events.d/41.httpd
@@ -128,6 +130,23 @@ fi
 %{_includedir}/ctdb_private.h
 
 %changelog
+* Tue Mar 31 2009 : Version 1.0.78
+ - Add a notify mechanism so we can send snmptraps/email to external management systems when the node becomes unhealthy
+ - include 11.natgw eventscript in thew install so that the NATGW feature works
+* Tue Mar 31 2009 : Version 1.0.77
+ - Update the 99.routing eventscript to also try to add the routes (back) during a releaseip event. Similar to the reasons why we must add addresses back during releaseip in 10.interfaces
+* Wed Mar 24 2009 : Version 1.0.76
+ - Add a debugging command "xpnn" which can print the pnn of the node even when ctdbd is not running.
+ - Redo the NATGW implementation to allow multiple disjoing NATGW groups in the same cluster.
+* Tue Mar 24 2009 : Version 1.0.75
+ - Various updates to LVS
+ - Fix a bug in the killtcp control where we did not set the port correctly
+ - add a new "ctdb scriptstatus" command that shows the status of the eventrscripts.
+* Mon Mar 16 2009 : Version 1.0.74
+ - Fixes to AIX from C Cowan.
+ - Fixes to ctdb_diagnostics so we collect correct GPFS data
+ - Fixes to the net conf list command in ctdb_diagnostics
+ - Check the static-routes file IFF it exists in ctdb_diagnostics
 * Wed Mar 4 2009 : Version 1.0.73
  - Add possibility to disable the check of shares for NFS and Samba
  - From Sumit Bose, fix dependencies so make -j works
index b8b31c9b5126c7d06fa5fdfe184192d67f5cf2af..ac77696a4b9726dab573b993119bc414d725741c 100644 (file)
@@ -418,6 +418,25 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
                CHECK_CONTROL_DATA_SIZE(0);
                return ctdb_control_recd_ping(ctdb);
 
+       case CTDB_CONTROL_EVENT_SCRIPT_INIT:
+               CHECK_CONTROL_DATA_SIZE(0);
+               return ctdb_control_event_script_init(ctdb);
+
+       case CTDB_CONTROL_EVENT_SCRIPT_START:
+               return ctdb_control_event_script_start(ctdb, indata);
+       
+       case CTDB_CONTROL_EVENT_SCRIPT_STOP:
+               CHECK_CONTROL_DATA_SIZE(sizeof(int32_t));
+               return ctdb_control_event_script_stop(ctdb, indata);
+
+       case CTDB_CONTROL_EVENT_SCRIPT_FINISHED:
+               CHECK_CONTROL_DATA_SIZE(0);
+               return ctdb_control_event_script_finished(ctdb);
+
+       case CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS:
+               CHECK_CONTROL_DATA_SIZE(0);
+               return ctdb_control_get_event_script_status(ctdb, outdata);
+
        default:
                DEBUG(DEBUG_CRIT,(__location__ " Unknown CTDB control opcode %u\n", opcode));
                return -1;
index 0aaab236b03aadeddb665a966f8f08fad986c56b..e730d76f55f9a65a5db6bee226dc6c191a8129c2 100644 (file)
@@ -582,7 +582,7 @@ static int ux_socket_bind(struct ctdb_context *ctdb)
        } 
 
 
-       if (listen(ctdb->daemon.sd, 10) != 0) {
+       if (listen(ctdb->daemon.sd, 100) != 0) {
                DEBUG(DEBUG_CRIT,("Unable to listen on ctdb socket '%s'\n", ctdb->daemon.name));
                goto failed;
        }
index 06c7eb8b694f7b6cac128b9912480f6cd0f0df93..45a9f7410ea4c5eb3cb83c3bf52a9a7cc01a0621 100644 (file)
@@ -163,6 +163,8 @@ static void ctdb_log_handler(struct event_context *ev, struct fd_event *fde,
                }
                if (script_log_level <= LogLevel) {
                        do_debug("%*.*s\n", n2, n2, ctdb->log->buf);
+                       /* log it in the eventsystem as well */
+                       ctdb_log_event_script_output(ctdb, ctdb->log->buf, n2);
                }
                memmove(ctdb->log->buf, p+1, sizeof(ctdb->log->buf) - n1);
                ctdb->log->buf_used -= n1;
@@ -174,6 +176,8 @@ static void ctdb_log_handler(struct event_context *ev, struct fd_event *fde,
                if (script_log_level <= LogLevel) {
                        do_debug("%*.*s\n", 
                                (int)ctdb->log->buf_used, (int)ctdb->log->buf_used, ctdb->log->buf);
+                       /* log it in the eventsystem as well */
+                       ctdb_log_event_script_output(ctdb, ctdb->log->buf, ctdb->log->buf_used);
                }
                ctdb->log->buf_used = 0;
        }
index 35212506df817a2c800babc36c534cb295bf5b1b..b330768dcb59df4b73d5ec57ac27841bc29d6ae4 100644 (file)
@@ -455,7 +455,7 @@ static void ctdb_ltdb_seqnum_check(struct event_context *ev, struct timed_event
        /* setup a new timer */
        ctdb_db->te = 
                event_add_timed(ctdb->ev, ctdb_db, 
-                               timeval_current_ofs(ctdb->tunable.seqnum_frequency, 0),
+                               timeval_current_ofs(ctdb->tunable.seqnum_interval/1000, (ctdb->tunable.seqnum_interval%1000)*1000),
                                ctdb_ltdb_seqnum_check, ctdb_db);
 }
 
@@ -474,7 +474,7 @@ int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context *ctdb, uint32_t db_id)
        if (ctdb_db->te == NULL) {
                ctdb_db->te = 
                        event_add_timed(ctdb->ev, ctdb_db, 
-                                       timeval_current_ofs(ctdb->tunable.seqnum_frequency, 0),
+                                       timeval_current_ofs(ctdb->tunable.seqnum_interval/1000, (ctdb->tunable.seqnum_interval%1000)*1000),
                                        ctdb_ltdb_seqnum_check, ctdb_db);
        }
 
index 21f0382d6b5d9f086219e04d7aaf3c31d9129847..46d9c632293fcecdce1116c6393098ff926b8164 100644 (file)
@@ -33,6 +33,74 @@ struct ctdb_monitor_state {
 static void ctdb_check_health(struct event_context *ev, struct timed_event *te, 
                              struct timeval t, void *private_data);
 
+/*
+  setup the notification script
+*/
+int ctdb_set_notification_script(struct ctdb_context *ctdb, const char *script)
+{
+       ctdb->notification_script = talloc_strdup(ctdb, script);
+       CTDB_NO_MEMORY(ctdb, ctdb->notification_script);
+       return 0;
+}
+
+static int ctdb_run_notification_script_child(struct ctdb_context *ctdb, const char *event)
+{
+       struct stat st;
+       int ret;
+       char *cmd;
+
+       if (stat(ctdb->notification_script, &st) != 0) {
+               DEBUG(DEBUG_ERR,("Could not stat notification script %s. Can not send notifications.\n", ctdb->notification_script));
+               return -1;
+       }
+       if (!(st.st_mode & S_IXUSR)) {
+               DEBUG(DEBUG_ERR,("Notification script %s is not executable.\n", ctdb->notification_script));
+               return -1;
+       }
+
+       cmd = talloc_asprintf(ctdb, "%s %s\n", ctdb->notification_script, event);
+       CTDB_NO_MEMORY(ctdb, cmd);
+
+       ret = system(cmd);
+       /* if the system() call was successful, translate ret into the
+          return code from the command
+       */
+       if (ret != -1) {
+               ret = WEXITSTATUS(ret);
+       }
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR,("Notification script \"%s\" failed with error %d\n", cmd, ret));
+       }
+
+       return ret;
+}
+
+static void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event)
+{
+       pid_t child;
+
+       if (ctdb->notification_script == NULL) {
+               return;
+       }
+
+       child = fork();
+       if (child == (pid_t)-1) {
+               DEBUG(DEBUG_ERR,("Failed to fork() a notification child process\n"));
+               return;
+       }
+       if (child == 0) {
+               int ret;
+
+               ret = ctdb_run_notification_script_child(ctdb, event);
+               if (ret != 0) {
+                       DEBUG(DEBUG_ERR,(__location__ " Notification script failed\n"));
+               }
+               _exit(0);
+       }
+
+       return;
+}
+
 /*
   called when a health monitoring event script finishes
  */
@@ -55,10 +123,13 @@ static void ctdb_health_callback(struct ctdb_context *ctdb, int status, void *p)
                        node->flags |= NODE_FLAGS_DISABLED;
                }
 
+               ctdb_run_notification_script(ctdb, "unhealthy");
        } else if (status == 0 && (node->flags & NODE_FLAGS_UNHEALTHY)) {
                DEBUG(DEBUG_NOTICE,("monitor event OK - node re-enabled\n"));
                node->flags &= ~NODE_FLAGS_UNHEALTHY;
                ctdb->monitor->next_interval = 1;
+
+               ctdb_run_notification_script(ctdb, "healthy");
        }
 
        next_interval = ctdb->monitor->next_interval;
index 2d95b184666262cdae85c43b1fc9cf7f241f1539..12b95deb7bf5f48076ba621cad64609a917888c2 100644 (file)
@@ -165,6 +165,7 @@ ctdb_control_getnodemap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA ind
        for (i=0; i<num_nodes; i++) {
                if (parse_ip(ctdb->nodes[i]->address.address,
                             NULL, /* TODO: pass in the correct interface here*/
+                            0,
                             &node_map->nodes[i].addr) == 0)
                {
                        DEBUG(DEBUG_ERR, (__location__ " Failed to parse %s into a sockaddr\n", ctdb->nodes[i]->address.address));
index 540749d12f8317e32e1e81d6e7cfab438c78187b..86f7a464cc09010df56c2f9aca6d4b1db802cdd9 100644 (file)
@@ -2657,12 +2657,14 @@ again:
        /* verify that all other nodes have the same nodemap as we have
        */
        for (j=0; j<nodemap->num; j++) {
-               if (nodemap->nodes[j].flags & NODE_FLAGS_DISCONNECTED) {
+               if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) {
                        continue;
                }
 
                if (remote_nodemaps[j] == NULL) {
                        DEBUG(DEBUG_ERR,(__location__ " Did not get a remote nodemap for node %d, restarting monitoring\n", j));
+                       ctdb_set_culprit(rec, j);
+
                        goto again;
                }
 
@@ -2906,7 +2908,6 @@ static void recd_sig_child_handler(struct event_context *ev,
  */
 int ctdb_start_recoverd(struct ctdb_context *ctdb)
 {
-       int ret;
        int fd[2];
        struct signal_event *se;
 
@@ -2931,35 +2932,16 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb)
 
        close(fd[1]);
 
-       /* shutdown the transport */
-       if (ctdb->methods) {
-               ctdb->methods->shutdown(ctdb);
-       }
-
-       /* get a new event context */
-       talloc_free(ctdb->ev);
-       ctdb->ev = event_context_init(ctdb);
-
-       event_add_fd(ctdb->ev, ctdb, fd[0], EVENT_FD_READ|EVENT_FD_AUTOCLOSE, 
-                    ctdb_recoverd_parent, &fd[0]);     
-
-       close(ctdb->daemon.sd);
-       ctdb->daemon.sd = -1;
-
        srandom(getpid() ^ time(NULL));
 
-       /* the recovery daemon does not need to be realtime */
-       if (ctdb->do_setsched) {
-               ctdb_restore_scheduler(ctdb);
-       }
-
-       /* initialise ctdb */
-       ret = ctdb_socket_connect(ctdb);
-       if (ret != 0) {
-               DEBUG(DEBUG_ALERT, (__location__ " Failed to init ctdb\n"));
+       if (switch_from_server_to_client(ctdb) != 0) {
+               DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch recovery daemon into client mode. shutting down.\n"));
                exit(1);
        }
 
+       event_add_fd(ctdb->ev, ctdb, fd[0], EVENT_FD_READ|EVENT_FD_AUTOCLOSE, 
+                    ctdb_recoverd_parent, &fd[0]);     
+
        /* set up a handler to pick up sigchld */
        se = event_add_signal(ctdb->ev, ctdb,
                                     SIGCHLD, 0,
index f758c2cf182644eb15caf255e91e96e7b89a8815..31ec89f82e4b439b3be2e65500f85acb507a0989 100644 (file)
@@ -25,7 +25,7 @@ static const struct {
        size_t offset;  
 } tunable_map[] = {
        { "MaxRedirectCount",     3,  offsetof(struct ctdb_tunable, max_redirect_count) },
-       { "SeqnumFrequency",      1,  offsetof(struct ctdb_tunable, seqnum_frequency) },
+       { "SeqnumInterval",      1000,  offsetof(struct ctdb_tunable, seqnum_interval) },
        { "ControlTimeout",      60, offsetof(struct ctdb_tunable, control_timeout) },
        { "TraverseTimeout",     20, offsetof(struct ctdb_tunable, traverse_timeout) },
        { "KeepaliveInterval",    5,  offsetof(struct ctdb_tunable, keepalive_interval) },
index 1d3b22aff78f9a71ffab583061213e56a93a3b16..de6c39fbca7331fb3d3ceef30b092f70a94f63ab 100644 (file)
@@ -33,6 +33,7 @@ static struct {
        const char *myaddress;
        const char *public_address_list;
        const char *event_script_dir;
+       const char *notification_script;
        const char *logfile;
        const char *recovery_lock_file;
        const char *db_dir;
@@ -119,6 +120,7 @@ int main(int argc, const char *argv[])
                { "logfile", 0, POPT_ARG_STRING, &options.logfile, 0, "log file location", "filename" },
                { "nlist", 0, POPT_ARG_STRING, &options.nlist, 0, "node list file", "filename" },
                { "node-ip", 0, POPT_ARG_STRING, &options.node_ip, 0, "node ip", "ip-address"},
+               { "notification-script", 0, POPT_ARG_STRING, &options.notification_script, 0, "notification script", "filename" },
                { "listen", 0, POPT_ARG_STRING, &options.myaddress, 0, "address to listen on", "address" },
                { "transport", 0, POPT_ARG_STRING, &options.transport, 0, "protocol transport", NULL },
                { "dbdir", 0, POPT_ARG_STRING, &options.db_dir, 0, "directory for the tdb files", NULL },
@@ -281,6 +283,7 @@ int main(int argc, const char *argv[])
 
                if (parse_ip(options.single_public_ip, 
                                svnn->iface,
+                               0,
                                &svnn->public_address) == 0) {
                        DEBUG(DEBUG_ALERT,("Invalid --single-public-ip argument : %s . This is not a valid ip address. Exiting.\n", options.single_public_ip));
                        exit(10);
@@ -301,6 +304,14 @@ int main(int argc, const char *argv[])
                exit(1);
        }
 
+       if (options.notification_script != NULL) {
+               ret = ctdb_set_notification_script(ctdb, options.notification_script);
+               if (ret == -1) {
+                       DEBUG(DEBUG_ALERT,("Unable to setup notification script\n"));
+                       exit(1);
+               }
+       }
+
        ctdb->do_setsched = !options.no_setsched;
 
        ctdb->do_checkpublicip = !options.no_publicipcheck;
index 6edd1a4dc6ace9fcf34960717247143be359ba7d..a30ac3f961c86fcdfb4c3af1c8039734bf98a316 100644 (file)
@@ -52,6 +52,235 @@ struct ctdb_event_script_state {
        const char *options;
 };
 
+
+struct ctdb_monitor_script_status {
+       struct ctdb_monitor_script_status *next;
+       const char *name;
+       struct timeval start;
+       struct timeval finished;
+       int32_t status;
+       int32_t timedout;
+       char *output;
+};
+
+struct ctdb_monitoring_status {
+       struct timeval start;
+       struct timeval finished;
+       int32_t status;
+       struct ctdb_monitor_script_status *scripts;
+};
+
+
+/* called from ctdb_logging when we have received output on STDERR from
+ * one of the eventscripts
+ */
+int ctdb_log_event_script_output(struct ctdb_context *ctdb, char *str, uint16_t len)
+{
+       struct ctdb_monitoring_status *monitoring_status =
+               talloc_get_type(ctdb->script_monitoring_ctx,
+                       struct ctdb_monitoring_status);
+       struct ctdb_monitor_script_status *script;
+
+       if (monitoring_status == NULL) {
+               return -1;
+       }
+
+       script = monitoring_status->scripts;
+       if (script == NULL) {
+               return -1;
+       }
+
+       if (script->output == NULL) {
+               script->output = talloc_asprintf(script, "%*.*s", len, len, str);
+       } else {
+               script->output = talloc_asprintf_append(script->output, "%*.*s", len, len, str);
+       }
+
+       return 0;
+}
+
+/* called from the event script child process when we are starting a new
+ * monitor event
+ */
+int32_t ctdb_control_event_script_init(struct ctdb_context *ctdb)
+{
+       struct ctdb_monitoring_status *monitoring_status;
+
+       DEBUG(DEBUG_INFO, ("event script init called\n"));
+       if (ctdb->script_monitoring_ctx != NULL) {
+               talloc_free(ctdb->script_monitoring_ctx);
+               ctdb->script_monitoring_ctx = NULL;
+       }
+
+       monitoring_status = talloc_zero(ctdb, struct ctdb_monitoring_status);
+       if (monitoring_status == NULL) {
+               DEBUG(DEBUG_ERR, (__location__ " ERROR: Failed to talloc script_monitoring context\n"));
+               return -1;
+       }
+
+       ctdb->script_monitoring_ctx = monitoring_status;
+       monitoring_status->start = timeval_current();   
+
+       return 0;
+}
+
+
+/* called from the event script child process when we are star running
+ * an eventscript
+ */
+int32_t ctdb_control_event_script_start(struct ctdb_context *ctdb, TDB_DATA indata)
+{
+       const char *name = (const char *)indata.dptr;
+       struct ctdb_monitoring_status *monitoring_status =
+               talloc_get_type(ctdb->script_monitoring_ctx,
+                       struct ctdb_monitoring_status);
+       struct ctdb_monitor_script_status *script;
+
+       DEBUG(DEBUG_INFO, ("event script start called : %s\n", name));
+
+       if (monitoring_status == NULL) {
+               DEBUG(DEBUG_ERR,(__location__ " script_status is NULL when starting to run script %s\n", name));
+               return -1;
+       }
+
+       script = talloc_zero(monitoring_status, struct ctdb_monitor_script_status);
+       if (script == NULL) {
+               DEBUG(DEBUG_ERR,(__location__ " Failed to talloc ctdb_monitor_script_status for script %s\n", name));
+               return -1;
+       }
+
+       script->next  = monitoring_status->scripts;
+       script->name  = talloc_strdup(script, name);
+       script->start = timeval_current();
+       monitoring_status->scripts = script;
+
+       return 0;
+}
+
+/* called from the event script child process when we have finished running
+ * an eventscript
+ */
+int32_t ctdb_control_event_script_stop(struct ctdb_context *ctdb, TDB_DATA indata)
+{
+       int32_t res = *((int32_t *)indata.dptr);
+       struct ctdb_monitoring_status *monitoring_status =
+               talloc_get_type(ctdb->script_monitoring_ctx,
+                       struct ctdb_monitoring_status);
+       struct ctdb_monitor_script_status *script;
+
+       DEBUG(DEBUG_INFO, ("event script stop called : %d\n", (int)res));
+
+       if (monitoring_status == NULL) {
+               DEBUG(DEBUG_ERR,(__location__ " script_status is NULL when script finished.\n"));
+               return -1;
+       }
+
+       script = monitoring_status->scripts;
+       if (script == NULL) {
+               DEBUG(DEBUG_ERR,(__location__ " script is NULL when the script had finished\n"));
+               return -1;
+       }
+
+       script->finished = timeval_current();
+       script->status   = res;
+
+       return 0;
+}
+
+/* called from the event script child process when we have completed a
+ * monitor event
+ */
+int32_t ctdb_control_event_script_finished(struct ctdb_context *ctdb)
+{
+       struct ctdb_monitoring_status *monitoring_status =
+               talloc_get_type(ctdb->script_monitoring_ctx,
+                       struct ctdb_monitoring_status);
+
+       DEBUG(DEBUG_INFO, ("event script finished called\n"));
+
+       if (monitoring_status == NULL) {
+               DEBUG(DEBUG_ERR,(__location__ " script_status is NULL when monitoring event finished\n"));
+               return -1;
+       }
+
+       monitoring_status->finished = timeval_current();        
+       monitoring_status->status   = MONITOR_SCRIPT_OK;
+       if (ctdb->last_monitoring_ctx) {
+               talloc_free(ctdb->last_monitoring_ctx);
+       }
+       ctdb->last_monitoring_ctx = ctdb->script_monitoring_ctx;
+       ctdb->script_monitoring_ctx = NULL;
+
+       return 0;
+}
+
+static struct ctdb_monitoring_wire *marshall_monitoring_scripts(TALLOC_CTX *mem_ctx, struct ctdb_monitoring_wire *monitoring_scripts, struct ctdb_monitor_script_status *script)
+{
+       struct ctdb_monitoring_script_wire script_wire;
+       size_t size;
+
+       if (script == NULL) {
+               return monitoring_scripts;
+       }
+       monitoring_scripts = marshall_monitoring_scripts(mem_ctx, monitoring_scripts, script->next);
+       if (monitoring_scripts == NULL) {
+               return NULL;
+       }
+
+       bzero(&script_wire, sizeof(struct ctdb_monitoring_script_wire));
+       strncpy(script_wire.name, script->name, MAX_SCRIPT_NAME);
+       script_wire.start    = script->start;
+       script_wire.finished = script->finished;
+       script_wire.status   = script->status;
+       script_wire.timedout = script->timedout;
+       if (script->output != NULL) {
+               strncpy(script_wire.output, script->output, MAX_SCRIPT_OUTPUT);
+       }
+
+       size = talloc_get_size(monitoring_scripts);
+       monitoring_scripts = talloc_realloc_size(mem_ctx, monitoring_scripts, size + sizeof(struct ctdb_monitoring_script_wire));
+       if (monitoring_scripts == NULL) {
+               DEBUG(DEBUG_ERR,(__location__ " Failed to talloc_resize monitoring_scripts blob\n"));
+               return NULL;
+       }
+
+       memcpy(&monitoring_scripts->scripts[monitoring_scripts->num_scripts], &script_wire, sizeof(script_wire));
+       monitoring_scripts->num_scripts++;
+       
+       return monitoring_scripts;
+}
+
+int32_t ctdb_control_get_event_script_status(struct ctdb_context *ctdb, TDB_DATA *outdata)
+{
+       struct ctdb_monitoring_status *monitoring_status =
+               talloc_get_type(ctdb->last_monitoring_ctx,
+                       struct ctdb_monitoring_status);
+       struct ctdb_monitoring_wire *monitoring_scripts;
+
+       if (monitoring_status == NULL) {
+               DEBUG(DEBUG_ERR,(__location__ " last_monitor_ctx is NULL when reading status\n"));
+               return -1;
+       }
+
+       monitoring_scripts = talloc_size(outdata, offsetof(struct ctdb_monitoring_wire, scripts));
+       if (monitoring_scripts == NULL) {
+               DEBUG(DEBUG_ERR,(__location__ " failed to talloc monitoring_scripts structure\n"));
+               return -1;
+       }
+       
+       monitoring_scripts->num_scripts = 0;
+       monitoring_scripts = marshall_monitoring_scripts(outdata, monitoring_scripts, monitoring_status->scripts);
+       if (monitoring_scripts == NULL) {
+               DEBUG(DEBUG_ERR,(__location__ " Monitoring scritps is NULL. can not return data to client\n"));
+               return -1;
+       }
+
+       outdata->dsize = talloc_get_size(monitoring_scripts);
+       outdata->dptr  = (uint8_t *)monitoring_scripts;
+
+       return 0;
+}
+
 /*
   run the event script - varargs version
   this function is called and run in the context of a forked child
@@ -68,6 +297,28 @@ static int ctdb_event_script_v(struct ctdb_context *ctdb, const char *options)
        struct dirent *de;
        char *script;
        int count;
+       int is_monitor = 0;
+
+       if (!strcmp(options, "monitor")) {
+               is_monitor = 1;
+       }
+
+       if (is_monitor == 1) {
+               /* This is running in the forked child process. At this stage
+                * we want to switch from being a ctdb daemon into being a
+                * client and connect to the real local daemon.
+                */
+               if (switch_from_server_to_client(ctdb) != 0) {
+                       DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch eventscript child into client mode. shutting down.\n"));
+                       _exit(1);
+               }
+
+               if (ctdb_ctrl_event_script_init(ctdb) != 0) {
+                       DEBUG(DEBUG_ERR,(__location__ " Failed to init event script monitoring\n"));
+                       talloc_free(tmp_ctx);
+                       return -1;
+               }
+       }
 
        if (ctdb->recovery_mode != CTDB_RECOVERY_NORMAL) {
                /* we guarantee that only some specifically allowed event scripts are run
@@ -80,6 +331,7 @@ static int ctdb_event_script_v(struct ctdb_context *ctdb, const char *options)
                if (i == ARRAY_SIZE(allowed_scripts)) {
                        DEBUG(DEBUG_ERR,("Refusing to run event scripts with option '%s' while in recovery\n",
                                 options));
+                       talloc_free(tmp_ctx);
                        return -1;
                }
        }
@@ -175,6 +427,14 @@ static int ctdb_event_script_v(struct ctdb_context *ctdb, const char *options)
                child_state.start = timeval_current();
                child_state.script_running = cmdstr;
 
+               if (is_monitor == 1) {
+                       if (ctdb_ctrl_event_script_start(ctdb, script) != 0) {
+                               DEBUG(DEBUG_ERR,(__location__ " Failed to start event script monitoring\n"));
+                               talloc_free(tmp_ctx);
+                               return -1;
+                       }
+               }
+
                ret = system(cmdstr);
                /* if the system() call was successful, translate ret into the
                   return code from the command
@@ -182,9 +442,25 @@ static int ctdb_event_script_v(struct ctdb_context *ctdb, const char *options)
                if (ret != -1) {
                        ret = WEXITSTATUS(ret);
                }
+               if (is_monitor == 1) {
+                       if (ctdb_ctrl_event_script_stop(ctdb, ret) != 0) {
+                               DEBUG(DEBUG_ERR,(__location__ " Failed to stop event script monitoring\n"));
+                               talloc_free(tmp_ctx);
+                               return -1;
+                       }
+               }
+
                /* return an error if the script failed */
                if (ret != 0) {
                        DEBUG(DEBUG_ERR,("Event script %s failed with error %d\n", cmdstr, ret));
+                       if (is_monitor == 1) {
+                               if (ctdb_ctrl_event_script_finished(ctdb) != 0) {
+                                       DEBUG(DEBUG_ERR,(__location__ " Failed to finish event script monitoring\n"));
+                                       talloc_free(tmp_ctx);
+                                       return -1;
+                               }
+                       }
+
                        talloc_free(tmp_ctx);
                        return ret;
                }
@@ -196,6 +472,14 @@ static int ctdb_event_script_v(struct ctdb_context *ctdb, const char *options)
        child_state.start = timeval_current();
        child_state.script_running = "finished";
        
+       if (is_monitor == 1) {
+               if (ctdb_ctrl_event_script_finished(ctdb) != 0) {
+                       DEBUG(DEBUG_ERR,(__location__ " Failed to finish event script monitoring\n"));
+                       talloc_free(tmp_ctx);
+                       return -1;
+               }
+       }
+
        talloc_free(tmp_ctx);
        return 0;
 }
@@ -249,6 +533,9 @@ static void ctdb_event_script_timeout(struct event_context *ev, struct timed_eve
        void *private_data = state->private_data;
        struct ctdb_context *ctdb = state->ctdb;
        char *options;
+       struct ctdb_monitoring_status *monitoring_status =
+               talloc_get_type(ctdb->script_monitoring_ctx,
+                       struct ctdb_monitoring_status);
 
        DEBUG(DEBUG_ERR,("Event script timed out : %s count : %u\n", state->options, ctdb->event_script_timeouts));
 
@@ -282,6 +569,21 @@ static void ctdb_event_script_timeout(struct event_context *ev, struct timed_eve
                callback(ctdb, -1, private_data);
        }
 
+       if (monitoring_status != NULL) {
+               struct ctdb_monitor_script_status *script;
+
+               script = monitoring_status->scripts;
+               if (script != NULL) {
+                       script->timedout = 1;
+               }
+               monitoring_status->status = MONITOR_SCRIPT_TIMEOUT;
+               if (ctdb->last_monitoring_ctx) {
+                       talloc_free(ctdb->last_monitoring_ctx);
+                       ctdb->last_monitoring_ctx = ctdb->script_monitoring_ctx;
+                       ctdb->script_monitoring_ctx = NULL;
+               }
+       }
+
        talloc_free(options);
 }
 
@@ -337,10 +639,8 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
                signed char rt;
 
                close(state->fd[0]);
-               if (ctdb->do_setsched) {
-                       ctdb_restore_scheduler(ctdb);
-               }
                set_close_on_exec(state->fd[1]);
+
                rt = ctdb_event_script_v(ctdb, state->options);
                while ((ret = write(state->fd[1], &rt, sizeof(rt))) != sizeof(rt)) {
                        sleep(1);
index 8efb5974438206748ea9f78e20470945d09ac23e..9d28d48a1f0d5a2c155bfd9b964b2d94965746c2 100644 (file)
@@ -109,7 +109,7 @@ static void ctdb_node_connect_write(struct event_context *ev, struct fd_event *f
 static int ctdb_tcp_get_address(struct ctdb_context *ctdb,
                                const char *address, ctdb_sock_addr *addr)
 {
-       if (parse_ip(address, NULL, addr) == 0) {
+       if (parse_ip(address, NULL, 0, addr) == 0) {
                DEBUG(DEBUG_CRIT, (__location__ " Unparsable address : %s.\n", address));
                return -1;
        }
@@ -129,6 +129,7 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te,
        struct ctdb_context *ctdb = node->ctdb;
         ctdb_sock_addr sock_in;
        int sockin_size;
+       int sockout_size;
         ctdb_sock_addr sock_out;
 
        ctdb_tcp_stop_connection(node);
@@ -167,12 +168,20 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te,
        if (ctdb_tcp_get_address(ctdb, ctdb->address.address, &sock_in) != 0) {
                return;
        }
+
+       /* AIX libs check to see if the socket address and length
+          arguments are consistent with each other on calls like
+          connect().   Can not get by with just sizeof(sock_in),
+          need sizeof(sock_in.ip).
+       */
        switch (sock_in.sa.sa_family) {
        case AF_INET:
                sockin_size = sizeof(sock_in.ip);
+               sockout_size = sizeof(sock_out.ip);
                break;
        case AF_INET6:
                sockin_size = sizeof(sock_in.ip6);
+               sockout_size = sizeof(sock_out.ip6);
                break;
        default:
                DEBUG(DEBUG_ERR, (__location__ " unknown family %u\n",
@@ -181,10 +190,11 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te,
        }
 #ifdef HAVE_SOCK_SIN_LEN
        sock_in.ip.sin_len = sockin_size;
+       sock_out.ip.sin_len = sockout_size;
 #endif
        bind(tnode->fd, (struct sockaddr *)&sock_in, sockin_size);
 
-       if (connect(tnode->fd, (struct sockaddr *)&sock_out, sizeof(sock_out)) != 0 &&
+       if (connect(tnode->fd, (struct sockaddr *)&sock_out, sockout_size) != 0 &&
            errno != EINPROGRESS) {
                ctdb_tcp_stop_connection(node);
                tnode->connect_te = event_add_timed(ctdb->ev, tnode, 
index 737bd8e4a54c37e9555483c9767d5a737c30c626..c0606f0ec5464f388de9b3f8b57d3da8cdbfc7cd 100644 (file)
@@ -27,7 +27,7 @@
 
 static int tnode_destructor(struct ctdb_tcp_node *tnode)
 {
-       struct ctdb_node *node = talloc_find_parent_bytype(tnode, struct ctdb_node);
+  //   struct ctdb_node *node = talloc_find_parent_bytype(tnode, struct ctdb_node);
 
        if (tnode->fd != -1) {
                close(tnode->fd);
index b2014f0eb6917ce9caee00f9829918bd7b5cc358..a4120e87f1c3c76de99f6c520656a88958ea0dae 100644 (file)
@@ -369,6 +369,80 @@ static int control_pnn(struct ctdb_context *ctdb, int argc, const char **argv)
        return 0;
 }
 
+
+struct pnn_node {
+       struct pnn_node *next;
+       const char *addr;
+       int pnn;
+};
+
+/*
+  show the PNN of the current node
+  discover the pnn by loading the nodes file and try to bind to all
+  addresses one at a time until the ip address is found.
+ */
+static int control_xpnn(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+       TALLOC_CTX *mem_ctx = talloc_new(NULL);
+       const char *nodes_list;
+       int nlines;
+       char **lines;
+       struct pnn_node *pnn_nodes = NULL;
+       struct pnn_node *pnn_node;
+       int i, pnn;
+
+       /* read the nodes file */
+       nodes_list = getenv("CTDB_NODES");
+       if (nodes_list == NULL) {
+               nodes_list = "/etc/ctdb/nodes";
+       }
+       lines = file_lines_load(nodes_list, &nlines, mem_ctx);
+       if (lines == NULL) {
+               ctdb_set_error(ctdb, "Failed to load nodes list '%s'\n", nodes_list);
+               return -1;
+       }
+       while (nlines > 0 && strcmp(lines[nlines-1], "") == 0) {
+               nlines--;
+       }
+       for (i=0, pnn=0; i<nlines; i++) {
+               char *node;
+
+               node = lines[i];
+               /* strip leading spaces */
+               while((*node == ' ') || (*node == '\t')) {
+                       node++;
+               }
+               if (*node == '#') {
+                       continue;
+               }
+               if (strcmp(node, "") == 0) {
+                       continue;
+               }
+               pnn_node = talloc(mem_ctx, struct pnn_node);
+               pnn_node->pnn = pnn++;
+               pnn_node->addr = talloc_strdup(pnn_node, node);
+               pnn_node->next = pnn_nodes;
+               pnn_nodes = pnn_node;
+       }
+
+       for(pnn_node=pnn_nodes;pnn_node;pnn_node=pnn_node->next) {
+               ctdb_sock_addr addr;
+
+               if (parse_ip(pnn_node->addr, NULL, 63999, &addr) == 0) {
+                       DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s' in nodes file %s\n", pnn_node->addr, nodes_list));
+                       return -1;
+               }
+
+               if (ctdb_sys_have_ip(&addr)) {
+                       printf("PNN:%d\n", pnn_node->pnn);
+                       return 0;
+               }
+       }
+
+       printf("Failed to detect which PNN this node is\n");
+       return -1;
+}
+
 /*
   display remote ctdb status
  */
@@ -471,6 +545,149 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv
        return 0;
 }
 
+
+struct natgw_node {
+       struct natgw_node *next;
+       const char *addr;
+};
+
+/*
+  display the list of nodes belonging to this natgw configuration
+ */
+static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+       int i, ret;
+       const char *natgw_list;
+       int nlines;
+       char **lines;
+       struct natgw_node *natgw_nodes = NULL;
+       struct natgw_node *natgw_node;
+       struct ctdb_node_map *nodemap=NULL;
+
+
+       /* read the natgw nodes file into a linked list */
+       natgw_list = getenv("NATGW_NODES");
+       if (natgw_list == NULL) {
+               natgw_list = "/etc/ctdb/natgw_nodes";
+       }
+       lines = file_lines_load(natgw_list, &nlines, ctdb);
+       if (lines == NULL) {
+               ctdb_set_error(ctdb, "Failed to load natgw node list '%s'\n", natgw_list);
+               return -1;
+       }
+       while (nlines > 0 && strcmp(lines[nlines-1], "") == 0) {
+               nlines--;
+       }
+       for (i=0;i<nlines;i++) {
+               char *node;
+
+               node = lines[i];
+               /* strip leading spaces */
+               while((*node == ' ') || (*node == '\t')) {
+                       node++;
+               }
+               if (*node == '#') {
+                       continue;
+               }
+               if (strcmp(node, "") == 0) {
+                       continue;
+               }
+               natgw_node = talloc(ctdb, struct natgw_node);
+               natgw_node->addr = talloc_strdup(natgw_node, node);
+               natgw_node->next = natgw_nodes;
+               natgw_nodes = natgw_node;
+       }
+
+       ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE, ctdb, &nodemap);
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR, ("Unable to get nodemap from local node.\n"));
+               return ret;
+       }
+
+       i=0;
+       while(i<nodemap->num) {
+               for(natgw_node=natgw_nodes;natgw_node;natgw_node=natgw_node->next) {
+                       if (!strcmp(natgw_node->addr, ctdb_addr_to_str(&nodemap->nodes[i].addr))) {
+                               break;
+                       }
+               }
+
+               /* this node was not in the natgw so we just remove it from
+                * the list
+                */
+               if ((natgw_node == NULL) 
+               ||  (nodemap->nodes[i].flags & NODE_FLAGS_DISCONNECTED) ) {
+                       int j;
+
+                       for (j=i+1; j<nodemap->num; j++) {
+                               nodemap->nodes[j-1] = nodemap->nodes[j];
+                       }
+                       nodemap->num--;
+                       continue;
+               }
+
+               i++;
+       }               
+
+       /* print the natgw master */
+       for(i=0;i<nodemap->num;i++){
+               if (!(nodemap->nodes[i].flags & NODE_FLAGS_DISCONNECTED)) {
+                       printf("%d\n", nodemap->nodes[i].pnn);
+                       break;
+               }
+       }
+
+       /* print the pruned list of nodes belonging to this natgw list */
+       for(i=0;i<nodemap->num;i++){
+               printf(":%d:%s:%d:%d:%d:%d:\n", nodemap->nodes[i].pnn,
+                       ctdb_addr_to_str(&nodemap->nodes[i].addr),
+                      !!(nodemap->nodes[i].flags&NODE_FLAGS_DISCONNECTED),
+                      !!(nodemap->nodes[i].flags&NODE_FLAGS_BANNED),
+                      !!(nodemap->nodes[i].flags&NODE_FLAGS_PERMANENTLY_DISABLED),
+                      !!(nodemap->nodes[i].flags&NODE_FLAGS_UNHEALTHY));
+       }
+
+       return 0;
+}
+
+
+/*
+  display the status of the monitoring scripts
+ */
+static int control_scriptstatus(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+       int i, ret;
+       struct ctdb_monitoring_wire *script_status;
+
+       ret = ctdb_ctrl_getscriptstatus(ctdb, TIMELIMIT(), options.pnn, ctdb, &script_status);
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR, ("Unable to get script status from node %u\n", options.pnn));
+               return ret;
+       }
+
+       printf("%d scripts were executed last monitoring cycle\n", script_status->num_scripts);
+       for (i=0; i<script_status->num_scripts; i++) {
+               printf("%-20s Status:%s    ",
+                       script_status->scripts[i].name,
+                       script_status->scripts[i].timedout?"TIMEDOUT":script_status->scripts[i].status==0?"OK":"ERROR");
+               if (script_status->scripts[i].timedout == 0) {
+                       printf("Duration:%.3lf ",
+                       timeval_delta(&script_status->scripts[i].finished,
+                             &script_status->scripts[i].start));
+               }
+               printf("%s",
+                       ctime(&script_status->scripts[i].start.tv_sec));
+               if ((script_status->scripts[i].timedout != 0)
+               ||  (script_status->scripts[i].status != 0) ) {
+                       printf("   OUTPUT:%s\n",
+                               script_status->scripts[i].output);
+               }
+       }
+
+       return 0;
+}
+       
+
 /*
   display the pnn of the recovery master
  */
@@ -502,7 +719,7 @@ static int control_get_tickles(struct ctdb_context *ctdb, int argc, const char *
                usage();
        }
 
-       if (parse_ip(argv[0], NULL, &addr) == 0) {
+       if (parse_ip(argv[0], NULL, 0, &addr) == 0) {
                DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[0]));
                return -1;
        }
@@ -574,7 +791,7 @@ static int control_moveip(struct ctdb_context *ctdb, int argc, const char **argv
                usage();
        }
 
-       if (parse_ip(argv[0], NULL,  &addr) == 0) {
+       if (parse_ip(argv[0], NULL, 0, &addr) == 0) {
                DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[0]));
                return -1;
        }
@@ -950,7 +1167,7 @@ static int control_delip(struct ctdb_context *ctdb, int argc, const char **argv)
                usage();
        }
 
-       if (parse_ip(argv[0], NULL, &addr) == 0) {
+       if (parse_ip(argv[0], NULL, 0, &addr) == 0) {
                DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[0]));
                return -1;
        }
@@ -1048,7 +1265,7 @@ static int control_gratious_arp(struct ctdb_context *ctdb, int argc, const char
                usage();
        }
 
-       if (!parse_ip(argv[0], NULL, &addr)) {
+       if (!parse_ip(argv[0], NULL, 0, &addr)) {
                DEBUG(DEBUG_ERR, ("Bad IP '%s'\n", argv[0]));
                return -1;
        }
@@ -2586,67 +2803,71 @@ static const struct {
        const char *name;
        int (*fn)(struct ctdb_context *, int, const char **);
        bool auto_all;
+       bool without_daemon; /* can be run without daemon running ? */
        const char *msg;
        const char *args;
 } ctdb_commands[] = {
 #ifdef CTDB_VERS
-       { "version",         control_version,           true,  "show version of ctdb" },
+       { "version",         control_version,           true,   false,  "show version of ctdb" },
 #endif
-       { "status",          control_status,            true,  "show node status" },
-       { "uptime",          control_uptime,            true,  "show node uptime" },
-       { "ping",            control_ping,              true,  "ping all nodes" },
-       { "getvar",          control_getvar,            true,  "get a tunable variable",               "<name>"},
-       { "setvar",          control_setvar,            true,  "set a tunable variable",               "<name> <value>"},
-       { "listvars",        control_listvars,          true,  "list tunable variables"},
-       { "statistics",      control_statistics,        false, "show statistics" },
-       { "statisticsreset", control_statistics_reset,  true,  "reset statistics"},
-       { "ip",              control_ip,                false,  "show which public ip's that ctdb manages" },
-       { "process-exists",  control_process_exists,    true,  "check if a process exists on a node",  "<pid>"},
-       { "getdbmap",        control_getdbmap,          true,  "show the database map" },
-       { "catdb",           control_catdb,             true,  "dump a database" ,                     "<dbname>"},
-       { "getmonmode",      control_getmonmode,        true,  "show monitoring mode" },
-       { "getcapabilities", control_getcapabilities,   true,  "show node capabilities" },
-       { "pnn",             control_pnn,               true,  "show the pnn of the currnet node" },
-       { "lvs",             control_lvs,               true,  "show lvs configuration" },
-       { "lvsmaster",       control_lvsmaster,         true,  "show which node is the lvs master" },
-       { "disablemonitor",      control_disable_monmode,        true,  "set monitoring mode to DISABLE" },
-       { "enablemonitor",      control_enable_monmode,        true,  "set monitoring mode to ACTIVE" },
-       { "setdebug",        control_setdebug,          true,  "set debug level",                      "<EMERG|ALERT|CRIT|ERR|WARNING|NOTICE|INFO|DEBUG>" },
-       { "getdebug",        control_getdebug,          true,  "get debug level" },
-       { "attach",          control_attach,            true,  "attach to a database",                 "<dbname>" },
-       { "dumpmemory",      control_dumpmemory,        true,  "dump memory map to stdout" },
-       { "rddumpmemory",    control_rddumpmemory,      true,  "dump memory map from the recovery daemon to stdout" },
-       { "getpid",          control_getpid,            true,  "get ctdbd process ID" },
-       { "disable",         control_disable,           true,  "disable a nodes public IP" },
-       { "enable",          control_enable,            true,  "enable a nodes public IP" },
-       { "ban",             control_ban,               true,  "ban a node from the cluster",          "<bantime|0>"},
-       { "unban",           control_unban,             true,  "unban a node from the cluster" },
-       { "shutdown",        control_shutdown,          true,  "shutdown ctdbd" },
-       { "recover",         control_recover,           true,  "force recovery" },
-       { "freeze",          control_freeze,            true,  "freeze all databases" },
-       { "thaw",            control_thaw,              true,  "thaw all databases" },
-       { "isnotrecmaster",  control_isnotrecmaster,    false,  "check if the local node is recmaster or not" },
-       { "killtcp",         kill_tcp,                  false, "kill a tcp connection.", "<srcip:port> <dstip:port>" },
-       { "gratiousarp",     control_gratious_arp,      false, "send a gratious arp", "<ip> <interface>" },
-       { "tickle",          tickle_tcp,                false, "send a tcp tickle ack", "<srcip:port> <dstip:port>" },
-       { "gettickles",      control_get_tickles,       false, "get the list of tickles registered for this ip", "<ip>" },
-
-       { "regsrvid",        regsrvid,                  false, "register a server id", "<pnn> <type> <id>" },
-       { "unregsrvid",      unregsrvid,                false, "unregister a server id", "<pnn> <type> <id>" },
-       { "chksrvid",        chksrvid,                  false, "check if a server id exists", "<pnn> <type> <id>" },
-       { "getsrvids",       getsrvids,                 false, "get a list of all server ids"},
-       { "vacuum",          ctdb_vacuum,               false, "vacuum the databases of empty records", "[max_records]"},
-       { "repack",          ctdb_repack,               false, "repack all databases", "[max_freelist]"},
-       { "listnodes",       control_listnodes,         false, "list all nodes in the cluster"},
-       { "reloadnodes",     control_reload_nodes_file,         false, "reload the nodes file and restart the transport on all nodes"},
-       { "moveip",          control_moveip,            false, "move/failover an ip address to another node", "<ip> <node>"},
-       { "addip",           control_addip,             true, "add a ip address to a node", "<ip/mask> <iface>"},
-       { "delip",           control_delip,             false, "delete an ip address from a node", "<ip>"},
-       { "eventscript",     control_eventscript,       true, "run the eventscript with the given parameters on a node", "<arguments>"},
-       { "backupdb",        control_backupdb,          false, "backup the database into a file.", "<database> <file>"},
-       { "restoredb",        control_restoredb,          false, "restore the database from a file.", "<file>"},
-       { "recmaster",        control_recmaster,          false, "show the pnn for the recovery master."},
-       { "setflags",        control_setflags,            false, "set flags for a node in the nodemap.", "<node> <flags>"},
+       { "status",          control_status,            true,   false,  "show node status" },
+       { "uptime",          control_uptime,            true,   false,  "show node uptime" },
+       { "ping",            control_ping,              true,   false,  "ping all nodes" },
+       { "getvar",          control_getvar,            true,   false,  "get a tunable variable",               "<name>"},
+       { "setvar",          control_setvar,            true,   false,  "set a tunable variable",               "<name> <value>"},
+       { "listvars",        control_listvars,          true,   false,  "list tunable variables"},
+       { "statistics",      control_statistics,        false,  false, "show statistics" },
+       { "statisticsreset", control_statistics_reset,  true,   false,  "reset statistics"},
+       { "ip",              control_ip,                false,  false,  "show which public ip's that ctdb manages" },
+       { "process-exists",  control_process_exists,    true,   false,  "check if a process exists on a node",  "<pid>"},
+       { "getdbmap",        control_getdbmap,          true,   false,  "show the database map" },
+       { "catdb",           control_catdb,             true,   false,  "dump a database" ,                     "<dbname>"},
+       { "getmonmode",      control_getmonmode,        true,   false,  "show monitoring mode" },
+       { "getcapabilities", control_getcapabilities,   true,   false,  "show node capabilities" },
+       { "pnn",             control_pnn,               true,   false,  "show the pnn of the currnet node" },
+       { "lvs",             control_lvs,               true,   false,  "show lvs configuration" },
+       { "lvsmaster",       control_lvsmaster,         true,   false,  "show which node is the lvs master" },
+       { "disablemonitor",      control_disable_monmode,        true,  false,  "set monitoring mode to DISABLE" },
+       { "enablemonitor",      control_enable_monmode,        true,    false,  "set monitoring mode to ACTIVE" },
+       { "setdebug",        control_setdebug,          true,   false,  "set debug level",                      "<EMERG|ALERT|CRIT|ERR|WARNING|NOTICE|INFO|DEBUG>" },
+       { "getdebug",        control_getdebug,          true,   false,  "get debug level" },
+       { "attach",          control_attach,            true,   false,  "attach to a database",                 "<dbname>" },
+       { "dumpmemory",      control_dumpmemory,        true,   false,  "dump memory map to stdout" },
+       { "rddumpmemory",    control_rddumpmemory,      true,   false,  "dump memory map from the recovery daemon to stdout" },
+       { "getpid",          control_getpid,            true,   false,  "get ctdbd process ID" },
+       { "disable",         control_disable,           true,   false,  "disable a nodes public IP" },
+       { "enable",          control_enable,            true,   false,  "enable a nodes public IP" },
+       { "ban",             control_ban,               true,   false,  "ban a node from the cluster",          "<bantime|0>"},
+       { "unban",           control_unban,             true,   false,  "unban a node from the cluster" },
+       { "shutdown",        control_shutdown,          true,   false,  "shutdown ctdbd" },
+       { "recover",         control_recover,           true,   false,  "force recovery" },
+       { "freeze",          control_freeze,            true,   false,  "freeze all databases" },
+       { "thaw",            control_thaw,              true,   false,  "thaw all databases" },
+       { "isnotrecmaster",  control_isnotrecmaster,    false,  false,  "check if the local node is recmaster or not" },
+       { "killtcp",         kill_tcp,                  false,  false, "kill a tcp connection.", "<srcip:port> <dstip:port>" },
+       { "gratiousarp",     control_gratious_arp,      false,  false, "send a gratious arp", "<ip> <interface>" },
+       { "tickle",          tickle_tcp,                false,  false, "send a tcp tickle ack", "<srcip:port> <dstip:port>" },
+       { "gettickles",      control_get_tickles,       false,  false, "get the list of tickles registered for this ip", "<ip>" },
+
+       { "regsrvid",        regsrvid,                  false,  false, "register a server id", "<pnn> <type> <id>" },
+       { "unregsrvid",      unregsrvid,                false,  false, "unregister a server id", "<pnn> <type> <id>" },
+       { "chksrvid",        chksrvid,                  false,  false, "check if a server id exists", "<pnn> <type> <id>" },
+       { "getsrvids",       getsrvids,                 false,  false, "get a list of all server ids"},
+       { "vacuum",          ctdb_vacuum,               false,  false, "vacuum the databases of empty records", "[max_records]"},
+       { "repack",          ctdb_repack,               false,  false, "repack all databases", "[max_freelist]"},
+       { "listnodes",       control_listnodes,         false,  false, "list all nodes in the cluster"},
+       { "reloadnodes",     control_reload_nodes_file,         false,  false, "reload the nodes file and restart the transport on all nodes"},
+       { "moveip",          control_moveip,            false,  false, "move/failover an ip address to another node", "<ip> <node>"},
+       { "addip",           control_addip,             true,   false, "add a ip address to a node", "<ip/mask> <iface>"},
+       { "delip",           control_delip,             false,  false, "delete an ip address from a node", "<ip>"},
+       { "eventscript",     control_eventscript,       true,   false, "run the eventscript with the given parameters on a node", "<arguments>"},
+       { "backupdb",        control_backupdb,          false,  false, "backup the database into a file.", "<database> <file>"},
+       { "restoredb",        control_restoredb,          false,        false, "restore the database from a file.", "<file>"},
+       { "recmaster",        control_recmaster,          false,        false, "show the pnn for the recovery master."},
+       { "setflags",        control_setflags,            false,        false, "set flags for a node in the nodemap.", "<node> <flags>"},
+       { "scriptstatus",        control_scriptstatus,    false,        false, "show the status of the monitoring scripts"},
+       { "natgwlist",        control_natgwlist,    false,      false, "show the nodes belonging to this natgw configuration"},
+       { "xpnn",             control_xpnn,               true, true,  "find the pnn of the local node without talking to the daemon (unreliable)" },
 };
 
 /*
@@ -2756,27 +2977,29 @@ int main(int argc, const char *argv[])
 
        ev = event_context_init(NULL);
 
-       /* initialise ctdb */
-       ctdb = ctdb_cmdline_client(ev);
-       if (ctdb == NULL) {
-               DEBUG(DEBUG_ERR, ("Failed to init ctdb\n"));
-               exit(1);
-       }
-
-       /* verify the node exists */
-       verify_node(ctdb);
-
        for (i=0;i<ARRAY_SIZE(ctdb_commands);i++) {
                if (strcmp(control, ctdb_commands[i].name) == 0) {
                        int j;
 
-                       if (options.pnn == CTDB_CURRENT_NODE) {
-                               int pnn;
-                               pnn = ctdb_ctrl_getpnn(ctdb, TIMELIMIT(), options.pnn);         
-                               if (pnn == -1) {
-                                       return -1;
+                       if (ctdb_commands[i].without_daemon == false) {
+                               /* initialise ctdb */
+                               ctdb = ctdb_cmdline_client(ev);
+                               if (ctdb == NULL) {
+                                       DEBUG(DEBUG_ERR, ("Failed to init ctdb\n"));
+                                       exit(1);
+                               }
+
+                               /* verify the node exists */
+                               verify_node(ctdb);
+
+                               if (options.pnn == CTDB_CURRENT_NODE) {
+                                       int pnn;
+                                       pnn = ctdb_ctrl_getpnn(ctdb, TIMELIMIT(), options.pnn);         
+                                       if (pnn == -1) {
+                                               return -1;
+                                       }
+                                       options.pnn = pnn;
                                }
-                               options.pnn = pnn;
                        }
 
                        if (ctdb_commands[i].auto_all && 
index 8304a68f5f2620f7d82750711d120b6bb97c7a36..a9531d646c7b4706232a1e23421fc6d0824edc03 100755 (executable)
@@ -4,7 +4,13 @@
 
 PATH="$PATH:/sbin:/usr/sbin:/usr/lpp/mmfs/bin"
 
-CONFIG_FILES="/etc/krb5.conf /etc/hosts /etc/ctdb/nodes /etc/sysconfig/ctdb /etc/ctdb/public_addresses /etc/resolv.conf /etc/nsswitch.conf /etc/sysctl.conf /etc/samba/smb.conf /etc/fstab /etc/multipath.conf /etc/pam.d/system-auth /etc/sysconfig/nfs /etc/exports /etc/vsftpd/vsftpd.conf"
+# list of config files that must exist and that we check are the same 
+# on all nodes
+CONFIG_FILES_MUST="/etc/krb5.conf /etc/hosts /etc/ctdb/nodes /etc/sysconfig/ctdb /etc/resolv.conf /etc/nsswitch.conf /etc/sysctl.conf /etc/samba/smb.conf /etc/fstab /etc/multipath.conf /etc/pam.d/system-auth /etc/sysconfig/nfs /etc/exports /etc/vsftpd/vsftpd.conf"
+
+# list of config files that may exist and should be checked that they
+# are the same on all nodes
+CONFIG_FILES_MAY="/etc/ctdb/public_addresses /etc/ctdb/static-routes"
 
 2>&1
 
@@ -54,9 +60,27 @@ cat <<EOF
 Comping critical config files on all nodes
 EOF
 
-for f in $CONFIG_FILES; do
+for f in $CONFIG_FILES_MUST; do
+ [ -r "$f" ] || {
+    error "$f is missing on this node"
+    continue;
+ }
+ show_file $f
+ for i in `seq 0 $MAX_NODE`; do
+     echo "Testing for same config file $f on node $i"
+     tmpf=/tmp/`basename $f`.node$i
+     onnode $i cat $f > $tmpf 2>&1
+     cmp $f $tmpf 2>&1 || {
+        error "File $f is different on node $i"
+        diff -u $f $tmpf
+     }
+     rm -f $tmpf
+ done
+done
+
+for f in $CONFIG_FILES_MAY; do
  [ -r "$f" ] || {
-    error "$f is missing"
+    echo "Optional file $f is not present on local node"
     continue;
  }
  show_file $f
@@ -182,11 +206,11 @@ EOF
  show_all "/usr/lpp/mmfs/bin/mmlsmgr"
  devlist=`mmlsfs all|grep ^File.system.attributes | cut -d/ -f3 | cut -d: -f1`
  for d in $devlist; do
-     show_all mmdf $d
-     show_all mmlsdisk $d
-     show_all mmlsfileset $d
-     show_all mmlspolicy $d
-     show_all mmlssnapshot $d
+     show_all "mmdf $d"
+     show_all "mmlsdisk $d"
+     show_all "mmlsfileset $d"
+     show_all "mmlspolicy $d"
+     show_all "mmlssnapshot $d"
  done
  fslist=`mount|grep type.gpfs|awk '{print $1}'`
  for fs in $fslist; do
@@ -202,6 +226,7 @@ Showing Samba status
 EOF
 show_all "smbstatus -n -B"
 show_all "net ads testjoin"
+show_all "net conf list"
 show_all "lsof -n | grep smbd"
 show_all "lsof -n | grep ctdbd"
 show_all "netstat -tan"
@@ -211,7 +236,7 @@ show_all "smbclient -U% -L 127.0.0.1"
 WORKGROUP=`testparm -s --parameter-name=WORKGROUP 2> /dev/null`
 show_all id "$WORKGROUP/Administrator"
 show_all "wbinfo -p"
-show_all "wbinfo --sequence"
+show_all "wbinfo --online-status"
 show_all "smbd -b"
 
 date
index 5b6cd42e84eda337978db68e34777c05f4c40437..f25b310d2d229108e66d2e442d9d0db0b880e1ff 100644 (file)
@@ -129,7 +129,8 @@ projects that want to make their services cluster aware using CTDB.
 <h2>Developers</h2>
 <ul>
 <li><a href="http://samba.org/~tridge/">Andrew Tridgell</a><br>
-<li><a href="http://samba.org/~sahlberg/"Ronnie Sahlberg</a><br>
+<li><a href="http://samba.org/~sahlberg/">Ronnie Sahlberg</a><br>
+<li><a href="http://samba.org/~obnox/">Michael Adam</a><br>
 <li>Peter Somogyi<br>
 <li><a href="http://sernet.de/Samba/">Volker Lendecke</a><br>
 </ul>