Example shell scripts for starting an HA cluster queue manager on UNIX and Linux
The queue manager is represented in the HA cluster as a resource. The HA cluster must be able to start and stop the queue manager. In most cases we can use a shell script to start the queue manager. We must make these scripts available at the same location on all nodes in the cluster, either using a network filesystem or by copying them to each of the local disks.
Note: Before you restart a failed queue manager, we must disconnect the applications from that instance of the queue manager. If we do not, the queue manager might not restart correctly.Examples of suitable shell scripts are given here. We can tailor these to your needs and use them to start the queue manager under the control of our HA cluster.
The following shell script is an example of how to switch from the HA cluster user to the mqm user so that the queue manager can be successfully started:
#!/bin/ksh # A simple wrapper script to switch to the mqm user. su mqm -c name_of_your_script $*
The following shell script is an example of how to start a queue manager without making any assumptions about the current state of the queue manager. Note that it uses an extremely abrupt method of ending any processes that belong to the queue manager:
#!/bin/ksh # # This script robustly starts the queue manager. # # The script must be run by the mqm user. # The only argument is the queue manager name. Save it as QM variable QM=$1 if [ -z "$QM" ] then echo "ERROR! No queue manager name supplied" exit 1 fi # End any queue manager processes which might be running. srchstr="( |-m)$QM *.*$" for process in amqzmuc0 amqzxma0 amqfcxba amqfqpub amqpcsea amqzlaa0 \ amqzlsa0 runmqchi runmqlsr amqcrsta amqrrmfa amqrmppa \ amqzfuma amqzmuf0 amqzmur0 amqzmgr0 do ps -ef | tr "\t" " " | grep $process | grep -v grep | \ egrep "$srchstr" | awk '{print $2}'| \ xargs kill -9 > /dev/null 2>&1 done # It is now safe to start the queue manager. # The strmqm command does not use the -x flag. strmqm ${QM}
We can modify the script to start other related programs.
Parent topic: HA clusters on UNIX and Linux