Configure Db2
Db2® support and configuration information.
The supported levels of Db2 are defined at the System Requirements for IBM MQ page.
Note: 32-bit instances of Db2 are not supported on platforms where the queue manager is 64-bit. Do the following:- Check the environment variable settings.
- Create the Db2 switch load file.
- Add resource manager configuration information.
- Change Db2 configuration parameters if necessary.
Checking the Db2 environment variable settings
Ensure that your Db2 environment variables are set for queue manager processes as well as in our application processes. In particular, you must always set the Db2INSTANCE environment variable before you start the queue manager. The DB2INSTANCE environment variable identifies the Db2 instance containing the Db2 databases that are being updated. For example:- On UNIX and Linux systems, use:
export DB2INSTANCE=db2inst1
- On Windows systems, use:
set DB2INSTANCE=Db2
On Windows with a Db2 database, you must add the user MUSR_MQADMIN to the DB2USERS group, to enable the queue manager to start.
Creating the Db2 switch load file
The easiest way to create the Db2 switch load file is to use the sample file xaswit.mak, which IBM MQ provides to build the switch load files for a variety of database products.
On Windows systems, we can find xaswit.mak in the directory MQ_INSTALLATION_PATH\tools\c\samples\xatm. MQ_INSTALLATION_PATH represents the high-level directory in which IBM MQ is installed. To create the Db2 switch load file with Microsoft Visual C++, use:nmake /f xaswit.mak db2swit.dllThe generated switch file is placed in C:\Program Files\IBM\MQ\exits.
We can find xaswit.mak in the directory MQ_INSTALLATION_PATH/samp/xatm. MQ_INSTALLATION_PATH represents the high-level directory in which IBM MQ is installed.
Edit xaswit.mak to uncomment the lines appropriate to the version of Db2 you are using. Then execute the makefile using the command:make -f xaswit.mak db2swit
The generated 32-bit switch load file is placed in /var/mqm/exits.
The generated 64-bit switch load file is placed in /var/mqm/exits64.
Add resource manager configuration information for Db2
You must modify the configuration information for the queue manager to declare Db2 as a participant in global units of work. Modifying configuration information in this way is described in more details in Add configuration information to the queue manager.- On Windows and Linux (x86 and x86-64 platforms) systems, use the IBM MQ Explorer. Specify the details of the switch load file in the queue manager properties panel, under XA resource manager.
- On all other systems specify the details of the switch load file in the XAResourceManager stanza in the queue manager's qm.ini file.
XAResourceManager: Name=mydb2 SwitchFile=db2swit XAOpenString=mydbname,myuser,mypasswd,toc=t ThreadOfControl=THREAD
- ThreadOfControl=THREAD cannot be used with Db2 versions earlier than version 8. Set
ThreadOfControl and the XAOpenString parameter toc to one of the
following combinations:
- ThreadOfControl=THREAD and toc=t
- ThreadOfControl=PROCESS and toc=p
If you are using the jdbcdb2 XA switch load file to enable JDBC/JTA coordination, you must use ThreadOfControl=PROCESS and toc=p.
Change Db2 configuration parameters
For each Db2 database that the queue manager is coordinating, you must set database privileges, change the tp_mon_name parameter, and reset the maxappls parameter. To do this, perform the following steps:
- Set database privileges
- The queue manager processes run with effective user and group mqm on UNIX and Linux systems. On Windows systems, they run as the user that started the queue
manager. This can be one of:
- The user who issued the strmqm command, or
- The user under which the IBM MQ Service COM server runs
If we have not specified a user name and password on the xa_open string, the user under which the queue manager is running is used by Db2 to authenticate the xa_open call. If this user (for example, user mqm on UNIX and Linux systems) does not have minimal privileges in the database, the database refuses to authenticate the xa_open call.
The same considerations apply to our application process. If we have not specified a user name and password on the xa_open string, the user under which our application is running is used by Db2 to authenticate the xa_open call that is made during the first MQBEGIN. Again, this user must have minimal privileges in the database for this to work.
For example, give the mqm user connect authority in the mydbname database by issuing the following Db2 commands:db2 connect to mydbname db2 grant connect on database to user mqm
- Change the TP_MON_NAME parameter
- For Db2 on Windows systems only, change the TP_MON_NAME configuration
parameter to name the DLL that Db2 uses to call the
queue manager for dynamic registration.
Use the command db2 update dbm cfg using TP_MON_NAME mqmax to name MQMAX.DLL as the library that Db2 uses to call the queue manager. This must be present in a directory within PATH.
- Reset the maxappls parameter
- You might need to review your setting for the maxappls parameter, which limits the maximum number of applications that can be connected to a database. Refer to Install and configuring the database product.