PreambleAs of MQ 9.1.0, MQ supports a pricing model around Hourly Virtual Processor Cores (VPC). This new pricing option additionally allows customers to pay for the number of CPU cores available to individual containers that queue managers are running under, rather than having to license based on the total available cores on the host system.
In this blog I'll take your though the basics around setting up a queue manager in a Docker container, running on a Linux (Ubuntu) host, to report metering statistics to the IBM Cloud Private (ICP) metering service. I'll assume at this point you have ICP with the metering capabilities already configured, and a Linux system with Docker/git etc all installed.
Creating an MQ Docker image
- Clone the âmq-containerâ github docker files using the 9.1.0 branch:
git clone -b 9.1.0 https://github.com/ibm-messaging/mq-container mq-container
- Copy the MQ 9.1.1 Debian e-image (available on Passport Advantage) under a new âdownloadsâ directory under mq-container directory
mkdir mq-container/downloads cp mq-188.8.131.52-e-image.tar.gz mq-container/downloads/
(Alternatively use the IBM MQ for developers Ubuntu version of the product if you are just trying this out and dont have access to the paid for Passport Advantage version)
- Build the MQ 9.1.1 Docker image
cd mq-container; MQ_ARCHIVE=mq-184.108.40.206-e-image.tar.gz MQ_VERSION=220.127.116.11 make build-advancedserver
At this point you should have the an IBM MQ docker image to create your containers from:
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE mqadvanced-server 18.104.22.168-x86_64-ubuntu-16.04 f9275dd6d6a4 About an hour ago 620MB mq-golang-sdk 22.214.171.124-x86_64-ubuntu-16.04 0bd3be6651fa About an hour ago 632MB mq-sdk 126.96.36.199-x86_64-ubuntu-16.04 52dd82f903e0 About an hour ago 383MB ubuntu 16.04 7e87e2b3bf7a 6 days ago 117MB
For more/latest information on building MQ Docker images see: https://github.com/ibm-messaging/mq-container/blob/master/docs/building.md
Creating a MQ Docker container and configuring for Hourly ICP metering
- Run a container using the docker image created above for your queue manager to lay down the queue managerâs initial file system structure:
docker run --add-host mycluster.icp:âICP_ip_addressâ --cpus="number of CPUsâ --env LICENSE=accept --env MQ_QMGR_NAME=QM1 --volume /var/example:/mnt/mqm --publish 1414:1414 --detach mqadvanced-server:188.8.131.52-x86_64-ubuntu-16.04
Important things to node here are the --add-host used to resolve the hostname we'll define in our qm.ini below, the --cpus used to restrict the number of CPUs the container has access to and as such the number of VPCs we'll report to the ICP metering service.
Note: CPUs can be a fraction of a CPU.
By starting a fresh container as above the qmgr data structure will be laid down under /var/example/data/qmgrs/QM1 on the host system.
- Add the ICP CA certificate into the queue managers keystore for MQ to validate certificates presented to it from the metering service upon connection:
runmqckm -keydb -create -db /var/example/data/qmgrs/QM1/ssl/key.kdb âpw password -type cms -expire 365 âstash runmqckm -cert -add -db /var/example/data/qmgrs/QM1/ssl/key.kdb -pw password -type cms -label ICPCACert -file metering_certificate_ca_file -format ascii -trust enable
- Create an API Key file containing the metering service's API Key (in the host system's /var/example/data/apikey.txt location in the example below)
- Add the âReportingServiceâ stanza fields into the /var/example/data/qmgrs/QM1/qm.ini for this qmgr:
ReportingService: ServiceURL=https://mycluster.icp:8443 # Location of the ICP Metering service host and port APIKeyFile=/var/mqm/apikey.txt # Location of the ICP Metering API Key (relative to the docker container) CapacityReporting=yes # (optional) Report metering stats to the qmgr diagnostic logs (AMQERR01.LOG etc) LicensingGroup=DEPT-TL # (optional) Metering group to report under (default: 'DefaultLicensingGroup')
This will enable reporting of metering data to the ICP metering service.
- Restart your docker container to pick up the qm.ini changes, ICP certificate and API Key
- The queue manager will report in its diagnostic logs it has successfully connected to the configured ICP metering service and started sending metering data to it. If errors are reported in the queue manager diagnostic logs confirm you have added the correct certificate, API Key and a contactable ServiceURL by the docker container.
AMQ5058I: The queue manager has been registered with an instance of the reporting service.
- If you have optionally added the 'CapacityReporting=yes' option to your qm.ini file you'll also get periodic messages such as:
AMQ5064I: The queue manager has been running for 1 seconds. It is currently running with 1.00 cores. License type is 'IBM MQ Advanced'.