MQ6.0操作手册

MQ6.0操作手册
                      
MQ6.0的安装
本次试验是在Fedora Core 4.0虚拟机下,是首次安装MQ.
安装的MQ软件包为WMQv600Trial-x86_linux_2.tar.gz.
安装要求是需要jdk-1.4.2的支持.这里的WMQv600Trial-x86_linux_2.tar.gz.软件包自带了jdk-1.4.2. 下面进入安装:
 
我将WMQv600Trial-x86_linux_2.tar.gz放在目录: /usr/local/mq/里.
(1)进目录:cd /usr/local/mq/
(2)解压: tar  zxvf  WMQv600Trial-x86_linux_2.tar.gz
(3)执行脚本:  ./mqlicense.sh –accept 这个脚本是要安装ÊWebSphere MQ 软件包的MQ许可程序. 至关重要,这个脚本没有正确配置的话将导致MQ安装失败.针对FC4系统,我对mqlicense.sh的配置如下:
mqlicense.sh脚本中有个JRE=${JRE:-$(find $PROGPATH/lap -type d -name bin)/java }字段. 将其改为JRE=/opt/IBMJava2-142/jre/bin/java
注意:这里的JRE路径可以是你系统本身JDK的路径,我采用的是MQ6.0自带的jdk-1.4.2版本. 默认路径为/opt/IBMJava2-142/jre/bin/java
 
将mqlicense.sh脚本中的
LAPCLASSPATH=${PROGPATH?}/lap/${LAP_JAR}:${PROGPATH?}/lap/jre/lib/rt.jar:${PROGPATH?}/lap/jre/lib/i18n.jar
字段改为
LAPCLASSPATH=${PROGPATH?}/lap/${LAP_JAR}:/opt/IBMJava2-142/lib/rt.jar:${PROGPATH?}/lap/jre/lib/i18n.jar
注:这里只是将第一个冒号和第二个冒号之间的作以修改.
/opt/IBMJava2-142/lib/rt.jar是MQ6.0自带的默认路径.
 
另外./mqlicense.sh –accept 是不启动图形直接接受许可(4) 安装 WebSphere MQ for Linux 服务器(Runtime、SDK 和ÍServer 软件包):ü 
[root@localhost mq]# rpm -U MQSeriesRuntime-6.0.0-0.i386.rpm
[root@localhost mq]# rpm -U MQSeriesSDK-6.0.0-0.i386.rpm
[root@localhost mq]# rpm -U MQSeriesServer-6.0.0-0.i386.rpm
 
注:在安装MQSeriesRuntime-6.0.0-0.i386.rpm时候,安装程序为系统自动创建了一个mqm用户和mqm组.本次试验在这一步中遇到了一个警告.我没有管它直接进行下一步.
(5) 安装 WebSphere MQ for Linux 客户机(注:安装服务器时我们已经安装了ÒRuntime 软件包)°  [root@localhost mq]# rpm -U MQSeriesClient-6.0.0-0.i386.rpm
(6) 安装 WebSphere MQ 样本程序(其中包括¨amqsput、amqsget、amqsgbr 和Íamqsbcg 等)£   [root@localhost mq]# rpm -U MQSeriesSamples-6.0.0-0.i386.rpm
这个命令把 WebSphere MQ 样本程序安装在ò/opt/mqm/samp/bin 中。它还将在»/opt/mqm/samp 中安装这些样本程序的ÑC 和ÍCPP 源文件。您可以打开这些样本程序的一些源文件(如ùamqsput.c),以了解如何使用çMQ API(MQI)。
(7)安装MQ其他软件包
[root@localhost mq]# rpm -U MQSeriesMan-6.0.0-0.i386.rpm
[root@localhost mq]# rpm -U MQSeriesJava-6.0.0-0.i386.rpm
[root@localhost mq]# rpm -U IBMJava2-SDK-1.4.2-0.0.i386.rpm
(8) 安装过程创建了一个名为ªmqm 的用户和一个同样名为ªmqm 的组。此时,新用户是被锁定的,您必须设置一个密码来解锁,这样才能继续本文的第二部分。可用µpasswd 命令做到这一点:Õ[root@localhost mq]# passwd mqm
 以上操作均在root用户下操作,至此MQ6.0安装结束.下面的所有命令操作均在mqm用户下.为了验证MQ6.0是否安装成功,我们不防先创建一个队列管理器并启动来检验.
