IBM® WebSphere® MQ V7 can increase messaging availability out-of-the-box without specialized skills or hardware. In the event of an unplanned outage, it provides automatic failover via multi-instance queue managers, and you can initiate planned outages such as to apply software maintenance via controlled switchovers.
Messages and data for multi-instance queue managers are held on networked storage accessed via a modern network file system protocol,such as Network File System (NFS) V4. You can define and start multiple instances of the queue manager on different machines, with one active and one standby instance. The active queue manager instance processes messages and accepts connections from applications and from other queue managers. It holds a lock on the queue manager data to ensure that there is only one active instance of the queue manager. The standby queue manager instance periodically checks whether the active queue manager instance is still running. If the active queue manager instance fails or is no longer connected, the standby instance acquires the lock on the queue manager data as soon as it is released, performs queue manager restart processing, and becomes the active queue manager instance.
- Set up Websphere MQ V7 according to the guidelines and instructions in the information center. For details, see Creating a multi-instance queue manager on Linux.
- Use two machines both running Linux RHEL 5 OS.
- Install Websphere MQ V7.0.1.0) on both machines.
- Run the File System Check tool (amqmfsck ) to verify that the file system is compliant with POSIX standards and capable of sharing queue manager data to support multi-instance queue managers.
- Before running the File System Check tool, create new directories on both machines and start the NFS server on Server 1:
- Create a directory HA under root.
- Create another directory mqdata under HA.
- Add the following user and group ownership to the HA directory recursively:
chown -R mqm:mqm /HA. - Add the following permissions to the HA directory recursively:
chmod -R ug+rwx /HA.
- Use the following command to check whether NFS is on:
chkconfig --list nfs For example: [root@lins shared]# chkconfig --list nfs nfs 0:off 1:off 2:off 3:off 4:off 5:off 6:off
- If Fields 2, 3, 4, and 5 are off in the above output, then it means that NFS is turned off and you need to turn it on:
chkconfig nfs on. - To verify whether NFS is on:
[root@lins shared]# chkconfig --list nfs nfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
- To export mount point (/HA) to another node:
Add /HA *(rw,sync,no_wdelay,fsid=0) to /etc/exports Start the NFS daemon on Server 1. /etc/init.d/nfs start For example: root@lins shared]# /etc/init.d/nfs start Starting NFS services: [ OK ] Starting NFS quotas: [ OK ] Starting NFS daemon: [ OK ] Starting NFS mountd: [ OK ]
- To verify the mount point that is being exported from this server to another server, use the following command:
showmount -e For example: [root@lins shared]# showmount -e Export list for lins.in.ibm.com: /HA *
- To mount the exported file system on Server 2, find the IP address of Server 1 by using the command ifconfig a on Server 1.
- Mount the file system as NFS4 from Server 1 to Server 2:
mount -t nfs4 -o hard,intr 9.122.163.105:/ /HA. - Run the command
mount vto check whether the NFS mount was successful:For example: [root@gtstress42 ~]# mount -v /dev/sdb2 on /testpool type ext3 (rw) /dev/sda5 on /usr type ext3 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) 9.122.163.105:/ on /HA type nfs4 (rw,hard,intr,addr=9.122.163.105)
Running the WebSphere MQ File System Check tool
- Change the login to mqtest on both machines to run the amqmfsck tool:
su - mqtest export PATH=/opt/mqm/bin:$PATH amqmfsck /HA/mqdata For example: Server 1: [mqst@lins root]$ amqmfsck /HA/mqdata The tests on the directory completed successfully. Server 2: [mqst@gtstress42 /]$ amqmfsck /HA/mqdata The tests on the directory completed successfully. amqmfsck -c /HA/mqdata For example: Server 1: [mqst@lins root]$ amqmfsck -c /HA/mqdata Start a second copy of this program with the same parameters on another server. Writing to test file. This will normally complete within about 60 seconds... The tests on the directory completed successfully. For example: Server 2: [mqst@gtstress42 /]$ amqmfsck -c /HA/mqdata Writing to test file. This will normally complete within about 60 seconds.. The tests on the directly completed successfully amqmfsck -wv /HA/mqdata (Run this command at the same time on the machines) For example: Server 1: [mqst@lins root]$ amqmfsck -wv /HA/mqdata System call: stat("/HA/mqdata",&statbuf) System call: fd = open("/HA/mqdata/amqmfsck.lkw",O_RDWR,0666) System call: fchmod(fd,0666) System call: fstat(fd,&statbuf) System call: fcntl(fd,F_SETLK,F_WRLCK) Start a second copy of this program with the same parameters on another server. File lock acquired. Press Enter or terminate this process to release the lock. System call: close(fd) File lock released. The tests on the directory completed successfully. For example: Server 2 : [mqst@gtstress42 /]$ amqmfsck -wv /HA/mqdata System call: stat("/HA/mqdata",&statbuf) System call: fd =open("/HA/mqdata/amqmfsck.lkw",O_RDWR,0666) System call: fchmod(fd,0666) System call: fstat(fd,&statbuf) System call: fcntl(fd,F_SETLK,F_WRLCK) Waiting for the file lock. System call: fcntl(fd,F_SETLK,F_WRLCK) Waiting for the file lock. System call: fcntl(fd,F_SETLK,F_WRLCK) Waiting for the file lock. System call: fcntl(fd,F_SETLK,F_WRLCK) Waiting for the file lock. System call: fcntl(fd,F_SETLK,F_WRLCK) Waiting for the file lock. System call: fcntl(fd,F_SETLK,F_WRLCK) Waiting for the file lock. System call: fcntl(fd,F_SETLK,F_WRLCK) File lock acquired. Press Enter or terminate this process to release the lock. System call: close(fd) File lock released. The tests on the directory completed successfully - After verifying the file system for file locking, you can create a multi instance queue manager on the selected machine:
- On Server 1:
cd HA mkdir logs mkdir qmgrs chown -R mqm:mqm /HA chmod -R ug+rwx /HA crtmqm -ld /HA/logs -md /HA/qmgrs -q QM1
- Copy the queue manager details from Server 1 to Server 2:
dspmqinf -o command QM1 (Run this command on Server 1) For example: addmqinf -s QueueManager -v Name=QM1 -v Directory=QM1 -v Prefix=/var/mqm -v DataPath=/HA/qmgrs/QM1

