Step by Step Guide To Q Replication
Step by Step Guide To Q Replication
Q Replication
DB2 9.7 Database
High level Structure of Q Replication between
two DB2 databases.
SOURCE DB TARGET DB
Learning objectives
Create and use MQ queue managers, queues, and channels.
Enable a DB2 database for replication.
Set up and operate the Q Capture and Q Apply programs.
Configure the Q Capture and Q Apply programs to use the queues.
Create a Q subscription to map a source table to a target table.
Setting up MQ
Create the source queue manager: Create the target queue manager:
crtmqm SRC_QM crtmqm TGT_QM
Start the source queue manager: Start the target queue manager:
strmqm SRC_QM strmqm TGT_QM
Creating the source queues
SRC_QM queue manager:
Start an interactive session for The SRC_QM using
runmqsc SRC_QM
From the session create the Required queues.
* In this Presentation source Server port is identified as 1450 and destination Server port is identified as 1451.
The Ports numbers are subject to availability. Default MQ port is 1414
Contd ->
Creating MQ channels . Contd ..
Define Channel objects at the target
Start an interactive session for The SRC_QM using
runmqsc TGT_QM
From the session create the Required Channels.
Define a sender channel from the TGT_QM queue manager to the
SRC_QM queue manager. Use the TCP/IP transmission protocol
DEFINE CHL ('TGT_QM.TO.SRC_QM') CHLTYPE(SDR)
TRPTYPE(TCP) CONNAME('IP_address(port)')
XMITQ('SRC_QM') DISCINT(0)
Define a receiver channel at the TGT_QM queue manager from the
SRC_QM queue manager.
DEFINE CHL ('SRC_QM.TO.TGT_QM') CHLTYPE(RCVR)
TRPTYPE(TCP)
* In this Presentation source Server port is identified as 1450 and destination Server port is identified as 1451.
The Ports numbers are subject to availability. Default MQ port is 1414
Starting MQ channels and listeners
SOURCE SERVER TARGET SERVER
Start the source queue manager: Start the source queue manager:
strmqm SRC_QM strmqm TGT_QM
Start the listener at the source for the receiver end Start the listener at the target for the receiver end
of the channel from the target, by using TCP/IP of the channel from the source, by using TCP/IP
protocol for queue manager SRC_QM, port 1451 protocol for queue manager TGT_QM, port 1450
nohup runmqlsr -t tcp -m SRC_QM -p nohup runmqlsr -t tcp -m TGT_QM -p
1451 & 1450 &
Start an interactive session with the SRC_QM Start an interactive session with the TGT_QM
queue manager queue manager
runmqsc SRC_QM runmqsc TGT_QM
Start the sender channel at the source. Start the sender channel at the source.
start channel (SRC_QM.TO.TGT_QM) start channel (TGT_QM.TO.SRC_QM)
You set up and started the MQ objects for unidirectional replication using two queue managers to simulate
replication between two remote database. Next, you will set up the Q Replication programs.
Setting up Q Replication
In this module, you configure your databases and create the control tables, replication queue maps, and Q subscriptions.
The Q Capture program at the source database and Q Apply program at the target database use control tables to store
important information such as which tables to capture data from, which queues to use, and which tables to apply
replicated data to. Creating control tables is also known as creating a schema.
Replication queue maps identify the IBM MQ queues that are used for sending and receiving data.
Q subscriptions identify options such as rows and columns that are replicated or published. The Q subscriptions also
identify options for loading target tables.
Steps Discussed:
Creating the source and target control tables
Enabling the source database for replication
Creating a replication queue map
Creating a Q subscription
Creating the source and target control tables
The Q Capture program at the source database and Q Apply program at the target
database use control tables to store important information such as which tables to
capture data from, which queues to use, and which tables to apply replicated data
to.
There are two methods to create the control tables
ASNCLP command-line program. Use the CREATE CONTROL TABLES FOR command to create a new set of Capture or Apply control tables.
For the complete list of the For example, the following commands set the environment and create Capture control tables:
command options please go the link SET SERVER CAPTURE TO DB SAMPLE
Here SET OUTPUT CAPTURE SCRIPT "capctrl.sql";
SET LOG "capctrl.err";
SET RUN SCRIPT LATER;
CREATE CONTROL TABLES FOR CAPTURE SERVER
IN UW UOW TSUOW100 OTHERS TSASN100;
Replication Center Use either the Create Control Tables or Create Control Tables -
Quick windows for Capture and Apply