二.MQ6.0命令基础操作.
 操作前首先需要修改一下mqm用户主目录下的.bash_profile 文件.添加以下内容:
export LD_ASSUME_KERNEL=2.2.5
export AMQ_INHIBIT_DLCLOSE=TRUE export
export LC_all=en_US
注:此添加内容为了避免出现不能创建队列管理器的情况.

 

队列管理器
创建队列管理器: crtmqm –q QM1  [-q是指创建缺省的队列管理器]
 [mqm@localhost ~]$ crtmqm -q QM1
There are 90 days left in the trial period for this copy of WebSphere MQ.
WebSphere MQ queue manager created.
Creating or replacing default objects for QM1.
Default objects statistics : 40 created. 0 replaced. 0 failed.
Completing setup.
Setup completed.
[mqm@localhost ~]$
启动队列管理器: strmqm QM1
如果是启动默认的队列管理器,可以不带其名字Ö [mqm@localhost ~]$ strmqm
There are 90 days left in the trial period for this copy of WebSphere MQ.
WebSphere MQ queue manager 'QM1' starting.
5 log records accessed on queue manager 'QM1' during the log replay phase.
Log replay for queue manager 'QM1' complete.
Transaction manager state recovered for queue manager 'QM1'.
WebSphere MQ queue manager 'QM1' started.
[mqm@localhost ~]$
这时ps –ux查看会有很多进程.
QM1队列管理器创建并启动成功! MQ6.0安装成功!


注: 当启动时 strmqm QM1 发生 cannot start queue managers
WebSphere MQ was unable to display an error message 893
and the queue manager does not start......
修改/etc/nsswitch.conf 将 'group: XXX' 的内容替换 为 group: ldap files nisplus
重新开始队列管理器。


停止队列管理器
(1) endmqm QM1 受控停止
[mqm@localhost ~]$ endmqm QM1
Quiesce request accepted. The queue manager will stop when all outstanding work
is complete.
(2) endmqm – i QM1 立即停止
[mqm@localhost ~]$ endmqm -i QM1
WebSphere MQ queue manager 'QM1' ending.
WebSphere MQ queue manager 'QM1' ended.
(3) endmqm –p QM1 强制停止
[mqm@localhost ~]$ endmqm -p QM1
WebSphere MQ queue manager 'QM1' ending.
WebSphere MQ queue manager 'QM1' ended.
删除队列管理器: dltmqm QM1
 [mqm@localhost ~]$ dltmqm QM1
WebSphere MQ queue manager 'QM1' deleted.
[mqm@localhost ~]$
显示队列管理器: dspmq –m QM1
(1) endmqm –I QM1命令后的状态
 [mqm@localhost ~]$ dspmq -m QM1
QMNAME(QM1)                       STATUS(Ended immediately)
(2) endmqm QM1命令后的状态变化.                                      
[mqm@localhost ~]$ dspmq -m QM1
QMNAME(QM1)                              STATUS(Quiescing)
[mqm@localhost ~]$ dspmq -m QM1
QMNAME(QM1)                         STATUS(Ended normally)
(3)endmqm –p QM1命令后的状态
[mqm@localhost ~]$ dspmq -m QM1
QMNAME(QM1)                   STATUS(Ended immediately)
  (4)strmqm QM1命令后的状态
[mqm@localhost ~]$ dspmq -m QM1
QMNAME(QM1)                                 STATUS(Running)
(5)dltmqm QM1命令后的状态
[mqm@localhost ~]$ dspmq -m QM1
AMQ7048: The queue manager name is either not valid or not known
运行MQSeries命令: runmqsc QM1
  [mqm@localhost ~]$ runmqsc QM1
5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager QM1.
此时运行一个MQ控制台. 退出用end命令即可.

 

定义本地队列
定义本地队列: define ql (DL1) replace
   [mqm@localhost bin]$ runmqsc QMTEST
5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager QMTEST.
 
define ql (DL1)
     1 : define ql (DL1)
AMQ8006: WebSphere MQ queue created.

定义别名队列
定义别名队列: define qalias (QMALIAS) targq (QMTEST)
    [mqm@localhost bin]$ runmqsc QMTEST
5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager QMTEST.
 
