2 # ctdb event script for NFS tickle acks
4 PATH=/bin:/usr/bin:$PATH
13 [ "$CTDB_MANAGES_NFS" = "yes" ] || exit 0
14 [ -z "$NFS_TICKLE_SHARED_DIRECTORY" ] && exit 0
18 mkdir -p $CTDB_BASE/state/nfstickle
19 mkdir -p $NFS_TICKLE_SHARED_DIRECTORY/`hostname`
20 # we rely on fast tcp wait1 recycling
21 echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
28 # first send a grat arp, to ensure the client knows the updated
29 # mac address for this IP
30 ctdb gratiousarp $ip $iface
31 # send tickle acks for all the connections the old server had
32 for f in $NFS_TICKLE_SHARED_DIRECTORY/*/$ip; do
33 [ -f $f ] && cat $f | while read dest; do
34 dip=`echo $dest | cut -d: -f1`
35 dport=`echo $dest | cut -d: -f2`
36 # send three, in case of lost packets
37 echo "Sending NFS tickle ack for $ip to $dip:$dport"
38 for i in `seq 1 3`; do
39 ctdb tickle $dip:$dport $ip:2049
59 # always create these direcotries since NFS might be enabled at runtime
60 # and we dont want to restart ctdbd
61 mkdir -p $CTDB_BASE/state/nfstickle
62 mkdir -p $NFS_TICKLE_SHARED_DIRECTORY/`hostname`
64 mydir=$NFS_TICKLE_SHARED_DIRECTORY/`hostname`
66 # record our connections to shared storage
67 netstat -tn |egrep '^tcp[[:space:]]+[0-9]+[[:space:]]+[0-9]+[[:space:]]+[0-9\.]+:2049.*ESTABLISHED' |
68 awk '{print $4" "$5}' |
69 while read dest src; do
70 ip=`echo $dest | cut -d: -f1`
71 echo $src >> $mydir/$ip
78 # ignore unknown commands