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.
9 gpfs_num_nsds="@@GPFS_DEFAULT_NSDS@@"
10 cluster_name="@@CLUSTER@@"
11 mountpoint="@@CLUSTERFS_DEFAULT_MOUNTPOINT@@"
12 nodes_storage_gpfs="@@NODES_STORAGE_GPFS@@"
13 shared_disk_ids="@@SHARED_DISK_IDS@@"
17 ##################################################
19 # If there are "storage_gpfs" nodes in the cluster (meaning that "nas"
20 # nodes will not have direct-attached storage) then scripts that
21 # include this snippet must be run on one of the storage nodes.
22 # Therefore, in the case, this snippet tries to determine if it is
23 # running on the 1st GPFS storage node and, if not, attempts to run
25 if [ -n "$nodes_storage_gpfs" -a \
26 "${HOSTNAME%%.*}" != "${nodes_storage_gpfs%%[.,]*}" ] ; then
27 if [ "${0#/}" != "$0" ] ; then
32 re_exec_node="${nodes_storage_gpfs%%[.,]*}"
34 echo "Creating NSDs on node \"${re_exec_node}\""
35 exec ssh "$re_exec_node" "$script" "$@"
38 ##################################################
43 _domain=$(dnsdomainname)
44 _nodes=$(onnode -q all hostname | grep -i "$_domain" | tr 'A-Z\012' 'a-z\040')
46 _first="${_nodes%% *}"
48 # Determine primary and secondary nodes. Give preference to GPFS
49 # storage nodes, falling back to regular nodes if there aren't any
51 if [ -n "$nodes_storage_gpfs" ] ; then
52 _primary="${nodes_storage_gpfs%%,*}"
53 _rest="${nodes_storage_gpfs#*,}"
54 _secondary="${_rest%%,*}"
56 if [ -z "$_primary" ] ; then
59 _secondary="${_rest%% *}"
60 elif [ -z "$_secondary" ] ; then
64 # Create the node description file for mmcrcluster. If there are
65 # dedicated storage nodes then they are quorum nodes, along with
66 # the first node. If there are no dedicated storage nodes then
67 # all nodes are quorum nodes.
68 _nodefile="${dir}/gpfs_nodes.${cluster_name}"
70 for _n in $_nodes ; do
71 if [ "$_n" = "$_first" ] ; then
72 echo "${_n}:manager-quorum:"
73 elif [ -n "$nodes_storage_gpfs" ] ; then
76 echo "${_n}:manager-quorum:"
79 for _n in $(echo "$nodes_storage_gpfs" | sed -e 's@,@ @g') ; do
80 echo "${_n}:manager-quorum:"
84 echo "Creating cluster"
85 # Don't quote secondary, since it might not exist
86 mmcrcluster -N "$_nodefile" \
87 -p "$_primary" ${_secondary:+-s} $_secondary \
88 -r /usr/bin/ssh -R /usr/bin/scp -C "${cluster_name}.${_domain}"
90 # GPFS >= 3.3 needs this. Earlier versions don't have
91 # mmchlicense, so be careful.
92 if type mmchlicense >/dev/null 2>&1 ; then
94 echo "Attempting to set server license mode for all nodes"
95 mmchlicense server --accept -N all
99 echo "Attempting to set adminMode=allToAll"
100 mmchconfig adminMode=allToAll </dev/null || true
103 echo "Generating auth key"
107 echo "Setting GPFS config options"
108 mmchconfig autoload=yes,leaseRecoveryWait=3,maxFilesToCache=20000,failureDetectionTime=10,maxMBpS=500,unmountOnDiskFail=yes,pagepool=64M,allowSambaCaseInsensitiveLookup=no,cipherList=AUTHONLY
113 echo "Waiting for gpfs to become active"
115 while mmgetstate -a | tail -n +4 | grep -v " active" > /dev/null; do
117 _count=$(($_count + 1))
118 if [ $_count -gt 60 ] ; then
119 echo "TIMEOUT: gpfs didn't become active"
127 nsdfile="${dir}/gpfs_nsds_all.${cluster_name}"
129 # Uses: nodes_storage_gpfs
134 echo "Setting up NSDs"
136 # Create an extended regexp that matches any of the IDs
137 pat=$(echo "$shared_disk_ids" | sed -e 's@ *@|@g')
139 # Now get devices and names from multipath
141 sed -r -n -e "s@^[^[:space:]]+[[:space:]]+\(($pat)\)[[:space:]](dm-[^[:space:]]+).*@\1 \2@p" |
142 while read _name _disk ; do
143 _name=$(echo "$_name" | tr -d -c '[:alnum:]')
144 echo "${_disk}:${nodes_storage_gpfs}::dataAndMetadata:1:${_name}:"
147 mmcrnsd -F "$nsdfile"
151 # Uses: mountpoint, gpfs_num_nsds, nsdfile
155 echo "Creating filesystem"
157 if [ ! -r "$nsdfile" ] ; then
158 echo "ERROR: missing NSD file \"${nsdfile}\""
162 mkdir -p "${mountpoint}/automountdir"
164 nsdfile2="${dir}/gpfs_nsds_defaultfs.${cluster_name}"
165 if [ -n "$gpfs_num_nsds" ] ; then
166 head -n $(($gpfs_num_nsds * 2))
169 fi <"$nsdfile" >"$nsdfile2"
171 chattr +i "$mountpoint"
173 mmcrfs gpfs0 -F "$nsdfile2" \
174 -A yes -Q yes -D nfs4 -B 64k -k nfs4 -n 32 -E yes -S no \
175 -T "$mountpoint" -i 512
183 echo "Mounting filesystem"
186 echo "Waiting for gpfs to mount"
187 while ! mount | grep /dev/gpfs0 > /dev/null; do
197 echo "GPFS setup complete"
200 [ -n "$1" ] || set -- setup mknsd mkfs mount complete