source: gpfs_3.1_ker2.6.20/lpp/mmfs/samples/nfscluster/install_ha-nfs.sh @ 90

Last change on this file since 90 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 7.4 KB
Line 
1#!/bin/bash
2
3# SLES 9 only
4# This script is written in bash (instead of ksh) as it invokes SLES scripts
5
6install_script=/usr/lpp/mmfs/samples/nfscluster/install_ha-nfs.sh
7
8error() {
9    echo "Error: $*"
10}
11
12usage() {
13    echo "Usage: $0 [-a] nfsdefs nodes.list"
14    echo "$@"
15    exit 1
16}
17
18# Exit if status is not 0
19statusCheck() {
20    status=$?
21    if [ $status -ne 0 ]; then
22        grep "Error:\|Warning:" $LOGFILE
23        [ -s $LOGFILE ] && echo -n "See $LOGFILE for details."
24        echo ""
25        exit $status
26    fi
27}
28
29config() {
30    # Check for SUSE distribution
31    dist=$(cat /etc/issue | grep "SUSE LINUX Enterprise Server 9")
32    if [ -z "$dist" ]; then
33  error "Install will work only for SUSE LINUX Enterprise Server 9"
34  return 1
35    fi
36
37    # Check the GPFS is not running
38    gpfs=$(mmfsadm dump version 2> /dev/null | grep "Current daemon version")
39    if [ -n "$gpfs" ]; then
40  error "GPFS must be stopped before installation."
41  return 1
42    fi
43
44    # Ensure programs required for HA are available
45    if [ ! -e /etc/ha.d/resource.d/IPaddr ]; then
46        error "Cannot find heartbeat in /etc/ha.d/resource.d. Please install the heartbeat RPMs required for high-availability. Installation will not continue."
47        return 1
48    fi
49
50    # Ensure all public interfaces used for NFS are static (no DHCP)
51    gpfsip=$(myGPFSIP)
52    nfsIPs=$(getNfsIPs $gpfsip)
53    for ip in $nfsIPs; do
54        # Find its ifcfg file
55        ifcfg=$(getifcfg $ip)
56  if [ -z "$ifcfg" ]; then
57            error "Cannot find configuration file for $ip in $IFPATH"
58            error "$ip has to be a static IP address defined in $IFPATH. DHCP is not permitted as an NFS address."
59            return 1
60        fi
61        bootproto=$(grep ^BOOTPROTO $ifcfg | awk -F\' '{print $2}')
62        if [ "$bootproto" != "static" ]; then
63            error "$ip has to be a static IP address in $ifcfg. DHCP is not permitted as an NFS address."
64            return 1
65        fi
66    done
67
68    # Check if sm-notify works with host names. Warn, otherwise
69    # Use any one of NFS IPs
70    sm-notify -m 1 -d -v $ip 2> /dev/null
71    if [ $? -ne 0 ]; then
72        echo "Warning: The installed version of sm-notify does not support notification of failures on IP takeover for NLM lock recovery. Please upgrade (see README) if you intend to use byte-range locking over NFS."
73    fi
74
75    typeset -i portAssigned=1
76    configNLMPorts $gpfsip
77    [ $? -ne 0 ] && portAssigned=0
78 
79    # Check if kernel supports manipulating grace period
80    checkDynamicGrace
81    if [ $? -eq 0 ]; then
82        echo "Warning: The running kernel ($(uname -r)) does not support setting grace period for NFS locking. On single node failure, all NFS locks will be released cluster-wide and reclaimed by clients."
83    fi
84
85    # Copy files from samples
86    [ -d /var/mmfs/etc ] && cp -a /var/mmfs/etc /var/mmfs/etc.bak
87    cp -dp /usr/lpp/mmfs/samples/nfscluster/* /var/mmfs/etc
88
89    log cp -dp /usr/lpp/mmfs/samples/nfscluster/init.d.gpfs /etc/init.d/gpfs &&
90    log insserv gpfs
91    # Undo GPFS autoload from inittab
92    sed -i 's/^gpfs:\(.*\)/# gpfs:\1  # Disabled by HA-NFS/g' /etc/inittab
93
94    # Set default start mode of interfaces to be used for HA-NFS to "manual"
95    # This is required so clients do not detect active connections on failover
96    # or failback before GPFS is active
97    for ip in $nfsIPs; do
98        # Find its ifcfg file
99        ifcfg=$(getifcfg $ip)
100  [ -z "$ifcfg" ] && continue
101        iface=$(getifname $ip)
102        if grep -q "^STARTMODE.*='onboot'" $ifcfg; then
103      . $ifcfg
104      for ipval in ${!IPADDR*}; do
105    index=${ipval#IPADDR}
106    ipaddr=${!ipval}
107    if [ "$ip" == "$ipaddr" ]; then
108      mode=STARTMODE$index
109      break
110    fi
111      done
112            # SuSE
113            sed -i "s/^$mode='onboot'/$mode='manual'  # added for HA-NFS/g" $ifcfg
114            echo "Installation has changed the start mode of interface $iface to manual."
115        elif grep -q "^ONBOOT=yes" $ifcfg; then
116            # RedHat
117            sed -i "s/^ONBOOT=yes/ONBOOT=no # added for HA-NFS/g" $ifcfg
118            echo "Installation has changed the start mode of interface $iface to manual."
119        fi
120    done
121
122    if [ $portAssigned -eq 0 ]; then
123  echo "Warning: Cannot assign requested ports for NLM. Reboot required to complete installation."
124    fi
125}
126
127install() {
128    echo -n "Synchronizing install files to all nodes in the cluster "
129    for ip in $gpfsIPs; do
130  log $GPFS_rcpPath $defs $ip:/var/mmfs/etc
131  log $GPFS_rcpPath $nodes $ip:$NODELIST
132    done
133    rc_status -v
134    statusCheck
135
136    echo -n "Installing HA-NFS on all nodes in the cluster "
137    gpfsIPs=$(echo $gpfsIPs | sed 's/ /,/g')
138    log mmdshcmdRC $gpfsIPs $install_script -c
139    rc_status -v
140    statusCheck
141}
142
143chconfig() {
144    nodeList=$*
145
146    # Autoload GPFS on boot.
147    if [ "$AUTOSTART" == "1" ]; then 
148  options="autoload=yes"
149    else
150  options="autoload=no"
151    fi
152
153    # For better read performance of large files set the following option.
154    options="$options,nfsprefetchstrategy=1"
155
156    # After creating the GPFS cluster turn on the GPFS HA-NFS option.
157    options="$options,enablenfscluster=yes"
158
159    echo -n "Configuring GPFS cluster for HA-NFS "
160    log mmchconfig "$options $nodeList"
161
162    # Following options have to be run on all nodes of the cluster
163   
164    if [ -n "$allflag" ]; then
165        # Current lease time and wait time are 35+35 seconds.
166        # set leaserecoverywait to no less than 10 second.
167        options="$options,leaserecoverywait=10"
168
169        # set leaseDuration to no less than 20 second.
170        options="$options,leaseDuration=20"
171
172        log mmchconfig "$options"
173    fi
174    rc_status -v
175}
176
177touch /var/mmfs/etc/nfsdefs # workaround to get nfsfuncs to work
178funcs=/usr/lpp/mmfs/samples/nfscluster/nfsfuncs
179[ -f $funcs ] || die "Cannot find $funcs"
180. $funcs
181
182. /etc/rc.status
183rc_reset
184
185LOGFILE=/tmp/install-ha-nfs.log
186> $LOGFILE
187
188allflag=""
189while getopts acv OPT; do
190    case $OPT in
191  a)
192      [ -n "$allflag" ] && usage "specify '$OPT' option only once"
193      allflag=yes
194      ;;
195  c)
196      config
197      exit $?
198      ;;
199  *)
200      usage "$OPTARG is not valid"
201      ;;
202    esac
203done
204
205shift $(($OPTIND-1))
206[ $# -eq 2 ] || usage
207
208defs=$1; nodes=$2
209
210[ -f $defs ] || die "Cannot find $defs. See /usr/lpp/mmfs/samples/nfscluster/README for installation instructions"
211[ -f $nodes ] || die "Cannot find $nodes. See /usr/lpp/mmfs/samples/nfscluster/README for installation instructions"
212
213cp -dp $defs /var/mmfs/etc
214cp -dp $nodes /var/mmfs/etc
215
216. $defs
217
218# Reset log file that might be overwritten by $defs
219LOGFILE=/tmp/install-ha-nfs.log
220
221if [ -n "$GPFS_RSH" ]; then
222    GPFS_rshPath=$(which $GPFS_RSH)
223else
224    GPFS_rshPath=$(which rsh)
225fi
226if [ -n "$GPFS_RCP" ]; then
227    GPFS_rcpPath=$(which $GPFS_RCP)
228else
229    GPFS_rcpPath=$(which rcp)
230fi
231
232# Check that mandatory parameters have been defined
233[ -n "$SHARED_ROOT" ] || die "The system directory (SHARED_ROOT) for HA-NFS not defined in $defs"
234[ -n "$NODELIST" ] || die "The list of GPFS nodes (NODELIST) for HA-NFS not defined in $defs"
235
236if [ -z "$allflag" ]; then
237    config
238    opts="-N $(myGPFSIP)"
239else
240    # Run configuration on all GPFS nodes
241    temp=$NODELIST
242    NODELIST=$nodes     # used by getAllGPFSIPs
243    gpfsIPs=$(getAllGPFSIPs)
244    list=$(echo $gpfsIPs | sed 's/ /,/g')
245    opts="-N $list"
246    NODELIST=$temp
247
248    myip=$(myGPFSIP)
249    if [ -z "$myip" ]; then
250  error "Install will work only from one of the nodes in nfs.nodes"
251  exit 1
252    fi
253
254    install $gpfsIPs
255fi
256chconfig $opts
257
258statusCheck
259grep "Warning:" $LOGFILE
260echo -n "Installation is complete. "
261[ -s $LOGFILE ] && echo "See $LOGFILE for details."
262exit 0
Note: See TracBrowser for help on using the repository browser.