define qalias (QMALIAS) targq (QMTEST)
     1 : define qalias (QMALIAS) targq (QMTEST)
AMQ8006: WebSphere MQ queue created.

 

定义死信队列
定义死信队列:define qlocal (死信队列名) defpsist (YES) replace
 

定义本地传输队列
定义本地传输队列: define qlocal ('CSDL') usage (XMITQ)
    define qlocal ('CSDL1') usage (XMITQ)
     1 : define qlocal ('CSDL1') usage (XMITQ)
AMQ8006: WebSphere MQ queue created.
   // 这时一个传输对列CSDL1就被成功建立

远程队列定义:

远程队列定义:
DEFINE QREMOTE('远程队列名字') RQMNAME('receive队列管理器') RNAME('receive本地队列') XMITQ ('sender本地传输队列') Replace
注:牢记上面的远程队列的定义格式. 经验证网上有些资料定义的格式是错误的.注意被误导!
[mqm@localhost bin]$ runmqsc QM1
5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager QM1
 

define qremote('RDL1') rqmname('QM2') rname('DL2') xmitq('CSDl1') replace
     1 : define qremote('RDL1') rqmname('QM2') rname('DL2') xmitq('CSDl1') replace
AMQ8006: WebSphere MQ queue created.

 

创建发送方通道:
创建发送方通道:
define channel (管道名) chltype (SDR) conname (‘IP地址(端口)’) xmitq(传输队列) replace
[mqm@localhost bin]$ runmqsc QM1
5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager QM1
 

define channel (CHANNEL1) chltype (SDR) conname ('127.0.0.1(1414)') xmitq (CSDL1)
     1 : define channel (CHANNEL1) chltype (SDR) conname ('127.0.0.1(1414)') xmitq (CSDL1)
AMQ8014: WebSphere MQ channel created.

 

创建接受方通道:
创建接受方通道:
define channel (接受方通道名字) chltype (RCVR)
注: 要记住很重要一点 要使发送和接受双方能正常通信必须保证接受方和发送方的通道名称相同!

 

启动侦听
启动侦听: runmqlsr –t TYPE –p PORT –m 队列管理器 &
 [mqm@localhost ~]$ runmqlsr -t tcp -p 1414 -m QM2 &
[1] 3258
[mqm@localhost ~]$ 5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
这时候netstat –an看下就会有1414在监听.
15.停止侦听:endmqlsr -m 队列管理器Ü
16.启动通道: runmqchl –c 管道名字 –m 队列管理器
   [mqm@localhost ~]$ runmqchl -c CHANNEL1  -m QM1 &
5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
02/13/06 09:14:13 Channel 'CHANNEL1' is starting.
02/13/06 09:14:13 AMQ9202: Remote host 'localhost (127.0.0.1) (1414)' not available, retry later.
02/13/06 09:14:13 AMQ9999: Channel program ended abnormally.
[mqm@localhost ~]$
上面是在没有启动侦听来启动通道出现的情况. 动侦听后再启动通道就OK了.
[mqm@localhost ~]$ runmqchl -c CHANNEL1 -m QM1 &
[3] 4900
[mqm@localhost ~]$ 5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
02/13/06 09:43:18 Channel 'CHANNEL1' is starting.


17.显示队列管理器的所有属性
display ql (*)  //查看当前管理器下所有的本地队列和传输队列
display chl (*) //查看当前管理器下所有的通道
DISPLAY QREMOTE (*)  //查看当前管理器下的所有远程队列.
具体其他的用法请参考IBM的MQ使用指南.
18.往队列中放消息: ampsput 队列名 队列管理器名
amqsput RDL1 QM1  //这是往QM1的远程队列RDL1中存放消息.
ampsput DL2 QM2  //这是往QM2的本地队列DL2中存放消息.
19.从队列中取出消息: amqsget 队列名 队列管理器名
amqsget DL2 QM2  //这是从QM2的本地队列DL2中取出消息
注:amqsput和amqsget命令均在/opt/mqm/samp/bin目录下
 
三.配置一个MQ单向远程通信.
上面讲述了MQ中基本的知识,写的有点杂,可能还似乎没看明白。下面结合一个实例来贯通上面的讲解。Sender服务器地址为10.4.5.74. Receive服务器地址为10.4.5.201.这里是实现QM1和QM2之间的单向远程通信。关于双向通信道理就大同小异了。Á
Sender 队列管理器:QM1 (10.4.5.74)
Receive 队列管理器:QM2 (10.4.5.201)
 
