1、资料内容仅供您学习参考,如有不当之处,请联系改正或者删除。1、 Q复制规划1.1主机和DB2的相关设置信息descriptionsourcetargetHost nameDbsvr01Dbsvr04Host IP Address10.0.1.4510.0.1.44Db2 instance ownerDb1inst1Db1inst1Db2 tcp port5000250002Database server /aliaspronodedssnodeDb2 codepage13861386LogretainYesYesDB ALIAStopicidssdb注意: 在使用复制功能之前, 源数据库都应该
2、将日志模式设置为archive logging模式( 归档日志模式) 1.2Websphere MQ的相关配置信息descriptionsourcetargetQueue ManagerQMSYSAQMSYSBListener port14531454Transmit QSYSA.XMITQSYSB.XMITQSDR channelSYSAtoSYSBSYSBtoSYSASCV channelSYSBtoSYSASYSAtoSYSBRestart QSYSA.RESTARTQAdminQSYSA.ADMINQSYSA.ADMINQSend Q(remote)SYSA.SENDQReceive
3、Q(local)SYSB.RECVQAdminQ(remote)SYSA.ADMINQSpill QIBMQREP.SPILL.MODELQ1.3Q复制的配置信息descriptionsourcetargetQ capture schemaASN Q apply schemaASN Q capture path/home/db2inst2/captureQ apply path/home/db2inst2/applyReplication queue map nameSYSAtoSYSBSYSAtoSYSB1.4复制队列映射属性descriptionQCaptureQApply复制队列映射名称
4、SYSAtoSYSBQ Capture服务器topicisQ Apply服务器dssdb发送队列SYSA.SENDQ接收队列SYSB.RECVQ管理队列SYSA.ADMINQSYSA.ADMINQ.1.5通道测试cd /usr/mqm/samp/bin./amqsput SYSA.SENDQ QMSYSA./amqsget SYSB.RECVQ QMSYSB2、 mq用户创立创立用户mqm和组mqm,并把组mqm加入到用户db2inst1和db2fenc1中。3、 mq software install 解压缩mq软件, 用smitty installp安装,创立大小50G的mqmvg 、 m
5、qmlv和文件系统mqm,挂载点/var/mqm, /var/mqm/log 4、 mq 队列和通道创立在dbsvr04上执行setclock dbsvr01进行与dbsvr01的时间同步, 需要在/etc/hosts中添加dbsvr01和IP。由于MQ的需要在dbsvr01和dbsvr04中/etc/hosts添加相互的IP和name 信息。Service ip 和 service name 也要添加。Dbsvr04:/etc/hosts:10.0.1.41 dbsvr0110.0.1.44 dbsvr0410.0.1.45 dbserver /hacmp 中service IP MQ测试:
6、 Dbsvr01:$ crtmqm -q venus.queue.managerWebSphere MQ queue manager created.Creating or replacing default objects for venus.queue.manager.Default objects statistics : 58 created. 0 replaced. 0 failed.Completing setup.Setup completed.$ strmqmWebSphere MQ queue manager venus.queue.manager starting.5 lo
7、g records accessed on queue manager venus.queue.manager during the log replay phase.Log replay for queue manager venus.queue.manager complete.Transaction manager state recovered for queue manager venus.queue.manager.WebSphere MQ queue manager venus.queue.manager started.$ runmqsc5724-H72 (C) Copyrig
8、ht IBM Corp. 1994, . ALL RIGHTS RESERVED.Starting MQSC for queue manager venus.queue.manager.define qlocal (orange.queue) 1 : define qlocal (orange.queue)AMQ8006: WebSphere MQ queue created.end 2 : endOne MQSC command read.No commands have a syntax error.All valid MQSC commands were processed.$ cd /
9、usr/mqm/samp/bin/$ ./amqsput ORANGE.QUEUESample AMQSPUT0 starttarget queue is ORANGE.QUEUEabcddsfsdsdfdsenddbsvr04:$ crtmqm -q venus.queue.managerWebSphere MQ queue manager created.Creating or replacing default objects for venus.queue.manager.Default objects statistics : 58 created. 0 replaced. 0 fa
10、iled.Completing setup.Setup completed.$ $ strmqmWebSphere MQ queue manager venus.queue.manager starting.5 log records accessed on queue manager venus.queue.manager during the log replay phase.Log replay for queue manager venus.queue.manager complete.Transaction manager state recovered for queue mana
11、ger venus.queue.manager.WebSphere MQ queue manager venus.queue.manager started.$ runmqsc5724-H72 (C) Copyright IBM Corp. 1994, . ALL RIGHTS RESERVED.Starting MQSC for queue manager venus.queue.manager.define qlocal (orange.queue) 1 : define qlocal (orange.queue)AMQ8006: WebSphere MQ queue created. :
12、 : : end 2 : endOne MQSC command read.No commands have a syntax error.All valid MQSC commands were processed.$ cd /usr/mqm/samp/bin$ ./amqsput ORANGE.QUEUESample AMQSPUT0 starttarget queue is ORANGE.QUEUEadsfsdfdsfsdfsdfsSample AMQSPUT0 end$ $ ./amqsget ORANGE.QUEUESample AMQSGET0 startmessage dbsvr
13、01:crtmqm -lc -d SYSA.XMITQ -u DEADLETTER -lp 20 -ls 10 -lf 10240 QMSYSA /创立MQ队列strmqm QMSYSA /起队列管理器endmqlsr -m QMSYSA /停队列管理器ps -ef | grep mq /查看队列管理器nohup runmqlsr -t tcp -p 1453 -m QMSYSA & /起监听ps ef|grep lsr / 查看监听进程endmqm QMSYSA /停队列endmqlsr /停监听dltmqm QMSYSA /删除管理队列runmqsc QMSYSA /起MQ资源DEFINE
14、 QREMOTE(SYSA.SENDQ) RNAME(SYSB.RECVQ) RQMNAME(QMSYSB) XMITQ(SYSA.XMITQ)DEFINE QLOCAL(SYSA.XMITQ) USAGE(XMITQ) MAXDEPTH(1000000) DEFPSIST(YES)DEFINE QLOCAL(DEADLETTER) USAGE(NORMAL) MAXDEPTH(500000)ALTER QMGR DEADQ(DEADLETTER)DEFINE CHL (SYSAtoSYSB) CHLTYPE(SDR) TRPTYPE(TCP) CONNAME(10.0.1.44(1454)
15、XMITQ(SYSA.XMITQ) DISCINT (0) BATCHSZ (200)START CHANNEL (SYSAtoSYSB)DEFINE CHL (SYSBtoSYSA) CHLTYPE(RCVR) TRPTYPE(TCP) BATCHSZ(200)DEFINE QLOCAL(SYSA.ADMINQ) MAXDEPTH(500000) DEFPSIST(YES)DEFINE QLOCAL(SYSA.RESTARTQ) MAXDEPTH(500000) DEFPSIST(YES)End*runmqsc QMSYSA dis chstatus(SYSAtoSYSB) /显示runni
16、ng 通道状态正常dis chstatus(SYSAtoSYSB) 1 : dis chstatus(SYSBtoSYSA)AMQ8417: Display Channel Status details. CHANNEL(SYSBtoSYSA) CHLTYPE(RCVR) CONNAME(10.0.1.44) CURRENT RQMNAME(QMSYSB) STATUS(RUNNING) SUBSTATE(RECEIVE) dis chstatus(SYSBtoSYSA) 2 : dis chstatus(SYSBtoSYSA) AMQ8417: Display Channel Status
17、details. CHANNEL(SYSBtoSYSA) CHLTYPE(RCVR) CONNAME(10.0.1.44) CURRENT RQMNAME(QMSYSB) STATUS(RUNNING) SUBSTATE(RECEIVE) *runmqsc QMSYSB dis chstatus(SYSBtoSYSA) runmqchl -c SYSAtoSYSB -m QMSYSA /如果没有错误信息显示, 表明该channel成功运行runmqchl -c SYSBtoSYSA -m QMSYSA /如果没有错误信息显示, 表明该channel成功运行*修改queue manager的CC
18、SID:strmqmrunmqscdisplay qmgr / 检查当前queue manager的CCSID值alter qmgr ccsid(437)end*dbsvr04:crtmqm -lc -d SYSB.XMITQ -u DEADLETTER -lp 20 -ls 10 -lf 10240 QMSYSBstrmqm QMSYSBnohup runmqlsr -t tcp -p 1454 -m QMSYSB &runmqsc QMSYSBDEFINE QLOCAL(SYSB.RECVQ) MAXDEPTH(1000000) DEFPSIST(YES)DEFINE QREMOTE(SY
19、SA.ADMINQ) RNAME(SYSA.ADMINQ) RQMNAME(QMSYSA) XMITQ(SYSB.XMITQ)DEFINE QLOCAL(SYSB.XMITQ) MAXDEPTH(1000000) USAGE(XMITQ) DEFPSIST(YES)DEFINE QLOCAL(DEADLETTER) USAGE(NORMAL) MAXDEPTH(500000)ALTER QMGR DEADQ(DEADLETTER)DEFINE CHL (SYSBtoSYSA) CHLTYPE(SDR) TRPTYPE(TCP) CONNAME(10.0.1.45(1453) XMITQ(SYS
20、B.XMITQ) DISCINT (0) BATCHSZ (200)START CHANNEL (SYSBtoSYSA) DEFINE CHL (SYSAtoSYSB) CHLTYPE(RCVR) TRPTYPE(TCP) BATCHSZ(200)DEFINE QMODEL(IBMQREP.SPILL.MODELQ) DEFSOPT(SHARED) MAXDEPTH(1000000) MSGDLVSQ(FIFO) DEFTYPE(PERMDYN)end*nohup runmqlsr -t tcp -p 1454 -m QMSYSB & /起监听runmqsc QMSYSB dis chstat
21、us(SYSBtoSYSA) /显示running 通道状态正常 dis chstatus(SYSBtoSYSA) dis chstatus(SYSAtoSYSB) 1 : dis chstatus(SYSAtoSYSB)AMQ8417: Display Channel Status details. CHANNEL(SYSAtoSYSB) CHLTYPE(RCVR) CONNAME(10.0.1.45) CURRENT RQMNAME(QMSYSA) STATUS(RUNNING) SUBSTATE(RECEIVE) dis chstatus(SYSBtoSYSA) 2 : dis chst
22、atus(SYSBtoSYSA)AMQ8417: Display Channel Status details. CHANNEL(SYSBtoSYSA) CHLTYPE(SDR) CONNAME(10.0.1.45(1453) CURRENT RQMNAME(QMSYSA) STATUS(RUNNING) SUBSTATE(MQGET) XMITQ(SYSB.XMITQ)EN)*修改队列管理器中的字符集命令: 首先打开命令行窗口。 在打开后的命令窗口中输入: runmqsc ( 队列管理器名称) , 然后按回车。 其后再输入: ALTER QMGR CCSID (字符集代码), 回车, 修改成
23、功。 最后输入: DISPLAY QMGR CCSID,查看已经更改过的字符编码集。 DISPLAY QMSTATUS STATUS( 查看qmgr的运行状态) 注:1208是UTF-8格式, 1381是中文格式。在字符集代码处选择输入, 如果这两都不是你需要的, 你能够查看MB帮助或MQ帮助, 选择合适你的字符集代码。5、 创立catalog 库本地复制中心pc、 dbsvr01、 dbsvr02上创立catalog库。本地复制中心pc上:C:Documents and Settingsadmincd C:db2 list db directorySQL1031N 在指示的文件系统中找不到数
24、据库目录。 SQLSTATE=58031C:db2 catalog tcpip node pridnode remote 10.0.1.45 server 50002 / prodnode对应dbsvr01主机DB 0I CATALOG TCPIP NODE 命令成功完成。DB21056W 直到刷新目录高速缓存之后, 目录更改才生效。C:db2 catalog db topicis at node pridnodeDB 0I CATALOG DATABASE 命令成功完成。DB21056W 直到刷新目录高速缓存之后, 目录更改才生效。C:db2 terminateDB 0I TERMINATE
25、 命令成功完成。C:db2 connect to topicis user db2inst1 using db2inst1 数据库连接信息 数据库服务器 = DB2/AIX64 9.7.1 SQL 授权标识 = DB2INST1 本地数据库别名 = TOPICISC:db2 catalog tcpip node dssnode remote 10.0.1.44 server 50002 /dssnode对应dbsvr04主机DB 0I CATALOG TCPIP NODE 命令成功完成。DB21056W 直到刷新目录高速缓存之后, 目录更改才生效。C:db2 catalog db topici
26、s as dssdb at node dssnode /创立topicis别名为dssdbDB 0I CATALOG DATABASE 命令成功完成。DB21056W 直到刷新目录高速缓存之后, 目录更改才生效。C:db2 terminateDB 0I TERMINATE 命令成功完成。C:db2 connect to dssdb user db2inst1 using db2inst1 数据库连接信息 数据库服务器 = DB2/AIX64 9.7.1 SQL 授权标识 = DB2INST1 本地数据库别名 = DSSDB删除用 : db2 uncatalog db dssdb Db2 unc
27、atalog node dssnodedbsvr01上catalog:dbsvr01:$ db2 catalog tcpip node dssnode remote 10.0.1.44 server 50002 / dssnode对应为dbsvr04DB 0I The CATALOG TCPIP NODE command completed successfully.DB21056W Directory changes may not be effective until the directory cache is refreshed.$ db2 catalog db topicis as
28、dssdb at node dssnode /创立topicis别名为dssdbDB 0I The CATALOG DATABASE command completed successfully.DB21056W Directory changes may not be effective until the directory cache is refreshed.$ db2 terminateDB 0I The TERMINATE command completed successfully.$ dbsvr04上catalog:dbsvr04:$ db2 catalog db topici
29、s as dssdb on /home/db2inst1 /创立topicis别名为dssdbDB 0I The CATALOG DATABASE command completed successfully.DB21056W Directory changes may not be effective until the directory cache is refreshed.$ db2 terminateDB 0I The TERMINATE command completed successfully.$ db2 list db directory System Database Di
30、rectory Number of entries in the directory = 2Database 1 entry: Database alias = TOPICIS Database name = TOPICIS Local database directory = /home/db2inst1 Database release level = d.00 Comment = Directory entry type = Indirect Catalog database partition number = 0 Alternate server hostname = Alterna
31、te server port number =Database 2 entry: Database alias = DSSDB Database name = TOPICIS Local database directory = /home/db2inst1 Database release level = d.00 Comment = Directory entry type = Indirect Catalog database partition number = 0 Alternate server hostname = Alternate server port number =$
32、db2 connect to dssdb Database Connection Information Database server = DB2/AIX64 9.7.1 SQL authorization ID = DB2INST1 Local database alias = DSSDB5、 用户口令配置Dbsvr01:asnpwd initasnpwd add alias topicis id db2inst1 password db2inst1asnpwd add alias dssdb id db2inst1 password db2inst1Dbsvr04:asnpwd init
33、asnpwd add alias topicis id db2inst1 password db2inst1asnpwd add alias dssdb id db2inst1 password db2inst16、 db2复制中心: db2rc7.1 capture模式创立 7.2、 Q预定创立 7.3创立复制队列映射 7.4、 APPLY模式创立 7.5、 Q预定单个启动与停止 8、 MQ相关脚本8.1 Capture主机中的相关脚本。启动脚本: capture.sh:date#export LD_LIBRARY_PATH=/usr/opt/db2_08_01/libexport LIBP
34、ATH=/usr/mqm/lib64:$LIBPATHexport LD_LIBRARY_PATH=$LIBPATHecho $LIBPATHecho $LD_LIBRARY_PATHasnqcap capture_server=topicis capture_schema=ASN capture_path=/home/db2inst1/capture PWDFILE=asnpwd.aut /usr/opt/db2_08_01/bin/asnqcap startmode=COLD #capture_server=BTPDBS capture_schema=ASN1 #capture_pat
35、h=/home/db2inst1/capture_data PWDFILE=asnpwd.aut停止脚本stop.sh:asnqccmd CAPTURE_SERVER=topicis CAPTURE_SCHEMA=ASN stop查看状态脚本status.sh:asnqccmd CAPTURE_SERVER=topicis CAPTURE_SCHEMA=ASN status启mqm脚本: Mqmstart.sh:strmqm QMSYSArunmqsc QMSYSA ./startcomponent.mqscnohup runmqlsr -t tcp -p 1453 -m QMSYSA &st
36、artcomponent.mqsc:START CHANNEL(SYSAtoSYSB)START CHANNEL(SYSBtoSYSA)END停mqm脚本: Mqmstop.sh:runmqsc QMSYSA ./stopcomponent.mqscendmqlsr -w -m QMSYSAendmqm -i QMSYSAendmqm -p QMSYSAstopcomponent.mqsc:STOP CHANNEL(SYSBtoSYSA) MODE(FORCE)STOP CHANNEL(SYSBtoSYSA) MODE(FORCE)END8.2 Apply主机中的相关脚本。启动脚本: appl
37、y.sh:date#export LD_LIBRARY_PATH=/usr/opt/db2_08_01/lib#export LIBPATH=/usr/lib:/lib:/usr/opt/db2_08_01/lib:/usr/mqm/libexport LIBPATH=/usr/mqm/lib64:$LIBPATHexport LD_LIBRARY_PATH=$LIBPATHecho $LIBPATHecho $LD_LIBRARY_PATHasnqapp apply_server=dssdb apply_schema=ASN apply_path=/home/db2inst1/apply P
38、WDFILE=asnpwd.aut &停止脚本stop.sh:asnqacmd APPLY_SERVER=dssdb APPLY_SCHEMA=ASN stop查看状态脚本status.sh:asnqacmd APPLY_SERVER=dssdb APPLY_SCHEMA=ASN status启mqm脚本: Mqmstart.sh:strmqm QMSYSBrunmqsc QMSYSB ./startcomponent.mqscnohup runmqlsr -t tcp -p 1454 -m QMSYSB &startcomponent.mqsc:START CHANNEL(SYSAtoSYS
39、B)START CHANNEL(SYSBtoSYSA)END停mqm脚本: Mqmstop.sh:runmqsc QMSYSB ./stopcomponent.mqscendmqlsr -w -m QMSYSBendmqm -i QMSYSBendmqm -p QMSYSBstopcomponent.mqsc:STOP CHANNEL(SYSBtoSYSA) MODE(FORCE)STOP CHANNEL(SYSBtoSYSA) MODE(FORCE)END9、 启动顺序DB2与MQM启动顺序 Db2数据库启动顺序为, 先启动hacmp 集群中db2, 启动MQ主机上的db2, 启动MQ主机上
40、的mq 队列与通道、 监听等。启动hacmp 集群中db2主机上的mq 队列与通道、 监听等。启动MQ主机上的mq的apply.sh启动hacmp 集群中db2主机上的mq的capture.sh10、 相关信息总结ASN7137W MAX_MESSAGE_SIZE偏小程序名: 程序标识: 发布或 Q 预订 名称 的指定 MAX_MESSAGE_SIZE 对于发送队列 队列名 和发布队列映射或复制队列映射 queue_map_name 可能太小。可能需要 大小 字节的最大值。说明发布队列映射或复制队列映射的 MAX_MESSAGE_SIZE 值( 用于指定此发送队列) 可能太小, 因此不能包括
41、WebSphere MQ 消息中的一行。如果 Q Capture 程序在运行时发生此问题, 那么它将停止。用户响应增大队列映射的 MAX_MESSAGE_SIZE 值。使用 asnqacmd reinitq 命令重新初始化队列映射。alter qmgr MAXMSGL()db2 update ASN.IBMQREP_SENDQUEUES set max_message_size = 8192asnqacmd reinitqSendMQ:db2 update ASN.IBMQREP_SENDQUEUES set max_message_size = 8192alter qmgr MAXMSGL()alter ql(SYSA.XMITQ) MAXMSGL()dis ql(SYSA.XMITQ) endReceiveMQ:db2 update ASN.IBMQREP_SENDQUEUES set max_message_size = 8192dis ql(SYSB.RECVQ)alter qmgr MAXMSGL() alter ql(SYSB.RECVQ) MAXMSGL()endQ复制源表增加字段是不能传输到目标表的。复制源表增加字段是不能