From d39e4a7c395d057cc7b4ad4a4b23937a7b2363bb Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 29 May 2009 16:53:13 +1000 Subject: Make setup_gpfs.sh and mknsd.sh aware of NSD servers. Both scripts now use nsd_server_common.bash to re-exec on the first node defined in $NSD_SERVERS if that variable is set (to the list of sofs_storage nodes by 50sofs.defconf). They also also include the NSD servers in the file that is passed to mmcrnsd and mmcrfs. setup_gpfs.sh includes any NSD servers in the list of nodes for the GPFS cluster, using them as the primary and secondary GPFS servers. setup_gpfs.sh just sources mknsd.sh to avoid duplication of logic. Signed-off-by: Martin Schwenke --- base/root/scripts/mknsd.sh | 16 +++++++++---- base/root/scripts/nsd_server_common.bash | 18 ++++++++++++++ base/root/scripts/setup_gpfs.sh | 41 +++++++++++++++++--------------- 3 files changed, 51 insertions(+), 24 deletions(-) create mode 100644 base/root/scripts/nsd_server_common.bash (limited to 'base/root/scripts') diff --git a/base/root/scripts/mknsd.sh b/base/root/scripts/mknsd.sh index 304225e..f2cfb11 100755 --- a/base/root/scripts/mknsd.sh +++ b/base/root/scripts/mknsd.sh @@ -1,12 +1,18 @@ -#!/bin/sh +#!/bin/bash set -e -disks=`/var/mmfs/etc/nsddevices | awk '{print $1}'` +# $nsd_servers is setup in here +. $(dirname $0)/nsd_server_common.bash + +echo +echo "Setting up NSDs" +nsdfile=/tmp/nsd.$$ +disks=$(/var/mmfs/etc/nsddevices | awk '{print $1}') ( for d in $disks; do - echo $d:::::: + echo $d:${nsd_servers}::::: done -) > /tmp/nsdfile.$$ -mmcrnsd -F /tmp/nsdfile.$$ +) > $nsdfile +mmcrnsd -F $nsdfile mmlsnsd -m diff --git a/base/root/scripts/nsd_server_common.bash b/base/root/scripts/nsd_server_common.bash new file mode 100644 index 0000000..d665c59 --- /dev/null +++ b/base/root/scripts/nsd_server_common.bash @@ -0,0 +1,18 @@ +# If there are sofs_storage nodes in the cluster (meaning that other +# sofs_* nodes will not have direct-attached storage) then scripts +# that include this snippet must be run on one of the storage nodes. +# Therefore, in the case, this snippet tries to determine if it is +# running on the 1st NSD server and, if not, attempts to run the +# script there. + +nsd_servers="@@NSD_SERVERS@@" + +if [ -n "$nsd_servers" -a \ + "${HOSTNAME%%.*}" != "${nsd_servers%%[.,]*}" ] ; then + if [ "${0#/}" != "$0" ] ; then + script="$0" + else + script="${PWD}/${0}" + fi + exec ssh "${nsd_servers%%[.,]*}" "$script" "$@" +fi diff --git a/base/root/scripts/setup_gpfs.sh b/base/root/scripts/setup_gpfs.sh index 8ddae32..6067794 100755 --- a/base/root/scripts/setup_gpfs.sh +++ b/base/root/scripts/setup_gpfs.sh @@ -1,12 +1,25 @@ -#!/bin/sh -# this sets up GPFS without using the GUI. It is meant as a quick way to get setup -# with an autocluster system +#!/bin/bash + +# Automatically setup GPFS. This is a quick way to get setup with an +# autocluster system. It finds NSDs, does various pieces of GPFS +# configuration, creates a filesystem and mounts it. set -e -domain=`dnsdomainname` -nodes=`onnode all hostname | grep -i $domain | tr A-Z a-z` -node1=`onnode 0 hostname | grep -i $domain | tr A-Z a-z` -node2=`onnode 1 hostname | grep -i $domain | tr A-Z a-z` + +# $nsd_servers is setup in here +. $(dirname $0)/nsd_server_common.bash + +domain=$(dnsdomainname) +nodes=$(onnode all hostname | grep -i $domain | tr A-Z a-z) +if [ -n "$nsd_servers" ] ; then + nodes="${nodes} ${nsd_servers//,/ }" + node1="${nsd_servers%%,*}" + node2="${nsd_servers#*,}" + node2="${node2%%,*}" +else + node1=$(onnode 0 hostname | grep -i $domain | tr A-Z a-z) + node2=$(onnode 1 hostname | grep -i $domain | tr A-Z a-z) +fi nodefile=/tmp/nodes.$$ for n in $nodes; do @@ -14,19 +27,9 @@ for n in $nodes; do done echo "Creating cluster" -mmcrcluster -N $nodefile -p $node1 -s $node2 -r /usr/bin/ssh -R /usr/bin/scp -C @@CLUSTER@@.$domain +mmcrcluster -N $nodefile -p $node1 -s $node2 -r /usr/bin/ssh -R /usr/bin/scp -C m1.$domain -echo -echo "Setting up NSDs" -nsdfile=/tmp/nsd.$$ -disks=`/var/mmfs/etc/nsddevices | awk '{print $1}'` -( -for d in $disks; do - echo $d:::::: -done -) > $nsdfile -mmcrnsd -F $nsdfile -mmlsnsd -m +. $(dirname $0)/mknsd.sh echo echo "Generating auth key" -- cgit From 179b37edc928d6259083d912c4382207b55eaf46 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 29 May 2009 17:23:00 +1000 Subject: More general selection of secondary GPFS server in setup_gpfs.sh. No longer mysteriously fail if there is only one entry in NSD_SERVER - use the first node in the CTDB cluster as the secondary GPFS server. Signed-off-by: Martin Schwenke --- base/root/scripts/setup_gpfs.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'base/root/scripts') diff --git a/base/root/scripts/setup_gpfs.sh b/base/root/scripts/setup_gpfs.sh index 6067794..69af32c 100755 --- a/base/root/scripts/setup_gpfs.sh +++ b/base/root/scripts/setup_gpfs.sh @@ -11,14 +11,21 @@ set -e domain=$(dnsdomainname) nodes=$(onnode all hostname | grep -i $domain | tr A-Z a-z) +primary=$(onnode 0 hostname | grep -i $domain | tr A-Z a-z) +secondary=$(onnode 1 hostname | grep -i $domain | tr A-Z a-z) + if [ -n "$nsd_servers" ] ; then nodes="${nodes} ${nsd_servers//,/ }" - node1="${nsd_servers%%,*}" - node2="${nsd_servers#*,}" - node2="${node2%%,*}" -else - node1=$(onnode 0 hostname | grep -i $domain | tr A-Z a-z) - node2=$(onnode 1 hostname | grep -i $domain | tr A-Z a-z) + + # Determine secondary GPFS server. Is there a 2nd NSD server? If + # not then use node 0 of the CTDB cluster. + secondary="${nsd_servers#*,}" + secondary="${secondary%%,*}" + [ -n "$secondary" -a "$secondary" != "${nsd_servers%%,*}" ] || \ + secondary="$primary" + + # Primary is just the 1st NSD server. + primary="${nsd_servers%%,*}" fi nodefile=/tmp/nodes.$$ @@ -27,7 +34,7 @@ for n in $nodes; do done echo "Creating cluster" -mmcrcluster -N $nodefile -p $node1 -s $node2 -r /usr/bin/ssh -R /usr/bin/scp -C m1.$domain +mmcrcluster -N $nodefile -p $primary -s $secondary -r /usr/bin/ssh -R /usr/bin/scp -C m1.$domain . $(dirname $0)/mknsd.sh -- cgit