(1)Sender 队列管理器:QM1 (10.4.5.74)
1. 创建QM1:crtmqm –q QM1 (我让QM1为默认管理器)
    [mqm@localhost bin]$ crtmqm -q QM1
There are 80 days left in the trial period for this copy of WebSphere MQ.
WebSphere MQ queue manager created.
Creating or replacing default objects for QM1.
Default objects statistics : 40 created. 0 replaced. 0 failed.
Completing setup.
Setup completed.
2. 启动QM1:strmqm
   [mqm@localhost bin]$ strmqm
There are 80 days left in the trial period for this copy of WebSphere MQ.
WebSphere MQ queue manager 'QM1' starting.
5 log records accessed on queue manager 'QM1' during the log replay phase.
Log replay for queue manager 'QM1' complete.
Transaction manager state recovered for queue manager 'QM1'.
WebSphere MQ queue manager 'QM1' started.
3.查看QM1状态:dspmq –m QM1
   [mqm@localhost bin]$ dspmq -m QM1
QMNAME(QM1)                                      STATUS(Running)
4.运行MQSeries命令: runmqsc QM1
  [mqm@localhost bin]$ runmqsc QM1
5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager QM1.
5.定义传输队列CSDL1:define qlocal ('CSDL1') usage (XMITQ)
   [mqm@localhost bin]$ runmqsc QM1
5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager QM1.
 

define qlocal ('CSDL1') usage (XMITQ)
     1 : define qlocal ('CSDL1') usage (XMITQ)
AMQ8006: WebSphere MQ queue created.
6.定义远程队列RDL1:define qremote('RDL1') rqmname('QM2') rname('DL2') xmitq('CSDL1')
    
     [mqm@localhost bin]$ runmqsc QM1
5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager QM1.
 

define qlocal ('CSDL1') usage (XMITQ)
     1 : define qlocal ('CSDL1') usage (XMITQ)
AMQ8006: WebSphere MQ queue created.
define qremote('RDL1') rqmname('QM2') rname('DL2') xmitq('CSDL1')
     2 : define qremote('RDL1') rqmname('QM2') rname('DL2') xmitq('CSDL1')
AMQ8006: WebSphere MQ queue created.
7.创建通道CHL1:define channel(CHL1) chltype(SDR) conname('10.4.5.201(1414)') xmitq(CSDL1)
 
    [mqm@localhost bin]$ runmqsc QM1
5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager QM1.
 

define qlocal ('CSDL1') usage (XMITQ)
     1 : define qlocal ('CSDL1') usage (XMITQ)
AMQ8006: WebSphere MQ queue created.
define qremote('RDL1') rqmname('QM2') rname('DL2') xmitq('CSDL1')
     2 : define qremote('RDL1') rqmname('QM2') rname('DL2') xmitq('CSDL1')
AMQ8006: WebSphere MQ queue created.
define channel(CHL1) chltype(SDR) conname('10.4.5.201(1414)') xmitq(CSDL1)
     3 : define channel(CHL1) chltype(SDR) conname('10.4.5.201(1414)') xmitq(CSDL1)
AMQ8014: WebSphere MQ channel created.
8.查看QM1属性:
1)dis ql (*)
      dis ql (*)
     1 : dis ql (*)
AMQ8409: Display Queue details.
   QUEUE(CSDL1)                            TYPE(QLOCAL)
2)dis qremote (*)
     dis qremote (*)
     1 : dis qremote (*)
AMQ8409: Display Queue details.
   QUEUE(RDL1)                             TYPE(QREMOTE)
3)dis chl (*)
     dis chl (*)
     1 : dis chl (*)
AMQ8414: Display Channel details.
   CHANNEL(CHL1)                           CHLTYPE(SDR)
经过确认一切OK!
 

(2)Receive 队列管理器:QM2 (10.4.5.201)
1.创建QM2:crtmqm QM2
        [mqm@fxvsystem]~ >crtmqm QM2