- Start the active instance of the queue manager on Server 1. Copy the output below and run it on Server 2:
strmqm -x QM1 For example: [mqst@lins HA]$ strmqm -x QM1 WebSphere MQ queue manager 'QM1' starting. 5 log records accessed on queue manager 'QM1' during the log replay phase. Log replay for queue manager 'QM1' complete. Transaction manager state recovered for queue manager 'QM1'. WebSphere MQ queue manager 'QM1' started. [mqst@lins HA]$ dspmq QMNAME(QM1) STATUS(Running) [mqst@lins HA]$ dspmq -x -o standby QMNAME(QM1) STANDBY(Permitted) INSTANCE(lins.in.ibm.com) MODE(Active) INSTANCE(gtstress42.in.ibm.com) MODE(Standby) Server 2: [mqst@gtstress42 /]$ strmqm -x QM1 WebSphere MQ queue manager 'QM1' starting. A standby instance of queue manager 'QM1' has been started. The active instance is running elsewhere. [mqst@gtstress42 /]$ dspmq QMNAME(QM1) STATUS(Running as standby) [mqst@gtstress42 /]$ dspmq -x -o standby QMNAME(QM1) STANDBY(Permitted) INSTANCE(lins.in.ibm.com) MODE(Active) INSTANCE(gtstress42.in.ibm.com) MODE(Standby)
- To completely stop a multi-instance queue manager, issue a normal endmqm command on the active instance on Server 1:
endmqm -i QM1 WebSphere MQ queue manager 'QM1' ended. Both instances end
- To stop just the standby instance on Server 2, use this command:
endmqm -x QM1 WebSphere MQ standby queue manager instance 'QM1' ended.

- To switch servers from active to standby, on machine A, enter:
endmqm -is QM1 WebSphere MQ queue manager 'QM1' ended, permitting switchover to a standby instance.Once the active instance has ended, the standby instance will try to become the active instance:Server 1: [mqst@lins HA]$ endmqm -is QM1 WebSphere MQ queue manager 'QM1' ending. WebSphere MQ queue manager 'QM1' ended, permitting switchover to a standby instance. [mqst@lins HA]$ dspmq QMNAME(QM1) STATUS(Running elsewhere) Server 2: [mqst@gtstress42 /]$ dspmq QMNAME(QM1) STATUS(Running)

