#!/usr/bin/ksh93 ################################################################# #### #### Description: #### #### This script generates the HACMP commands necessary to #### build/rebuild a 2 node - 1 or 2 way cascading cluster, #### each node with one or more resource groups, each #### resource group with one or more application servers. #### #### The output of this script must be saved to a file and #### executed separately to actually build the HACMP cluster. #### #### Assumptions: #### #### This script is designed for a 2 node - 1 or 2 way #### cascading cluster. #### #### The HACMP cluster utilities directory is: #### /usr/es/sbin/cluster/utilities/ #### #### The HACMP application start/stop scripts directory is: #### /usr/local/hascripts/ #### #### Resource group names and volume groups conform to the naming #### standards defined by Mt Xia: http://www.mtxia.com/css #### #### IP addresses exist for DNS names identical to the Node names. #### IP addresses exist for boot names assigned as: nodename-boot #### IP addresses exist for persistent names assigned as: nodename-pers #### IP addresses exist for resource group names assigned as defined #### by the Mt Xia naming standard: http://www.mtxia.com/css #### #### The /etc/hosts file contains all IP addresses and names. #### #### The /usr/es/sbin/cluster/etc/rhosts file contains the IP names for #### the nodename and bootname of both cluster nodes. #### #### The /usr/es/sbin/cluster/netmon.cf file contains the IP names for #### the nodename and bootname of both cluster nodes. #### #### The /.rhosts is configured to permit HACMP to operate correctly. #### #### This script assumes an ethernet network and that all IP addresses #### will exist in the first network discovered by the HACMP #### network discovery, although this can be modified by the user. #### ################################################################# # Define two node names representing each node of the cluster # USER MUST EDIT THIS ARRAY TO CONTAIN DESIRED NODE NAMES NODES=( "nodename01" "nodename02" ) # Service address priority # NOT NECESSARY FOR USER TO EDIT THIS ARRAY SAORD=( "${NODES[0]}" "${NODES[1]}" ) # Resource groups to configure # USER MUST EDIT THIS ARRAY TO CONTAIN DESIRED RESOURCE GROUP NAMES RGS=( abcapmx1 abcapmx2 abcapmx3 defapmx1 defapmx2 ) # Define the Node priority for each resource group listed in the RGS array # USER MUST EDIT THIS ARRAY TO CONTAIN DESIRED NODE PRIORITY # FOR EACH RESOURCE GROUP NAME, HIGHEST PRIORITY NODE FIRST RGORD=( "${NODES[0]} ${NODES[1]}" "${NODES[0]} ${NODES[1]}" "${NODES[0]} ${NODES[1]}" "${NODES[1]} ${NODES[0]}" "${NODES[1]} ${NODES[0]}" ) # Define the application servers for each resource group listed # in the RGS array. One or more application servers may be specified. # USER MUST EDIT THIS ARRAY TO CONTAIN DESIRED APPLICATION SERVER NAMES # FOR EACH RESOURCE GROUP APPLS=( "${RGS[0]}_appl01 ${RGS[0]}_appl02" ${RGS[1]}_appl01 ${RGS[2]}_appl01 ${RGS[3]}_appl01 ${RGS[4]}_appl01 ) # Define the volume groups for each resource group listed # in the RGS array. One or more volume groups may be specified. # USER MUST EDIT THIS ARRAY TO CONTAIN DESIRED VOLUME GROUP NAMES # FOR EACH RESOURCE GROUP VGS=( "${RGS[0]}01vg ${RGS[0]}02vg" ${RGS[1]}01vg ${RGS[2]}01vg ${RGS[3]}01vg ${RGS[4]}01vg ) ################################################################# TRUE="0" FALSE="1" VERBOSE="${TRUE}" DOMAIN="${DOMAIN:-.domain.com}" # User MUST modify this value DD_CL="${DD_CL:-/usr/es/sbin/cluster/utilities}" DD_SS="${DD_SS:-/usr/local/hascripts}" NETWORK="${NETWORK:-net_ether_01}" #### NO MORE USER EDITS ARE REQUIRED OR RECOMMENDED BELOW THIS LINE for IDX in "${!RGS[@]}" do print -- "# " print -- "# RGS[${IDX}] = ${RGS[${IDX}]}" print -- "# RGORD[${IDX}] = ${RGORD[${IDX}]}" print -- "# APPLS[${IDX}] = ${APPLS[${IDX}]}" print -- "# VGS[${IDX}] = ${VGS[${IDX}]}" done print -- "# " # print -- "DD_CL=\"\${DD_CL:-${DD_CL}}\"" # print -- "DD_SS=\"\${DD_SS:-${DD_SS}}\"" # print -- "NETWORK=\"${NETWORK:-${NETWORK}}\"" # print -- "# " ################################################################ COMMADDR="${NODES[@]/%(*)/\1-boot${DOMAIN}}" print -- "# COMMADDR = ${COMMADDR}" # Remove any Existing Cluster: (( VERBOSE == TRUE )) && print -- "\n# Remove existing Cluster: " print -- "${DD_CL}/clrmclstr" # Create Cluster: (( VERBOSE == TRUE )) && print -- "\n# Create Cluster: ${NODES[0]}cl" (( VERBOSE == TRUE )) && print -- "\n# Comm Paths: ${COMMADDR}" print -- "${DD_CL}/clmodclstr -n ${NODES[0]}cl \ -p \"${COMMADDR}\"" ################################################################ # Remove/Create Service Addresses for NODE in "${NODES[@]}" do (( VERBOSE == TRUE )) && print -- "\n# Remove Service Addr: ${NODE}${DOMAIN}" print -- "${DD_CL}/clrmnode -a ${NODE}${DOMAIN}" done for NODE in "${NODES[@]}" do (( VERBOSE == TRUE )) && print -- "\n# Create Service Addr: ${NODE}${DOMAIN}" print -- "${DD_CL}/claddnode -T service -B ${NODE}${DOMAIN} \ -w ${NETWORK}" done ################################################################ # Remove/Create Application Servers for APPL in "${APPLS[@]}" do (( VERBOSE == TRUE )) && print -- "\n# Remove Appl Server: ${APPL}" print -- "${DD_CL}/clrmserv ${APPL}" done for APPL in "${APPLS[@]}" do (( VERBOSE == TRUE )) && print -- "\n# Create Appl Server: ${APPL}" print -- "${DD_CL}/claddserv -s ${APPL} \ -b \"${DD_SS}/${APPL}_start.sh\" \ -e \"${DD_SS}/${APPL}_stop.sh\"" done ################################################################ # Remove/Create persistant addresses for NODE in "${NODES[@]}" do (( VERBOSE == TRUE )) && print -- "\n# Remove Pers Addr: ${NODE}-pers${DOMAIN}" print -- "${DD_CL}/clrmnode -a ${NODE}-pers${DOMAIN}" done for NODE in "${NODES[@]}" do (( VERBOSE == TRUE )) && print -- "\n# Create Pers Addr: ${NODE}-pers${DOMAIN}" print -- "${DD_CL}/claddnode -a ${NODE}-pers${DOMAIN} \ :ether :${NETWORK} : :persistent : : -n ${NODE}" done ################################################################ # Remove/Create resource groups to contain service addresses for IDX in "${!NODES[@]}" do (( VERBOSE == TRUE )) && print -- "\n# Remove Res Group: ${NODES[IDX]}" print -- "${DD_CL}/clrmgrp -g ${NODES[IDX]}" (( VERBOSE == TRUE )) && print -- "\n# Create Res Group: ${NODES[IDX]}" print -- "${DD_CL}/claddgrp -g ${NODES[IDX]} \ -n "${SAORD[IDX]}" \ -S OHN \ -O FNPN \ -B NFB" done ################################################################ # Remove/Create resource groups to contain application servers and VG's for IDX in "${!RGS[@]}" do (( VERBOSE == TRUE )) && print -- "\n# Remove Res Group: ${RGS[IDX]}" print -- "${DD_CL}/clrmgrp -g ${RGS[IDX]}" (( VERBOSE == TRUE )) && print -- "\n# Create Res Group: ${RGS[IDX]}" print -- "${DD_CL}/claddgrp -g ${RGS[IDX]} \ -n "${SAORD[IDX]}" \ -S OHN \ -O FNPN \ -B NFB" done ################################################################ # Add the Service address to the resource group for IDX in "${!NODES[@]}" do (( VERBOSE == TRUE )) && print -- "\n# Add Serv Addr: ${NODES[IDX]}" print -- "${DD_CL}/claddres -g \"${NODES[IDX]}\" \ FALLBACK_AT= \ SERVICE_LABEL=\"${NODES[IDX]}${DOMAIN}\" \ APPLICATIONS= \ VOLUME_GROUP= \ FORCED_VARYON=\"false\" \ VG_AUTO_IMPORT=\"false\" \ FILESYSTEM= \ FSCHECK_TOOL=\"fsck\" \ RECOVERY_METHOD=\"sequential\" \ FS_BEFORE_IPADDR=\"false\" \ EXPORT_FILESYSTEM= \ MOUNT_FILESYSTEM= \ NFS_NETWORK= \ SHARED_TAPE_RESOURCES= \ DISK= \ AIX_FAST_CONNECT_SERVICES= \ COMMUNICATION_LINKS= \ MISC_DATA=" done ################################################################ # Add application servers and volumes to resource groups for IDX in "${!RGS[@]}" do (( VERBOSE == TRUE )) && print -- "\n# Add Appl Server: ${RGS[IDX]}" print -- "${DD_CL}/claddres -g \"${RGS[IDX]}\" \ FALLBACK_AT= \ SERVICE_LABEL=\"${RGS[IDX]}\" \ APPLICATIONS=\"${APPLS[IDX]}\" \ VOLUME_GROUP=\"${VGS[IDX]}\" \ FORCED_VARYON=\"false\" \ VG_AUTO_IMPORT=\"false\" \ FILESYSTEM= \ FSCHECK_TOOL=\"fsck\" \ RECOVERY_METHOD=\"sequential\" \ FS_BEFORE_IPADDR=\"false\" \ EXPORT_FILESYSTEM= \ MOUNT_FILESYSTEM= \ NFS_NETWORK= \ SHARED_TAPE_RESOURCES= \ DISK= \ AIX_FAST_CONNECT_SERVICES= \ COMMUNICATION_LINKS= \ MISC_DATA=" done