技术开发 频道

DB2远程Q复制实践

    2. 通过CLP方式来检查channels的连接性并获取更多相关信息有时候,通过命令行方式可以高效快捷地检查一些相关的信息,这种方式可以脚本化,当我们要检查的channel很多时,或者相关操作重复性比较大时,应该考虑命令行方式来做。另外,命令行方式能够获取更多的出错方面的详细信息。

    (1). 在EAST上运行如下命令:

    runmqchl -c EAST_TO_WEST -m QM_EAST

    如果没有错误信息显示,表明该channel成功运行。之后打开另外一个命令行窗口,并输入如下的命令:

    runmqchl -c WEST_TO_EAST -m QM_WEST

    如果此时返回相关错误码,那么对其进行分析并根据错误提示去采取相应的解决办法。

    (2). 测试本地的queues 在EAST上,执行如下命令将一个消息放到队列上:

    /usr/mqm/samp/bin/amqsput EAST_RESTARTQ QM_EAST
    Sample AMQSPUT0 start
    target queue is EAST_RESTARTQ
    This is a test message to a local queue
    Sample AMQSPUT0 end

    然后通过执行下面的命令来从queue中获取信息。这个时候应该会显示出上面输入的消息文本。

    /usr/mqm/samp/bin/amqsget EAST_RESTARTQ QM_EAST
    Sample AMQSGET0 start
    message <This is a test message to a local queue>
    no more messages
    Sample AMQSGET0 end

    在WEST端,执行如下命令来将一个消息放到队列里面:

    /usr/mqm/samp/bin/amqsput WEST_RESTARTQ QM_WEST
    Sample AMQSPUT0 start
    target queue is WEST_RESTARTQ
    This is a test message to a local queue
    Sample AMQSPUT0 end

    同样的,执行如下命令来从queue中获取信息。这个时候应该也会显示出上面输入的相关消息文本。

    /usr/mqm/samp/bin/amqsget WEST_RESTARTQ QM_WEST
    Sample AMQSGET0 start
    message <This is a test message to a local queue>
    no more messages
    Sample AMQSGET0 end

    (3). 测试远程的queues 测试从远端的queue上面放入和取出消息。

    在EAST上执行如下命令来将消息放入到WEST_ADMINQ这个队列中。

    /usr/mqm/samp/bin/amqsput WEST_ADMINQ QM_EAST
    Sample AMQSPUT0 start
    target queue is WEST_ADMINTQ
    This is a test message to a remote queue
    Sample AMQSPUT0 end

    在WEST中执行如下命令获取来自WEST_ADMINQ 队列上的消息。

    /usr/mqm/samp/bin/amqsget WEST_ADMINQ QM_WEST
    Sample AMQSGET0 start
    message <This is a test message to a remote queue>
    no more messages
    Sample AMQSGET0 end

    步骤注解

    Remote queues:

    Remote queues是一个相对的概念,是用来在另外一个queue manager上定义local queue。在本文中,每个queue manager分别定义了两个remote queue。在QM_EAST上,WEST_ADMINQ和EAST_TO_WEST_Q被定义成为remote queue。在QM_WEST上,EAST_ADMINQ和WEST_TO_EAST_Q被定义成为remote queue。

    WSMQ objects:

    关于MQ对象的更多信息,请参考《Fast Track implementation scenarios》的附录A。该资料在附件中已给出。

    出错分析及解决

    问题1描述:

    C:\Documents and Settings\Administrator>runmqchl -c EAST_TO_WEST -m QM_EAST 5724-B41 (C) Copyright IBMCorp.     
    1994, 2002. ALL RIGHTS RESERVED.
    2005-09-25 17:46:56 通道程序已启动。
    2005-09-25 17:47:04 AMQ6047: 不支持转换。
    2005-09-25 17:47:04 AMQ9999: 通道程序异常终止。

    分析:

    在MQ消息手册中查找关于AMQ6047的相关信息,如下: 
    AMQ6047 Conversion not supported.
    Explanation: WebSphere MQ is unable to convert string data tagged in CCSID &1 to data in CCSID &2.
    User Response: Check the WebSphere MQ Application Programming Reference Appendix and the appropriate National
     Language Support publications to see if the CCSIDs are supported by your system.

    这个错误的原因是由于两个queue manager的CCSID 的设置不兼容造成的。而这种不兼容的最根本原因是由于本地的locale和远程主机的locale不一致造成的(从而WebSphere MQ的安装语言版本不一样)。这点和DB2的code page问题很类似。

    解决:

    (1) 在MQ explorer中找到CCSID及相关属性。在笔者的环境中,如果安装的是中文版的MQ,那么CCSID的缺省值是1381,而英文版的则相应为437。在这两者之间,它们并没有直接的转换方式来进行兼容性处理。

    (2) 由于(1),我们必须在本地对CCSID进行转换。在EAST(CCSID=1381)端通过如下命令来实现其转换:

    strmqm
    runmqsc
    display qmgr       // 检查当前queue manager的CCSID值
    alter qmgr ccsid(437)
    end

    第三部分 通过Replication Center图形界面建立远程Q复制

    操作步骤

    这部分主要通过GUI图形界面(即Replication Center)来完成。同时,为了方便起见,其中也会用到CLP命令行方式。对于本文的单向复制而言,这里主要通过配置EAST端来说明相关使用方法。

    在开始配置Capture和Apply之前,首先应该对密码和连接性进行测试。在Replication Center中,选择Manage Password and Connectivity,然后选择Systems,在其中添加两行信息,即本地EAST和远程WEST的相关密码和连接信息。

    对于远程Q replication图形界面方面的基本操作,大体和完全在一个机器上的Q replication类似,主要的区别在于对MQ相关对象的操作上有所不同。所以下面的操作部分重点在于MQ的详细介绍。

    1.建立Q Capture相关的控制表

    通过前面的步骤,这里至少可以有两个DB2 server可用,一个是Server A,一个是Server B。可以使用如下命令来获取相关信息:db2 list db directory,具体操作步骤如下:

    选择Sample作为Capture Server。 
    将Q Capture的Schema指定为ASN。 
    Q Manager选择为QM_WEST,然而admin queue应该为WEST_ADMINQ并且restart queue为ST_RESTARTQ。 
    在完成上述配置后,Sample这个Capture Server应该能够用来进行复制了。 

    2.建立Q Apply相关的控制表

    选择ITARGET作为Apply Server。 
    将Q Apply的Schema指定为ASN。 
    Q Manager应该为QM_EAST。 

    3.建立Replication Queue Maps

    在Sample节点下,选择"create Replication Queue Maps"。 
    选择Apply Server为ITARGET。 
    因为前面我们选定了WEST_ADMINQ作为Sample这个Capture Server的AdminQ,所以,Apply server的admin queue也应该 同样指定为WEST_ADMINQ。同时,应该指定send queue和receive queue为WEST_TO_EAST_Q。 
    为 Queue map指定一个名称。 

0
相关文章