If 'mqconfig' indicates that any of the requirements have not been met,
consult the installation section within the WebSphere MQ Information Center
for details about how to configure the system and user limits.
然后根据提示,执行命令去检查环境是否允许
第一次检查,提示缺少bc
[root@236 mq]# su mqm -c "/opt/mqm/bin/mqconfig"
mqconfig: Analyzing CentOS Linux release 7.4.1708 (Core) settings for
WebSphere MQ V7.5
mqconfig: The bc program was not found on this system. Please install bc
and try running mqconfig again.
安装bc
[root@236 mq]# yum install -y bc
第二次检查
有几个fail的需要解决,参考文档:https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_9.0.0/com.ibm.mq.ins.doc/q008550_.htm
修改内核参数
编辑/sysctl.conf ,添加下列配置
[root@236 mq]# vim /etc/sysctl.conf
kernel.sem = 500 256000 250 1024
net.ipv4.tcp_keepalive_time = 300
fs.file-max = 524288
写入配置
[root@236 mq]# sysctl -p
第三次检查
还剩2个文件相关的需要解决
编辑limit.conf
[root@236 mq]# vim /etc/security/limits.conf
添加两行
mqm hard nofile 10240
mqm soft nofile 10240
第四次检查通过
修改环境变量
由于mq默认安装在/opt/mqm目录,所以安装完成后会找不到mq相关命令,需要配置环境变量才能找到
vim /etc/profile #添加下面一行
PATH=/opt/mqm/bin:/opt/mqm/samp/bin/:$PATH
安装完成
2、启动实例
切换到mqm用户启动
[root@236 mq]# su mqm
bash-4.2$
创建默认实例
bash-4.2$ crtmqm -q oe
WebSphere MQ queue manager created.
Directory '/var/mqm/qmgrs/oe' created.
The queue manager is associated with installation 'Installation1'.
Creating or replacing default objects for queue manager 'oe'.
Default objects statistics : 74 created. 0 replaced. 0 failed.
Completing setup.
Setup completed.
查看实例,这里状态是ended的
bash-4.2$ dspmq
QMNAME(oe) STATUS(Ended immediately)
启动实例
bash-4.2$ strmqm oe
WebSphere MQ queue manager 'oe' starting.
The queue manager is associated with installation 'Installation1'.
5 log records accessed on queue manager 'oe' during the log replay phase.
Log replay for queue manager 'oe' complete.
Transaction manager state recovered for queue manager 'oe'.
WebSphere MQ queue manager 'oe' started using V7.5.0.2.
创建队列一个名为test的队列
bash-4.2$ runmqsc oe #进入队列
5724-H72 (C) Copyright IBM Corp. 1994, 2011. ALL RIGHTS RESERVED.
Starting MQSC for queue manager oe.
define qlocal(test) #定义队列test
1 : define qlocal(test)
AMQ8006: WebSphere MQ queue created.
end
2 : end #退出
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
发送消息测试,报错2085
bash-4.2$ amqsput Test oe
Sample AMQSPUT0 start
target queue is Test
MQOPEN ended with reason code 2085
unable to open queue for output
Sample AMQSPUT0 end
后来查找问题发现这个队列不能为小写的,test队列被转换成大写的了,建议队列名设置为大写的,重新发送消息测试,连续敲两下回车表示输入完成
bash-4.2$ amqsput TEST oe
Sample AMQSPUT0 start
target queue is TEST
hello world!
Sample AMQSPUT0 end
接收消息,接受成功
bash-4.2$ amqsget TEST oe
Sample AMQSGET0 start
message <hello world!>
启动端口监听
bash-4.2$ runmqlsr -t tcp -p 2424 -m oe &
[1] 5067
bash-4.2$ 5724-H72 (C) Copyright IBM Corp. 1994, 2011. ALL RIGHTS RESERVED.
启动成功