Add rsyslog configuration that uses high precision time format
authorMartin Schwenke <martin@meltin.net>
Thu, 20 Jun 2013 02:27:07 +0000 (12:27 +1000)
committerMartin Schwenke <martin@meltin.net>
Thu, 20 Jun 2013 02:27:07 +0000 (12:27 +1000)
This allows accurate merging of logs from multiple cluster nodes for
easier CTDB debugging.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>

base/all/etc/rsyslog.d/autocluster.conf [new file with mode: 0644]
examples/create_cluster.sh

diff --git a/base/all/etc/rsyslog.d/autocluster.conf b/base/all/etc/rsyslog.d/autocluster.conf
new file mode 100644 (file)
index 0000000..2e55279
--- /dev/null
@@ -0,0 +1,3 @@
+# Select a high precision time format.  This allows accurate merging
+# of logs from multiple cluster nodes for easier CTDB debugging.
+$ActionFileDefaultTemplate   RSYSLOG_FileFormat
index 4afd277b7121b9de005ea0d42db25510c90fd327..c030bf7758400e7b877b95debd2e8b5eef9fbcaf 100755 (executable)
@@ -6,12 +6,40 @@
 # Exit on 1st error.
 set -e
 
+usage ()
+{
+    cat <<EOF
+usage: ./create_cluster.sh <cluster> [ <type> [ <args> ] ]
+          <cluster> - Name of cluster
+          <type> - Type of cluster
+              samba: samba cluster with gpfs (default)
+              build: development node
+                 ad: active directory node
+          <args> - Optional arguments to autocluster"
+
+EOF
+    exit 1
+}
+
 CLUSTER="$1"
+[ -n "$CLUSTER" ] || usage
+shift
+
+TYPE="$1"
+if [ -n "$TYPE" ] ; then
+    case "$TYPE" in
+       build|ad|samba) : ;;
+       *) usage ;;
+    esac
+    shift
+else
+    TYPE="samba"
+fi
 
-if [ -z "$CLUSTER" ] ; then
-    echo "usage: ./create_cluster.sh <cluster>"
+die () {
+    echo "$@"
     exit 1
-fi
+}
 
 update_hosts_file ()
 {
@@ -22,8 +50,8 @@ update_hosts_file ()
     t="/etc/hosts.${cluster}"
     grep -E "$pat" /etc/hosts >"$t"
     if diff -B "$t" "tmp/hosts.${cluster}" >/dev/null ; then
-       rm "$t"
-       return
+rm "$t"
+return
     fi
 
     old=/etc/hosts.old.autocluster
@@ -38,16 +66,22 @@ update_hosts_file ()
     diff -u "$old" /etc/hosts || true
 }
 
+[ -f "${CLUSTER}.autocluster" ] || die "Missing cluster configuration file ${CLUSTER}.autocluster"
 
 vircmd destroy "$CLUSTER" || true
-autocluster -c "${CLUSTER}.autocluster" create cluster "$CLUSTER"
+autocluster -c "${CLUSTER}.autocluster" "$@" create cluster "$CLUSTER"
 update_hosts_file "$CLUSTER"
 vircmd start "$CLUSTER"
 
-n1="${CLUSTER}n1"
+nodes=$(vircmd dominfo "$CLUSTER" 2>/dev/null | sed -n -e 's/Name: *//p')
 
-# Wait until the first node is up.  
-waitfor "/var/log/kvm/serial.${n1}" "login:" 120
+# Wait for the node
+for i in $nodes ; do
+    waitfor "/var/log/kvm/serial.$i" "login:" 300 || {
+       vircmd destroy "$CLUSTER"
+       die "Failed to create cluster"
+    }
+done
 
 # Run the post-install in sequence on each node.  This is a little
 # more time-consuming than doing it in parallel but if some nodes boot
@@ -57,12 +91,33 @@ waitfor "/var/log/kvm/serial.${n1}" "login:" 120
 # However, the approach used here is more flexible since a generic
 # base image can be reused.  Note that this might not get the correct
 # nodes for some exotic clusters...
-nodes=$(sed -r -n -e "s@.*[[:space:]](${CLUSTER}n[[:digit:]]+)\$@\1@p" /etc/hosts)
-# Could avoid this by creating a special base and doing it in postinstall
-for i in $nodes ; do
-    ssh -o StrictHostKeyChecking=no "$i" ./scripts/install_gpfs_nas.sh
-done
 
-ssh "$n1" ./scripts/setup_gpfs.sh
+n1="${CLUSTER}n1"
 
-ssh "$n1" ./scripts/setup_cluster.sh
+case "$TYPE" in
+    "build")
+       # Build node doesn't really need CTDB/Samba to be installed, if the
+       # packages are not present in the repo, they're skipped.
+       ssh -o StrictHostKeyChecking=no "$n1" "./scripts/setup_build.sh || true"
+       ;;
+
+    "ad")
+       ssh -o StrictHostKeyChecking=no "$n1" ./scripts/setup_ad_server.sh
+       ;;
+
+    "samba")
+       for i in $nodes ; do
+           ssh -o StrictHostKeyChecking=no "$i" ./scripts/install_gpfs_nas.sh
+       done
+       ssh "$n1" ./scripts/setup_gpfs.sh
+
+       auth_method=$(autocluster -c "${CLUSTER}.autocluster" -e 'echo $AUTH_METHOD')
+       if [ "$auth_method" = "winbind" ]; then
+           ad_pw=$(autocluster -c "${CLUSTER}.autocluster" -e 'echo $AD_ADMIN_PASS')
+           args="-UAdministrator%${ad_pw}"
+       else
+           args=""
+       fi
+       ssh "$n1" ./scripts/setup_cluster.sh "$args"
+       ;;
+esac