Checking and creating users and groups
- The UID and GID of mqm and mqtest must be the same on both machines before installing WebSphere MQ. If they are different on the two nodes, change them to be the same and reboot the machine
to reflect the changes. Here are the steps to change the UID and GID of mqm and mqmtestr:
- For example, if UID and GID of mqm are 501 on Server 1, then you need to set the UID and GID of mqm on Server 2 to 501:
groupmod -g 501 mqm usermod -u 501 -g 501 mqm
- Reboot Server 2 to reflect the changes.
- The same step applies to mqtest, and mqtest needs to be a part of mqm group.
- To create new mqm and mqtest ids on a system, use the commands below:
groupadd -g <GID> mqm useradd -u <UID> mqm -g mqm useradd -u <UID> mqtest -g mqm
- For example, if UID and GID of mqm are 501 on Server 1, then you need to set the UID and GID of mqm on Server 2 to 501:
- To check that the ids have been created correctly on both machines, use the commands below:
id mqm For example: Server 1: uid=501(mqm) gid=501(mqm) groups=501(mqm) Server 2: uid=501(mqm) gid=501(mqm) groups=501(mqm) id mqtest For example: Server 1: uid=550(mqtest) gid=501(mqm) groups=501(mqm) Server 2: uid=550(mqtest) gid=501(mqm) groups=501(mqm)
The author would like to thank Ummahesh Ponnuswamy of IBM Software Group and Swetha Vb Prabhakar of IBM Global Business Services for their help with this article.
- Red Hat Linux 9 Reference Guide
Online documentation from Red Hat - WebSphere MQ V7 information center
A single Web portal to all WebSphere MQ V7 documentation, with conceptual, task, and reference information on installing, configuring, and using WebSphere MQ V7. - WebSphere MQ documentation library
WebSphere MQ product manuals. - WebSphere MQ developer resources page
Technical resources to help you design, develop, and deploy messaging middleware with WebSphere MQ to integrate applications, Web services, and transactions on almost any platform. - WebSphere MQ product page
Product descriptions, product news, training information, support information, and more. - IBM Redbook: WebSphere MQ V7 features and enhancements
Describes the fundamental concepts and benefits of message queuing technology, describes the new features in V7, and provides a business scenario that shows those features in action. - Download a free trial version of WebSphere MQ V7
A 90-day, full featured, no-charge trial of WebSphere MQ V7 - WebSphere MQ support page
A searchable database of support problems and their solutions, plus downloads, fixes, problem tracking, and more. - WebSphere MQ public newsgroup
A non-IBM forum where you can get answers to your WebSphere MQ technical questions and share your WebSphere MQ knowledge with other users. - WebSphere MQ SupportPacs
Downloadable code, documentation, and performance reports for the WebSphere MQ family of products. - developerWorks WebSphere developer resources
Technical information and resources for developers who use WebSphere products. developerWorks WebSphere provides product downloads, how-to information, support resources, and a free technical library of more than 2000 technical articles, tutorials, best practices, IBM Redbooks, and online product manuals. - developerWorks WebSphere application connectivity developer resources
How-to articles, downloads, tutorials, education, product info, and other resources to help you build WebSphere application connectivity and business integration solutions. - Most popular WebSphere trial downloads
No-charge trial downloads for key WebSphere products. - WebSphere forums
Product-specific forums where you can get answers to your technical questions and share your expertise with other WebSphere users. - WebSphere on-demand demos
Download, watch, and learn what WebSphere products and WebSphere-related technologies can do for your company. - developerWorks WebSphere weekly newsletter
The developerWorks newsletter gives you the latest articles and information only on those topics that interest you. In addition to WebSphere, you can select from Java, Linux, Open source, Rational, SOA, Web services, and other topics. Subscribe now and design your custom mailing. - WebSphere-related books from IBM Press
Convenient online ordering through Barnes & Noble. - WebSphere-related events
Conferences, trade shows, Webcasts, and other events around the world of interest to WebSphere developers. - developerWorks blogs
Join a conversation with developerWorks users and authors, and IBM editors and developers. - developerWorks Webcasts
Free technical sessions by IBM experts that can accelerate your learning curve and help you succeed in your most difficult software projects. Sessions range from one-hour Webcasts to half-day and full-day live sessions in cities worldwide. - developerWorks podcasts
Listen to interesting and offbeat interviews and discussions with software innovators. - developerWorks on Twitter
Check out recent Twitter messages and URLs.
Chaitra Sampige is a Software Engineer on the Websphere MQ Test Team at the IBM India Software Lab in Bangalore. She has three years of testing experience with the Websphere MQ Test Team and she also handles TXSeries and interoperability testing. She is a certified CSTE and she has a Bachelor of Engineering degree in Information Science from Viswesvaraya Technological University in India. You can contact Chaitra at csampige@in.ibm.com.




