Setting up replication
Before using the Q Replication Dashboard, let's set up a running Q replication configuration for you to monitor. We've simplified this part of the task by providing a set of scripts and batch files that will create the configurations that you need and get everything running.
Make sure that DB2 and WebSphere MQ are running.
Figure 1, below, shows what you will be setting up:
Figure 1. Replication setup for tutorial
- A source database, LONDON, and two target databases, DALLAS and TOKYO.
- A queue manager, WORLDWIDE_QM, and three local queues that act as both send and receive queues.
- Unidirectional Q subscriptions between LONDON and DALLAS and between LONDON and TOKYO for four source tables.
- Small Java™ applications that create a steady stream of activity at the source database so that the changes can be replicated in one direction to the two targets and also make changes to a target database to create data exceptions that you can monitor.
- From the Downloads section of the tutorial,
download and extract the files from one of the following compressed files,
depending on your WebSphere Replication Server version:
Table 2. Download options Version Compressed file 9.5 tutorial_setup_v95.zip 9.1 tutorial_setup_v91.zip
- From a system command prompt, change to the tutorial_setup_version
directory and enter
Create_MQto run the Create_MQ.bat file. The batch file does the following things:
- Creates the WebSphere MQ queue manager WORLDWIDE_QM
- Starts the queue manager
- Creates the queues that are needed for Q replication
db2cmdto open a DB2 command window. Make sure the command window points to the tutorial_setup_version directory. Enter
setupto run the Setup.bat file. The batch file does the following things:
- Creates and configures three DB2 databases (LONDON, TOKYO, and DALLAS)
- Creates the source tables at the LONDON database that will be replicated to the TOKYO and DALLAS targets
- Creates Q Capture control tables at LONDON and Q Apply control tables at TOKYO and DALLAS
- Creates replication queue maps and Q subscriptions that map the source tables and queues to the target tables and queues
Figure 2. Results of setup command
Note: The setup command takes some time to complete; it includes backing up the newly created databases. For detailed results, you can view the setup.out file that the command generates in the same directory.
start_replto start the Q Capture program at the LONDON database and the Q Apply programs at the TOKYO and DALLAS databases.
Look for messages similar to the following to confirm that the programs started:
Listing 1. Sample initialization messages from Q Capture
2008-02-15-16.02.03.588000 <asnqwk> ASN0572I "Q Capture" : "ASN" : "WorkerThread" : The program initialized successfully. 2008-02-15-16.01.58.118000 <brwzMain> ASN7526I "Q Apply" : "ASN" : "BR00001" : The Q Apply program has started processing the receive queue "SEND_RECVQ1_LON_DALLAS" for replication queue map "LONDON_ASN_TO_DALLAS_ASN".
Important: After you start the replication programs, leave the command window open to avoid stopping replication.
- Edit the setenv.bat file and replace <your_SQLLIB_location> with the location of the SQLLIB directory where DB2 is installed. The default location is C:\Program Files\IBM\SQLLIB. Save the setenv.bat file.
- Open another command window and change to the tutorial_setup_version
setenv, then enter
Figure 3. Output of the runwork command
The runwork.bat file runs several small Java applications to create a workload in the LONDON database. The workload runs for 1 to 1.5 hours.
Important: Do not close the command window in which you are running the workload, or it will stop the applications from running and could leave your database in an inconsistent state before the next time you run the workload applications. If you stop the applications, run CleanTables.bat before you run your next workload to clean up the tables to avoid any inconsistency problems.
- When you are done with the tutorial and the applications have finished running, you can run the stop_repl.bat batch file to stop the Q Capture and Q Apply programs.
- If the Q Apply program did not start for some reason but Q Capture did start, your queues might fill up if the workload is running. In the WebSphere MQ Explorer, open the WORLDWIDE_QM queue manager in the left navigation pane, select Queues, right-click each queue in the Queues table, and select Clear Messages before you restart Q Capture.
- The Q Apply program is set up to stop reading from the queue in case of errors. If Q Apply appears to not be reading data from the queue, you might have to manually start processing by running the start_queues.bat batch file.
- As a last resort, use the stop_repl.bat file to stop the Q Capture and Q Apply programs, drop the LONDON, DALLAS, and TOKYO databases, and start from the beginning.
After you set up your replication configurations and start transactions flowing from the source to the target, you can set up the Q Replication Dashboard to monitor the progress of your replication environment.