There are 80 days left in the trial period for this copy of WebSphere MQ.
WebSphere MQ queue manager created.
Creating or replacing default objects for QM2.
Default objects statistics : 40 created. 0 replaced. 0 failed.
Completing setup.
Setup completed.
2.启动QM2:strmqm QM2
        [mqm@fxvsystem]~ >strmqm QM2
There are 80 days left in the trial period for this copy of WebSphere MQ.
WebSphere MQ queue manager 'QM2' starting.
5 log records accessed on queue manager 'QM2' during the log replay phase.
Log replay for queue manager 'QM2' complete.
Transaction manager state recovered for queue manager 'QM2'.
WebSphere MQ queue manager 'QM2' started.
3. 查看QM2状态:dspmq -m QM2
         [mqm@fxvsystem]~ >dspmq -m QM2
QMNAME(QM2)                                     STATUS(Running)
4. 运行MQSeries命令: runmqsc QM2
          [mqm@fxvsystem]~ >runmqsc QM2
5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager QM2.
5. 定义DL2本地队列:
           [mqm@fxvsystem]~ >runmqsc QM2
5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager QM2.
 

define ql (DL2)
     1 : define ql (DL2)
AMQ8006: WebSphere MQ queue created.
6. 创建通道CHL1:define channel(CHL1) chltype(RCVR)
          [mqm@fxvsystem]~ >runmqsc QM2
5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager QM2.
 

define ql (DL2)
     1 : define ql (DL2)
AMQ8006: WebSphere MQ queue created.
define channel(CHL1) chltype(RCVR)
     2 : define channel(CHL1) chltype(RCVR)
AMQ8014: WebSphere MQ channel created.
 
注意这里是CHL1,和QM1中的通道名字要保持一致。Ö7. 查看QM2属性:
1) dis ql (*)
       dis ql (*)
     1 : dis ql (*)
AMQ8409: Display Queue details.
   QUEUE(DL2)                              TYPE(QLOCAL)
2) dis chl (*)
       dis chl (*)
     1 : dis chl (*)
AMQ8414: Display Channel details.
   CHANNEL(CHL1)                           CHLTYPE(RCVR)
经过确认一切OK!
 

开始通信操作
 
1. 在201机器上启动侦听:runmqlsr -t tcp -p 1414 -m QM2 &
     
     [mqm@fxvsystem]~ 3>runmqlsr -t tcp -p 1414 -m QM2 &
[1] 23437
[mqm@fxvsystem]~ 4>5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
2. 在74机器上启动通道CHL1:runmqchl -c CHL1 -m QM1 &
            [mqm@localhost bin]$ runmqchl -c CHL1 -m QM1 &
[1] 6071
[mqm@localhost bin]$ 5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
02/13/06 13:21:13 Channel 'CHL1' is starting.
在74机器上往RDL1存放消息:
           1)cd  /opt/mqm/samp/bin
2)./amqsput RDL1 QM1
       [mqm@localhost bin]$ ./amqsput RDL1 QM1
Sample AMQSPUT0 start
target queue is RDL1
fjsofjoefgf
1456tuyt56uty
kgfpgkpfdh456485
      
在201机器上从DL2取出消息:
           1)cd  /opt/mqm/samp/bin
           2)./amqsget DL2 QM2
       [mqm@fxvsystem]/opt/mqm/samp/bin >./amqsget DL2 QM2
Sample AMQSGET0 start
message <fjsofjoefgf>
message <1456tuyt56uty>
message <kgfpgkpfdh456485>
 
OK!成功!^_^
 

四.试验总结:
     本次试验包括MQ的安装学习和MQ的基础命令操作,以及最后能配置一个MQ远程通信。安装部分主要注意mqlicense.sh文件的配置,基础命令操作部分需注意严格遵守MQ命令的格式规范,并了解每个参数的含义达到正确使用。加强命令的练习。配置MQ通信部分,要保证一个MQ能够单向远程通信,需注意几点。对于Sender这块,首先要有一个队列管理器,建立一个传输队列,建立一个远程队列,建立一个通道。无需建立本地队列。对于Receive这块,首先要有一个队列管理器,建立一个本地队列,建立一个与发送方通道名字一样的接受通道。在Sender和Receive预备工作做好之后,首先要在Receive启动侦听,然后再到Sender启动通道。这样就能实现Sender->Receive单向通信了。对于双向通信这里不再赘述。总之本次试验比较成功!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值