Configuring Db2
Db2® support and configuration information.
The supported levels of Db2 are defined at the System Requirements for IBM® MQ page.
- Check the environment variable settings.
- Create the Db2 switch load file.
- Add resource manager configuration information.
- Change Db2 configuration parameters if necessary.
db2profile on AIX® and Linux® platforms, the environment variable LIBPATH and
LD_LIBRARY_PATH are set. It is advisable to unset these environment variables. See
crtmqenv or setmqenv for more information. Checking the Db2 environment variable settings
- On AIX 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, you 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.dll
The generated switch file is placed in
C:\Program Files\IBM\MQ\exits.
![[UNIX]](ngunix.gif)
You can find xaswit.mak in the directory
MQ_INSTALLATION_PATH/samp/xatm, where MQ_INSTALLATION_PATH is the high-level directory in which IBM MQ is installed.
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 64-bit switch load file is placed in /var/mqm/exits64.
make -f xaswit.mak db2swit64
Adding resource manager configuration information for Db2
- 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.
mydbname, this name being specified in the XAOpenString:XAResourceManager:
Name=mydb2
SwitchFile=db2swit
XAOpenString=mydbname,myuser,mypasswd,toc=t
ThreadOfControl=THREAD
ThreadOfControl=THREADcannot be used with Db2 versions earlier than 8. SetThreadOfControland the XAOpenString parametertocto one of the following combinations:ThreadOfControl=THREADandtoc=tThreadOfControl=PROCESSandtoc=p
If you are using the jdbcdb2 XA switch load file to enable JDBC/JTA coordination, you must use
ThreadOfControl=PROCESSandtoc=p.
Changing Db2 configuration parameters
- Set database privileges
- The queue manager processes run with effective user and group mqm on AIX 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 you 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 AIX 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 your application process. If you have not specified a user name and password on the xa_open string, the user under which your 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 mqmaxto 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 Installing and configuring the database product.