Copying configuration from one queue manager to another

How to use the dmpmqcfg tool to store the configuration of a queue manager in an mqsc file, along with using runmqsc to apply this saved configuration to a different queue manager.

Prerequisites

  1. A secure connection to two existing queue managers (for instructions, follow the creating a queue manager guide).
  2. You have permission to access queue managers within your IBM MQ service instance (for instructions, follow the configuring administrator access for a queue manager guide).
    Important: The user performing the following operations should be configured as an administrator of the queue manager as described Configuring administrator access for a queue manager.
  3. An existing installation of IBM® MQ Client on your own machine. (See Administering a queue manager using IBM MQ Explorer and the runmqsc command line for instructions on downloading and installing a client).
  4. Follow the steps to gather credentials and certificates and create a keystore in PKCS12 format for your queue managers, see TLS security for IBM MQ channels in IBM MQ as a Service.

Connecting to your remote queue managers

To connect to your remote queue managers, a few environment variables must first be set. We want to make sure that the MQSERVER value is empty. This can be achieved with the following: unset MQSERVER.

Assign the connection details and certificate gathered previously to MQCCDTURL and MQSSLKEYR:
  • Linux®
    $ export MQCCDTURL=/path/to/file/connection_info_ccdt.json
    export MQSSLKEYR=/path/to/file/key
  • Windows
    $ set  MQCCDTURL=\path\to\file\connection_info_ccdt.json
    set MQSSLKEYR=\path\to\file\key
With these variables set, you can use runmqsc to test that your setup is correct:
$ runmqsc -c -u <username> -w 60 <queue_manager_name>
When prompted, enter your apikey to authenticate, and you will be in the runmqsc console. Simply type quit to exit the mqsc terminal.

dmpmqcfg to generate mqsc file

The dmpmqcfg tool enables a user to create a copy of a queue manager's configuration, and save it to a file. This file has multiple uses, such as a backup to help rebuild a queue manager if the configuration and log data are lost due to hardware failure and the queue manager is unable to restart or to be recovered from the log.

A small selection of optional parameters are needed when using the dmpmqcfg tool. Firstly, make sure that all attributes are copied, this can be assured with the -a field. Second, a client mode connection needs to be forced, which can be achieved with -c. Use standard output redirection to store the definitions into a file. For example:
$ dmpmqcfg -c default -m <queue_manager_1_name> -u <username> -a > /mq/backups/<queue_manager_1_name>.mqsc
When run, you are prompted for the apikey that enables you to connect to these queue managers. When supplied, the configuration file is created in the specified location.

Review users and groups

When you import definitions to another queue manager, the commands fail if they reference a user or group that is not known to that queue manager. You should review the users and groups that the exported configuration depends on, and create the necessary users for the IBM MQ as a Service queue manager before importing the configuration by using runmqsc. For guidance on creating administrative and application users, see Configuring administrator access for a queue manager and Configuring access for connecting an application to a queue manager. When creating an IBM MQ as a Service user, a group is created of the same name that the user belongs to (see Assigning user/group access to a queue). You cannot create other user groups, so any authorities granted to other user groups might need to be converted to user-based authorities for IBM MQ as a Service.

Applying the generated file to a different queue manager

Before applying the configuration to a new queue manager, your apikey needs to be added to the first line of the newly created file. The start of your file should look similar to the following example:
<IBMCloud-apikey>
********************************************
*******************************************************************************
* Script generated on 2022-07-22   at 14.23.16 
* Script generated by user '<user>' on host '<host>' 
* Queue manager name: <queue_manager_1_name> 
* Queue manager platform: UNIX 
* Queue manager command level: (930/922)
* Command issued: dmpmqcfg -c default -m <queue_manager_1_name> -u <username> -a
*******************************************************************************
Note: This is an important step as when running the next command, some of the optional parameters used will not provide a chance to input an apikey, but instead read the first line of the specified file.
With the apikey added to the configuration file, it can now be applied to other queue managers. Using runmqsc, the optional parameter -f <filename> the input can be processed from the .mqsc file created in the previous task. The optional parameter -c must be used to ensure a client connection. The queue manager this configuration is being applied to must also be provided, for example:
runmqsc -f /mq/backups/<queue_manager_1_name>.mqsc -c -u <username> <queue_manager_2_name>
This command reads the file created in the previous step and processes every command. After successful completion, the settings of the second queue manager match the settings of the first queue manager.

Conclusion

You have successfully:

  • Created a configuration backup of a queue manager
  • Applied a backup of a queue manager's configuration to a new queue manager.