source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmchecksubsys @ 90

Last change on this file since 90 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 12.8 KB
Line 
1#!/bin/ksh
2# IBM_PROLOG_BEGIN_TAG
3# This is an automatically generated prolog.
4
5
6
7# Licensed Materials - Property of IBM
8
9# (C) COPYRIGHT International Business Machines Corp. 1997,2006
10# All Rights Reserved
11
12# US Government Users Restricted Rights - Use, duplication or
13# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
14
15# IBM_PROLOG_END_TAG
16# @(#)71 1.112 src/avs/fs/mmfs/ts/admin/mmchecksubsys.sh, mmfs, avs_rgpfs24, rgpfs240610b 10/28/05 01:24:23
17#######################################################################
18#
19# mmchecksubsys is called by mmfsenv.
20# This script verifies that all GPFS system files are at the latest
21# level and then waits indefinitely for the proper conditions to exist
22# for mmfs to come up.  If the conditions do not exist, a message is
23# printed every minute for a while indicating what is being waited for.
24# After so many messages, a larger time interval occurs between messages.
25# The conditions checked for depend on the execution environment.
26#
27#######################################################################
28
29
30#######################################################################
31# If this has not been done yet by the caller, determine the pathname
32# of the mm commands directory and include the global declarations.
33#######################################################################
34if [[ $commandPath != set ]]
35then
36  # Decide where to look for the commands.  The normal install directory
37  # is /usr/lpp/mmfs/bin.  This can be changed by setting the MMFSDIR
38  # environment variable to something other than /usr/lpp/mmfs.
39  # If MMFSDIR is not used, before assuming the default install directory,
40  # we will check if the mmfs binaries are in the same place where this
41  # script resides.  This is a development aid for running out of a build tree.
42  if [[ -n $MMFSDIR ]]
43  then
44    mmcmdDir="${MMFSDIR}/bin"
45  else
46    if [[ -z ${0%%/*} ]]
47    then
48      fullname="$0"
49    else
50      fullname="${PWD%/}/$0"
51    fi
52    progDir=${fullname%/*}
53
54    if [[ -f ${progDir}/mmfs ]]
55    then
56      mmcmdDir="$progDir"
57    else
58      mmcmdDir="/usr/lpp/mmfs/bin"
59    fi
60  fi
61
62  # Determine the values of mmcmdSubdir and mmcmdSuffix.
63  set -f ; set -- $(/bin/uname -a) ; set +f
64  osName=$1
65  osVersion=$4
66  if [[ -f ${mmcmdDir}/mmfs || $osName != AIX || $osVersion < 5 ]]
67  then
68    mmcmdSubdir=""
69    mmcmdSuffix=""
70
71  else
72    # We must be running on top of AIX 5.
73    # Determine whether the current kernel is 64-bit.
74    kernelMode=$(${mmcmdDir}/mmkerninfo)
75    if [[ $kernelMode = 64 ]]
76    then
77      mmcmdSubdir="aix64"
78      mmcmdSuffix="64"
79    else
80      mmcmdSubdir="aix32"
81      mmcmdSuffix=""
82    fi
83  fi
84
85  # Include global declarations and service routines.
86  . ${mmcmdDir}/mmglobfuncs
87  . ${mmcmdDir}/mmsdrfsdef
88  . ${mmcmdDir}/mmfsfuncs
89
90  commandPath=set
91
92fi # end of if [[ $commandPath != set ]]
93
94sourceFile="mmchecksubsys.sh"
95[[ -n $DEBUG || -n $DEBUGmmchecksubsys ]] && set -x
96$mmTRACE_ENTER "$*"
97
98# Local variables
99
100intervala=10          # 10 6-second intervals is a message per minute.
101intervalb=50          # 50 6-second intervals is a message every 5 minutes.
102integer timeout=1
103integer longwait=5    # Do 5 short waits before starting the long ones.
104rvsd="rvsd"
105havsd="/usr/bin/ha.vsd"
106runningCmnd=""
107rshPath=""
108rcpPath=""
109
110
111# Local routines
112
113
114####################################################################
115#
116# Function:  Compare the release level of the currently-installed
117#            code against the daemon version level for the nodeset.
118#
119# Input:     None
120#
121# Output:    None
122#
123# Returns:   0 - success
124#            1 - incompatible release
125#
126####################################################################
127function checkDaemonVersion
128{
129  typeset sourceFile="mmchecksubsys.sh"
130  [[ -n $DEBUG || -n $DEBUGcheckDaemonVersion ]] && set -x
131  $mmTRACE_ENTER "$*"
132
133  typeset maxFeatureLevelAllowed
134  typeset recordedProductVersion
135
136  # Determine the value of the maxFeatureLevelAllowed parameter.
137  maxFeatureLevelAllowed=$(showCfgValue maxFeatureLevelAllowed)
138
139  # Warn the user if the current release information for
140  # the node in the mmsdrfs file is not up to date.
141  recordedProductVersion=$(getNodeInfo $PRODUCT_VERSION_Field  \
142           $NODE_NUMBER_Field $ourNodeNumber $nsId $mmsdrfsFile)
143  if [[ $recordedProductVersion != $productVersion ]]
144  then
145    print -u2 "$mmcmd: The release information for this node in the GPFS configuration files is not up to date."
146    print -u2 "     Recorded Release: $recordedProductVersion  Installed Release: $productVersion."
147    print -u2 "     Use the mmchconfig release=LATEST command to update the information."
148    print -u2 "     Processing continues ..."
149  fi
150
151  # If maxFeatureLevelAllowed is not established yet, assume the lowest value.
152  if [[ -z $maxFeatureLevelAllowed ]]
153  then
154    print -u2 "$mmcmd: The GPFS release level for nodeset $nsId cannot be determined (assumed $initialDaemonVersion)."
155    printErrorMsg 344 $mmcmd "\"mmchconfig release=LATEST -C $nsId\""
156    maxFeatureLevelAllowed=$initialDaemonVersion
157  fi
158
159  # Compare the daemon release levels.
160  if [[ $compatibleDaemonVersion -gt $maxFeatureLevelAllowed ]]
161  then
162    rc=1
163    print -u2 "$mmcmd: The GPFS code installed on this node is not compatible with the"
164    print -u2 "     rest of the nodes in nodeset $nsId."
165
166  elif [[ $currentDaemonVersion -lt $maxFeatureLevelAllowed ]]
167  then
168    rc=1
169    print -u2 "$mmcmd: The GPFS code installed on this node is at a lower level than the"
170    print -u2 "     rest of the nodes in nodeset $nsId."
171    print -u2 "$mmcmd: Upgrade the node and run mmchconfig release=LATEST, or"
172    print -u2 "     shutdown GPFS on all nodes and run mmchconfig release=$currentDaemonVersion"
173
174  elif [[ $currentDaemonVersion -gt $maxFeatureLevelAllowed ]]
175  then
176    rc=0
177    print -u2 "$mmcmd: The GPFS code installed on this node is at a higher level than the"
178    print -u2 "     rest of the nodes in nodeset $nsId."
179    print -u2 "$mmcmd: Processing continues but some functionality may not be available."
180    print -u2 "$mmcmd: Upgrade the back level nodes and run mmchconfig release=LATEST"
181
182  else
183    # The node is at the right level.
184    rc=0
185  fi
186
187  return $rc
188
189}  #----------- end of function checkDaemonVersion -------------
190
191
192###########################################################
193#
194#  Mainline processing
195#
196###########################################################
197
198$rm -f $errMsg
199
200# Set up trap exception handling.
201trap pretrap2 HUP INT QUIT KILL
202
203# If not already done by mmautoload, make sure that
204# the GPFS environment is properly initialized.
205if [[ -n $GPFSINIT && $GPFSINIT != '""' ]]
206then
207  # If GPFSINIT is set in mmautoload, strip the surrounding quotes.
208  GPFSINIT=${GPFSINIT#\"}
209  gpfsInitOutput=${GPFSINIT%\"}
210else
211  # Verify the GPFS environment.
212
213  # If AIX, verify there is an mmfs entry in /etc/vfs.
214  # If Linux, figure out what is the correct major number.
215  checkVfsNumber
216  rc=$?
217  if [[ $rc -ne 0 ]]
218  then
219    $rm -f $GLOBAL_FILES $LOCAL_FILES
220    return $rc
221  fi
222
223  # If the major number of the /dev entries is incorrect, remove
224  # one of the system files to force the environment to be rebuild.
225  [[ $currentMajorNumber -ne $neededMajorNumber ]] && \
226    $rm -f $mmfscfgFile
227
228  # Make sure that the local copies of the mmsdrfs, mmfs.cfg,
229  # and the rest of the system files are up to date.
230  export MOUNT_POINT_CHECK=all
231  gpfsInitOutput=$(gpfsInit nolock)
232  rc=$?
233  unset MOUNT_POINT_CHECK
234  if [[ -z $gpfsInitOutput || $rc -ne 0 ]]
235  then
236    # The GPFS configuration information is missing.
237    printErrorMsg 195 $mmcmd
238    $rm -f $GLOBAL_FILES $LOCAL_FILES
239    [[ $rc -eq 0 ]] && rc=1
240    return $rc
241  fi
242fi
243
244# Parse the output from the gpfsInit call.
245setGlobalVar 0 $gpfsInitOutput
246
247if [[ $MMMODE != lc && $MMMODE != single ]]
248then
249  # Unknown GPFS cluster type.
250  printErrorMsg 338 $mmcmd $MMMODE
251  $rm -f $GLOBAL_FILES $LOCAL_FILES
252  return 1
253fi
254
255# Parse the Gpfs object information.
256IFS=:
257set -f ; set -- $gpfsObjectInfo ; set +f
258runningCmnd=$3
259IFS="$IFS_sv"
260
261
262# Extract needed information from the mmsdrfs file.
263vsdDisk=false
264nonVsdDisk=false
265IFS=":"
266exec 3<&-
267exec 3< $mmsdrfsFile
268while read -u3 sdrfsLine
269do
270  # Parse the line.
271  set -f ; set -A v -- - $sdrfsLine ; set +f
272  IFS="$IFS_sv"   # Restore the default IFS settings.
273
274  # Extract information from fields in various lines.
275  case ${v[$LINE_TYPE_Field]} in
276
277    $SG_DISKS )
278      if [[ ${v[$NODESETID_Field]} != $FREE_DISK ]]
279      then
280        if [[ ${v[$NSD_SUBTYPE_Field]} = "vsd" ]]
281        then
282          vsdDisk=true
283        else
284          nonVsdDisk=true
285        fi
286      fi
287      ;;
288
289    $SG_ETCFS )
290      if [[ ${v[$LINE_NUMBER_Field]} = $MOUNT_Line &&
291            ${v[$ETCFS_TEXT_Field]}  = *automount* ]]
292      then
293        automountMounts=true
294      fi
295      ;;
296
297  esac  # end of "Extract information from fields in various lines"
298
299  IFS=":"  # Change the separator back to ":" for the next iteration.
300
301done  # end while read -u3 sdrfsLine
302
303IFS="$IFS_sv"  # Restore the default IFS settings.
304
305if [[ $nonVsdDisk = false && $vsdDisk = true ]]
306then
307  # If all of the disks are VSD based, normally we will wait for rvsd.
308  # The exception is if the user explicitly set wait4RVSD to 'no'.
309  waitForVsdSubsys=$(showCfgValue wait4RVSD)
310  [[ -z $waitForVsdSubsys ]] && waitForVsdSubsys=yes
311else
312  # If there are non-VSD based disks, we will not wait for rvsd so
313  # that the mounting of the non-VSD based file system can proceed.
314  waitForVsdSubsys=no
315fi
316
317
318##################################################################
319# Ensure mmsdrserv is not running on this node unless it has to.
320##################################################################
321[[ $ourNodeName != $primaryServer && $ourNodeName != $backupServer ]] &&  \
322  killSdrServ >/dev/null 2>&1
323
324
325##############################
326# Start the automount daemon.
327##############################
328if [[ -n $automountMounts ]]
329then
330  # Determine the value of the automountDir parameter.
331  [[ $osName = Linux ]] &&  \
332    automountDir=$(showCfgValue automountDir)
333  [[ -z $automountDir ]] && automountDir=$defaultAutomountDir
334
335  # Start the automount daemon.
336  startAutomounter $automountDir
337
338fi  # end of if [[ $automountMounts = true ]]
339
340
341##############################################################
342# In a single node environment, there is nothing more to do.
343##############################################################
344if [[ $MMMODE = single ]]
345then
346  $rm -f $GLOBAL_FILES $LOCAL_FILES
347  return 0
348fi
349
350
351#######################################################
352# Make sure the code level on this node is compatible
353# with code in the rest of the nodes in the nodeset.
354#######################################################
355# checkDaemonVersion
356# rc=$?
357# if [[ $rc -ne 0 ]]
358# then
359#   $rm -f $GLOBAL_FILES $LOCAL_FILES
360#   return $rc
361# fi
362
363
364########################################################
365# Wait until all conditions for daemon startup are met.
366########################################################
367while true
368do
369  if [[ -z $gpfsObjectInfo ]]
370  then
371    # Get the latest Gpfs object via a call to gpfsInit.
372    # This will rebuild the environment if needed.
373    export MOUNT_POINT_CHECK=all
374    gpfsInitOutput=$(gpfsInit nolock 2>$errMsg)
375    rc=$?
376    unset MOUNT_POINT_CHECK
377    if [[ -z $gpfsInitOutput || $rc -ne 0 ]]
378    then
379      # The GPFS configuration information is missing.
380      printErrorMsg 195 $mmcmd 2>> $errMsg
381    else
382      # Parse the GpfsInit output.
383      setGlobalVar 0 $gpfsInitOutput
384
385      # Parse the Gpfs object information.
386      IFS=':'
387      set -f ; set -- $gpfsObjectInfo ; set +f
388      IFS="$IFS_sv"
389      runningCmnd=$3
390    fi  # end of if [[ -z $gpfsInitOutput || $rc -ne 0 ]]
391  fi  # end of if [[ -z $gpfsObjectInfo ]]
392
393  if [[ -z $gpfsObjectInfo ]]
394  then
395    whatfor="cluster data repository"
396  elif [[ -n $runningCmnd ]]
397  then
398    # An mm administration command is in progress.
399    whatfor="$runningCmnd"
400    gpfsObjectInfo=""    # Force gpfsInit to be executed again.
401
402  else
403    # If waitForVsdSubsys is set to 'yes', ensure rvsd is up and ready.
404    if [[ $waitForVsdSubsys = yes && -x $havsd && $osName = AIX &&
405          -z $(LC_ALL=C $lssrc -l -s $rvsd | $fgrep "active=1, state=idle") ]]
406    then
407      # rvsd is up but it is not ready yet.
408      whatfor="rvsd-ready"
409    else
410      # All subsystems seem to be on-line.
411      $rm -f $errMsg
412      break
413    fi  # end of if [[ $waitForVsdSubsys = yes ... ]]
414  fi  # end of if [[ -z $gpfsObjectInfo ]]
415
416  timeout=timeout-1
417  if [[ $timeout -le 0 ]]
418  then
419    # Show detailed error messages if any.
420    [[ -s $errMsg ]] && $cat $errMsg 1>&2
421    $rm -f $errMsg
422    # Tell the user what it is that we are waiting for.
423    printErrorMsg 142 $mmcmd "$whatfor"
424    if [[ $longwait -gt 0 ]]
425    then
426       longwait=longwait-1
427       timeout=$intervala
428    else
429       timeout=$intervalb
430    fi
431  fi
432  $sleep 6
433done
434
435$rm -f $GLOBAL_FILES $LOCAL_FILES
436$mmTRACE_EXIT "$MMMODE environment verified rc=0"
437return 0
438
Note: See TracBrowser for help on using the repository browser.