source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmautoload @ 223

Last change on this file since 223 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 6.1 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# @(#)01 1.57.1.1 src/avs/fs/mmfs/ts/admin/mmautoload.sh, mmfs, avs_rgpfs24, rgpfs24s001a 4/5/06 11:34:58
17#########################################################################
18#                                                                       #
19#  Usage:  mmautoload                                                   #
20#                                                                       #
21#  Called once from inittab.  Performs GPFS configuration               #
22#  initialization.  If everything goes smoothly, and the                #
23#  autoload parameter is set to yes, starts the GPFS daemon.            #
24#                                                                       #
25#########################################################################
26
27# Include global declarations and service routines.
28. /usr/lpp/mmfs/bin/mmglobfuncs
29. /usr/lpp/mmfs/bin/mmsdrfsdef
30. /usr/lpp/mmfs/bin/mmfsfuncs
31
32sourceFile="mmautoload.sh"
33[[ -n $DEBUG || -n $DEBUGmmautoload ]] && set -x
34$mmTRACE_ENTER "$*"
35
36# Local variables
37
38mmfslog=${rasDir}mmfs.log.latest # daemon log (/var/adm/ras/mmfs.log.latest)
39interval=10                      # 10 6-second intervals is a message per minute
40integer waitPeriod               # wait period (in minutes)
41integer timeout
42
43
44###########################################################
45#
46#  Mainline processing
47#
48###########################################################
49
50# If the node does not appear to belong to a GPFS cluster,
51# go away quietly.
52if [[ ! -f $mmsdrfsFile ]]
53then
54  $rm -f $GLOBAL_FILES $LOCAL_FILES
55  return 0
56fi
57
58# Determine the type of cluster environment.
59determineMode
60
61# If the cluster type is not known, go away quietly.
62if [[ $MMMODE != lc && $MMMODE != single ]]
63then
64  $rm -f $GLOBAL_FILES $LOCAL_FILES
65  return 0
66fi
67
68# Put a message in the daemon log to reflect the node reboot.
69[[ -f $mmfslog ]] &&  \
70  print "\n\n$(date): Node rebooted.  Starting mmautoload..." >> $mmfslog
71
72# Force the recreation of the local system files.
73$rm -f $mmfsNodeData $mmfscfgFile ${mmfsNewKeyLevel}+([0-9])  \
74       ${mmfsCommittedKeyLevel}+([0-9]) $nsdpvol
75
76# If AIX, verify there is an mmfs entry in /etc/vfs.
77# If Linux, figure out what is the correct major number.
78checkVfsNumber
79rc=$?
80if [[ $rc -ne 0 ]]
81then
82  $rm -f $GLOBAL_FILES $LOCAL_FILES
83  return 0
84fi
85
86# Verify that the GPFS environment is properly initialized.
87# If not successful, keep trying for up to 5 minutes before giving up.
88waitPeriod=5
89timeout=1
90$rm -f $errMsg
91while true
92do
93  export MOUNT_POINT_CHECK=all
94  gpfsInitOutput=$(gpfsInit nolock 2>$errMsg)
95  rc=$?
96  unset MOUNT_POINT_CHECK
97  if [[ $rc -ne 0 || -z $gpfsInitOutput ]]
98  then
99    # gpfsInit failed but there still may be a chance
100    # for things to get fixed - we'll try again.
101    whatfor="cluster data repository"
102  else
103    # The gpfsInit call worked.
104    # Parse the result and get out of the loop.
105    setGlobalVar 0 $gpfsInitOutput
106    $rm -f $errMsg
107    break
108  fi  # end of if [[ $rc -ne 0 || -z $gpfsInitOutput ]]
109
110  # Something is not right.  Put out a message every 60 seconds.
111  timeout=timeout-1
112  if [[ $timeout -le 0 ]]
113  then
114    # Show detailed error messages if any.
115    [[ -s $errMsg ]] && $cat $errMsg 1>&2
116    # Tell what it is that we are waiting for.
117    printErrorMsg 142 $mmcmd "$whatfor"
118    # Put the messages in the daemon log as well.
119    if [[ -f $mmfslog ]]
120    then
121      [[ -s $errMsg ]] && $cat $errMsg     >> $mmfslog
122      printErrorMsg 142 $mmcmd "$whatfor" 2>> $mmfslog
123    fi
124    $rm -f $errMsg
125
126    # Reset the counters and see if it is time to give up.
127    if [[ $waitPeriod -gt 0 ]]
128    then
129      waitPeriod=waitPeriod-1
130      timeout=$interval
131    else
132      # The problem did not clear in the last 5 minutes.
133      # Tell the guy to use mmstartup and give up.
134      print -u2 "mmautoload: The GPFS environment cannot be initialized."
135      print -u2 "mmautoload: Correct the problem and use mmstartup to start GPFS."
136      # Put the messages in the daemon log as well.
137      if [[ -f $mmfslog ]]
138      then
139        print "mmautoload: The GPFS environment cannot be initialized." >> $mmfslog
140        print "mmautoload: Correct the problem and use mmstartup to start GPFS." >> $mmfslog
141      fi
142      $rm -f $GLOBAL_FILES $LOCAL_FILES
143      return 0
144    fi  # end of if [[ $waitPeriod -gt 0 ]]
145  fi  # end of if [[ $timeout -le 0 ]]
146  $rm -f $errMsg
147
148  # Wait a while before retrying.
149  $sleep 6
150done  # end while true
151
152
153# If this is a primary or backup config server,
154# ensure the mmsdrserv daemon is running.
155if [[ $ourNodeName = $primaryServer || $ourNodeName = $backupServer ]]
156then
157  startSdrServ CURRENT 2>$errMsg
158
159  # Show detailed error messages if any.
160  if [[ -s $errMsg ]]
161  then
162    $cat $errMsg 1>&2
163    [[ -f $mmfslog ]] && $cat $errMsg >> $mmfslog
164  fi
165  $rm -f $errMsg
166fi  # end of if [[ $ourNodeName = $primaryServer || $ourNodeName = $backupServer ]]
167
168
169# Find the setting of the autoload parameter.
170autoload=$(showCfgValue autoload)
171
172
173# Go away if the autoload parameter is not set to yes.
174if [[ $autoload != yes ]]
175then
176  $rm -f $GLOBAL_FILES $LOCAL_FILES
177  return 0
178fi
179
180
181# Start GPFS.
182[[ -f $mmfslog ]] &&  \
183  print "\n$(date): mmautoload: Starting GPFS..." >> $mmfslog
184
185# Check whether we are already running.
186pid=$($ps -eo "pid args" |  \
187      $awk '/\/runmmfs/ && !/this process/ {print $1}')
188if [[ -n $pid ]]
189then
190  # GPFS is already active.
191  printInfoMsg 586 GPFS
192  [[ -f $mmfslog ]] &&  \
193    printInfoMsg 586 GPFS >> $mmfslog
194else
195  # Start the daemon.
196  # In non-Linux systems, pass the output of gpfsInit
197  # to runmmfs to avoid a second initialization call.
198  # In Linux, this is not done because the device major
199  # number is not available at this time.
200  if [[ $osName = Linux ]]
201  then
202    $daemonize -c $runmmfs
203  else
204    $daemonize -e "GPFSINIT=\"$gpfsInitOutput\"" -c $runmmfs
205  fi
206fi
207
208$rm -f $GLOBAL_FILES $LOCAL_FILES
209return 0
210
Note: See TracBrowser for help on using the repository browser.