1 | #!/bin/ksh |
---|
2 | # @(#)67 1.13.1.10 src/avs/fs/mmfs/samples/nfscluster/start.nfs, mmfs, avs_rgpfs24, rgpfs24s010a 2/16/07 02:32:51 |
---|
3 | # |
---|
4 | # start.nfs <GPFS_IP_ADDRESS> |
---|
5 | # |
---|
6 | |
---|
7 | if [ ! -f /var/mmfs/etc/nfsfuncs ]; then |
---|
8 | echo "$0: Can't find NFS functions in /var/mmfs/etc" |
---|
9 | exit 0 |
---|
10 | fi |
---|
11 | . /var/mmfs/etc/nfsfuncs |
---|
12 | |
---|
13 | myip=$1 |
---|
14 | [ "$myip" == "" ] && myip=$(myGPFSIP) |
---|
15 | [ "$myip" != "" ] || die "Usage: start.nfs <GPFS IP address>" |
---|
16 | |
---|
17 | debugmsg "start.nfs called with ip=$myip" |
---|
18 | |
---|
19 | # Setup |
---|
20 | rotatelog |
---|
21 | _unlink /tmp/ha-nfs-reboot |
---|
22 | |
---|
23 | configHA $myip |
---|
24 | [ $? -ne 0 ] && die "start.nfs: configHA failed" |
---|
25 | |
---|
26 | # did we mount any of the exported fs |
---|
27 | isAnyExported |
---|
28 | [ $? -ne 0 ] && die "start.nfs: mount failed" |
---|
29 | |
---|
30 | # Clear any old locks in Linux. |
---|
31 | resetLockd |
---|
32 | |
---|
33 | # Set nfsd proc fs, used for grace control |
---|
34 | debuglog mount -t nfsd nfsd /proc/fs/nfsd |
---|
35 | |
---|
36 | # Stop NFSD before doing failback |
---|
37 | debuglog rpc.nfsd 0 |
---|
38 | |
---|
39 | # Is this a failback? |
---|
40 | [ $iptakeover -eq 1 ] && IPfailback $myip |
---|
41 | |
---|
42 | # Bring up all nfs ip address |
---|
43 | nfsips=$(getNfsIPs $myip) |
---|
44 | msg "Enabling interface(s) for IP address(es) $nfsips" |
---|
45 | |
---|
46 | typeset -i connections=0 |
---|
47 | while true; do |
---|
48 | for ip in $nfsips; do |
---|
49 | ifUp $ip |
---|
50 | iface=$(getifname $ip) |
---|
51 | checkLinkStatus $iface |
---|
52 | if [ $? -ne 1 ]; then |
---|
53 | gwIP=$(route -n |awk '/UG/ {print $2}') |
---|
54 | if [ -n "$gwIP" ]; then |
---|
55 | ping -c 1 -w 5 $gwIP > /dev/null |
---|
56 | if [ $? -ne 0 ]; then |
---|
57 | debugmsg "Failed to ping the gateway at $gwIP" |
---|
58 | else |
---|
59 | connections=1 |
---|
60 | fi |
---|
61 | else |
---|
62 | connections=1 |
---|
63 | fi |
---|
64 | fi |
---|
65 | done |
---|
66 | if [ $connections -eq 0 ]; then |
---|
67 | sleep 10 |
---|
68 | else |
---|
69 | break |
---|
70 | fi |
---|
71 | done |
---|
72 | |
---|
73 | # Start nfs server. |
---|
74 | debuglog umount /proc/fs/nfsd |
---|
75 | nfsService start |
---|
76 | |
---|
77 | _mkdir $SHARED_RECOVERY/$myip |
---|
78 | |
---|
79 | # takeover nodes that were recovered by this node before failing |
---|
80 | for failed_node in $(ls -A $SHARED_RECOVERY/$myip 2> /dev/null); do |
---|
81 | debugmsg "Do recovery for node $failed_node at $myip start up" |
---|
82 | IPtakeover $myip $failed_node |
---|
83 | done |
---|
84 | |
---|
85 | # takeover nodes that are not up |
---|
86 | next=$(getNextNode $myip $myip) |
---|
87 | debugmsg check other nodes starting with $next |
---|
88 | while [ -n "$next" ]; do |
---|
89 | isNodeUp $next |
---|
90 | if [ $? -ne 0 ]; then |
---|
91 | # was already on my list and was handled above |
---|
92 | if [ ! -f $SHARED_RECOVERY/$myip/$next ]; then |
---|
93 | isNodeUp $next |
---|
94 | if [ $? -ne 0 ]; then |
---|
95 | touch $SHARED_RECOVERY/$myip/$next |
---|
96 | sleep 10 |
---|
97 | if [ -f $SHARED_RECOVERY/$myip/$next ]; then |
---|
98 | isNodeUp $next |
---|
99 | if [ $? -ne 0 ]; then |
---|
100 | debugmsg "Do start recovery for node $next" |
---|
101 | IPtakeover $myip $next |
---|
102 | next=$(getNextNode $next $myip) |
---|
103 | continue |
---|
104 | fi |
---|
105 | fi |
---|
106 | fi |
---|
107 | fi |
---|
108 | fi |
---|
109 | break |
---|
110 | done |
---|
111 | |
---|
112 | |
---|
113 | # reclaim locks |
---|
114 | startReclaim $myip |
---|
115 | backupSmDir /tmp/statd |
---|
116 | |
---|
117 | if [ $monitor -eq 1 ]; then |
---|
118 | nfsmonitor -s |
---|
119 | fi |
---|
120 | exit 0 |
---|