3 # Automatically setup GPFS. This is a quick way to get setup with an
4 # autocluster system. It finds NSDs, does various pieces of GPFS
5 # configuration, creates a filesystem and mounts it.
11 # $nsd_servers is setup in here
12 . $(dirname $0)/nsd_server_common.bash "$@"
22 --gpfs-num-nsds=<num> Specify number of NSDs to use for GPFS
23 filesystem. Defaults to value of
24 autocluster variable GPFS_DEFAULT_NSDS.
25 If this is unset then all NSDs found
28 --cluster-name=<string> Specify prefix for GPFS cluster name. The
29 domain will be appended to this.
30 Defaults to value of autocluster
33 --mountpoint=<dir> The directory where the GPFS filesystem
40 gpfs_num_nsds="@@GPFS_DEFAULT_NSDS@@"
41 cluster_name="@@CLUSTER@@"
42 mountpoint="@@CLUSTERFS_DEFAULT_MOUNTPOINT@@"
44 opts="gpfs-num-nsds:,cluster-name:,mountpoint:"
45 getopt_output=$(getopt -n autocluster -o h -l "$opts" -- "$@")
48 eval set -- "$getopt_output"
51 --gpfs-num-nsds) gpfs_num_nsds="$2" ; shift 2 ;;
52 --cluster-name) cluster_name="$2" ; shift 2 ;;
53 --mountpoint) mountpoint="$2" ; shift 2 ;;
56 *) echo "Unknown option \"$1\"" ; usage ;;
64 domain=$(dnsdomainname)
65 nodes=$(onnode -q all hostname | grep -i $domain | tr 'A-Z\012' 'a-z\040')
68 if [ "$first" != "$nodes" ] ; then
71 secondary="${rest%% *}"
76 if [ -n "$nsd_servers" ] ; then
77 nodes="${nodes} ${nsd_servers//,/ }"
79 # Determine secondary GPFS server. Is there a 2nd NSD server? If
80 # not then use node 0 of the CTDB cluster.
81 secondary="${nsd_servers#*,}"
82 secondary="${secondary%%,*}"
83 [ -n "$secondary" -a "$secondary" != "${nsd_servers%%,*}" ] || \
86 # Primary is just the 1st NSD server.
87 primary="${nsd_servers%%,*}"
90 nodefile=/tmp/nodes.$$
93 if [ -n "$nsd_servers" ] ; then
94 # This designates the $nsd_servers and $first as quorum nodes.
96 if [ "$n" = "$first" -o "$foo" != "${foo/${n},/}" ] ; then
97 designation="${designation}-quorum"
100 designation="${designation}-quorum"
102 echo "$n:${designation}:"
105 echo "Creating cluster"
106 mmcrcluster -N $nodefile -p $primary ${secondary:+-s} $secondary -r /usr/bin/ssh -R /usr/bin/scp -C $cluster_name.$domain
108 # GPFS 3.3 needs this... and GPFS 3.2 doesn't have mmchlicense, so
109 # this seems like a good option for now.
110 if type mmchlicense >/dev/null 2>&1 ; then
111 mmchlicense server --accept -N all
115 echo "Attempting to set adminMode=allToAll"
116 mmchconfig adminMode=allToAll </dev/null || true
118 . $(dirname $0)/mknsd.sh
121 echo "Generating auth key"
125 echo "Setting GPFS config options"
126 mmchconfig autoload=yes,leaseRecoveryWait=3,maxFilesToCache=20000,failureDetectionTime=10,maxMBpS=500,unmountOnDiskFail=yes,pagepool=64M,allowSambaCaseInsensitiveLookup=no,cipherList=AUTHONLY
131 echo "Waiting for gpfs to become active"
133 while mmgetstate -a | tail -n +4 | grep -v " active" > /dev/null; do
135 count=$(($count + 1))
136 if [ $count -gt 60 ] ; then
137 echo "TIMEOUT: gpfs didn't become active"
145 echo "Creating filesystem"
146 mkdir -p "${mountpoint}/automountdir"
148 nsdfile2=/tmp/nsd2.$$
149 if [ -n "$gpfs_num_nsds" ] ; then
150 head -n $(($gpfs_num_nsds * 2))
153 fi <$nsdfile >$nsdfile2
155 chattr +i "$mountpoint"
156 mmcrfs gpfs0 -F $nsdfile2 -A yes -Q yes -D nfs4 -B 64k -k nfs4 -n 32 -E yes -S no -T "$mountpoint" -i 512
159 echo "Mounting filesystem"
162 echo "Waiting for gpfs to mount"
163 while ! mount | grep /dev/gpfs0 > /dev/null; do echo -n "."; sleep 1; done
166 echo "GPFS setup complete"