IBM Books

Replication Guide and Reference


Operating in a replication environment

After the replication environment is up and running, changes that are made to the replication source will be replicated to the target table. You must prune the control tables periodically to prevent them from growing too large. Although the Capture and Apply programs can run continuously, there are times when you will want to stop them (for example, to run utilities that use the table spaces that contain the control tables).

Step 1: Update the source table

Assume that two new departments were created at the Spiffy Computer Service: a technical writing department and a public relations department.

To update the source table:

  1. Select Start -> Programs -> DB2 for Windows NT -> Command Window to open a DB2 command window.

  2. Check that you are connected to the source server. If you are disconnected, type the following command before going to the next step:
    DB2 CONNECT TO SAMPLE
    

  3. Add two new rows, one for each department, by typing both of the following commands:
    DB2 INSERT INTO DEPARTMENT VALUES ('F01','Technical Writing','000110','F01',NULL)
    DB2 INSERT INTO DEPARTMENT VALUES ('G01','Public Relations','000120','G01',NULL)
    

  4. Connect to the target database by typing the following command:
    DB2 CONNECT TO COPYDB
    

  5. Verify that the new rows are replicated to the target database by typing the following command:
    DB2 SELECT * FROM DEPTCOPY
    

Table 5 shows the results of the replication, with two new rows appended to the table.

Table 5. DEPTCOPY table after changes are replicated
DEPTNO DEPTNAME MGRNO ADMRDEPT LOCATION
A00 Spiffy Computer Service 000010 A00 -
B01 Planning 000020 A00 -
C01 Information Center 000030 A00 -
D01 Development Center - A00 -
D21 Administration Systems 000070 D01 -
E01 Support Services 000050 A00 -
E11 Operations 000090 E01 -
E21 Software Support 000100 E01 -
F01 Technical Writing 000110 F01 -
G01 Public Relations 000120 G01 -

Step 2: Prune the control tables

The following steps assume that the Capture program is running. If the Capture program is not running, the prune command will not work. Usually pruning should occur during offpeak hours.

To verify that there is something to prune:

  1. From a DB2 command window, connect to the source database by typing the following command:
    DB2 CONNECT TO SAMPLE
    

  2. Check that there are some rows in the unit-of-work table by typing the following command from the same window:
    DB2 SELECT COUNT(*) FROM ASN.IBMSNAP_UOW
    

    There should be two rows in the unit-of-work table from the previous replication.

To run the prune command:

  1. Type the prune command; and include the name of the source server:
    ASNCMD SAMPLE PRUNE
    

  2. To verify that the prune command worked, check that the unit-of-work table is empty by typing the following command:
    DB2 SELECT COUNT(*) FROM ASN.IBMSNAP_UOW
    

    There should be no rows in the table.

Step 3: Stop the Capture and Apply programs

An important part of maintaining your replication environment is regular database maintenance. Sometimes that maintenance will require you to stop the Capture and Apply programs. For example, you must stop the Capture and Apply programs before you run utilities that directly use the table spaces that are used by these programs.

To stop the Capture program:

  1. Type the following command from the same DB2 command window:
    ASNCMD SAMPLE STOP 
    

To stop the Apply program:

  1. Type the following command from the same DB2 command window:
    ASNASTOP DEPTQUAL
    

You can run DB2 utilities on your database now that you stopped the Capture and Apply programs. (Running the utilities is beyond the scope of this exercise.)


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]