本文介绍了DB2 + IBM MQ; enable_MQFunctions =错误-连接数据库时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我构建包含IBM MQ 9.1,DB2express-c 9.7 + ubuntu 16.04 64bit的docker映像。

我想在我的Db2数据库上启用MQ函数(将msg发送到队列中)。

但是当我使用 enable_MQFunctions 时,我得到了以下错误:

I build docker's image containing IBM MQ 9.1, DB2express-c 9.7 + ubuntu 16.04 64bit.
I want to enable MQ functions(sending msg to queue) on my Db2 database.
But when I used enable_MQFunctions than I got this error:

来证明这一点。在您运行 enable_MQFunctions 之前,该帐户的code>条目。

I suspect that the cause of your symptom is that the account specified for enable_MQFunctions command line does not have a password at the time that enable_MQFunctions tries to run. You can prove this by looking at db2diag.log to see the exact authentication failure message, and/or by looking at the /etc/passwd entry for that account just before you run enable_MQFunctions.

您可以展开 Dockerfile 完全在 docker构建期间配置MQ的Db2,而不是在 docker run 或入口点。这样,您将负责Dockerfile中的所有步骤,并且在 docker run 命令后无需手动干预即可重复执行。这也意味着您将使用所有必需的配置来预烘焙构建的映像,然后将其持久化。您需要具有足够的Dockerfile脚本编写能力,才能获得理想的结果。

You can expand the Dockerfile to configure the Db2 for MQ entirely during the docker build instead of running those steps after docker run or in entrypoints. That way you are responsible for all the steps inside the Dockerfile and it will be repeatable without manual intervention after the docker run command. It also means that your built image is pre-baked with all of the required configuration which will then be persistent. You need to have enough competence with scripting in the Dockerfile to get the desired outcome.

正确完成后,enable_MQFunctions将在 docker build 期间正常运行,因此,如果遇到错误,是因为您

When correctly done, the enable_MQFunctions will operate properly during docker build, so if you are getting errors it's because you are doing it incorrectly.

我可以成功配置数据库并在Dockerfile内全部运行 enable_MQFunctions ,这些步骤下面的内容(因为使用了非root用户安装的Db2),因此所有配置都已在生成的映像中。

I can successfully configure the database and run enable_MQFunctions all inside the Dockerfile, with these steps below (because of using a non-root install of Db2), so all the configuration is already in the built image.


  • 在安装Db2之后且在db2start之前,Dockerfile应该
    创建 / home / db2inst1 / sqllib / userprofile (只要实例所有者在 .bash_profile 中点入点,它将运行$ c>或 .profile ),以执行以下步骤:

  • after installing Db2 and before db2start the Dockerfile shouldcreate /home/db2inst1/sqllib/userprofile (which will run whenever the instance-owner accounts dots in its db2profile from .bash_profile or .profile), to do these steps:

-附加 / opt / mqm / lib64 到 LD_LIBRARY_PATH

-导出AMT_DATA_PATH = / opt / mqm

-前置 / opt / mqm / bin 在 PATH

chown db2inst1:db2iadm1 / home / db2inst1 / sqllib / userprofile

在安装Db2之后且在 db2start 之前, Dockerfile应该运行以下步骤:

after installing Db2 and before db2start, the Dockerfile should run these steps:

- db2set DB2COMM = TCPIP

- db2set DB2ENVLIST = AMT_DATA_PATH

- db2 -v使用联合的yes立即更新dbm cfg

设置密码Dockerfile中db2inst1帐户的单词

set a password for db2inst1 account in the Dockerfile

然后Dockerfile可以运行 db2start ,创建数据库(称它为样本,您可以随意命名)并以db2inst1用户身份运行以下片段,以首先在MQ函数使用的数据库中创建所需的对象:

the Dockerfile can then run db2start, create the database ( i call it sample, you can call it whatever you like) and run the fragment below as user db2inst1 to first create the required objects in the database used by the MQ functions:

su -db2inst1 -c(db2 -v连接到样本; \
db2 -tvf /home/db2inst1/sqllib/cfg/mq/amtsetup.sql; \
db2 -v模式DB2MQ的列表表; \
出口0)

请注意,您必须运行 amtsetup.sql 显式退出0,因为 amtsetup.sql 即使成功完成也总是返回非零的退出代码。 docker build 在这种情况下继续。

Notice that you have to run amtsetup.sql in a subshell ,as shown, to explicitly exit 0, because amtsetup.sql always returns non-zero exit code even when it completes successfully. So you want the docker build to continue in that case.

如果以上所有步骤均已成功完成并且MQ已成功安装,稍后在 Dockerfile 中,可以运行 enable_MQFunctions 如下:

If all the above steps completed successfully and MQ is already successfully installed, later in the Dockerfile you can run the enable_MQFunctions as follows:

我使用ARG INSTANCE_PASSWORD指定db2inst1密码,该密码可以来自外部。

su-db2inst1 -c(。./.profile; \
db2start; \
db2 -v激活数据库样本; \
cd / home / db2inst1 / sqllib / cfg; \
/ home / db2inst1 / sqllib / bin / enable_MQFunctions -echo -force -n sample -u db2i nst1 -p $ INSTANCE_PASSWORD; b
db2stop力; \
出口0)

这篇关于DB2 + IBM MQ; enable_MQFunctions =错误-连接数据库时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 14:27