Testing replication

After you finish setting up the replication system, you can test replication.

StepsTesting replication

  1. Connect to the primary IBM DB2 Universal Database instance as a regular user, not the maintenance user. Make sure the regular user also exists in the replicate database.

    1. To connect to the database with CLP, use:

      CONNECT TO dbalias USER db2_user USING db2_user_ps
      

      Here, dbalias is the cataloged alias of the primary database, db2_user is the primary database user, and db2_user_ps is the password.

  2. Create a test table in the primary database:

    create table T1( a int, b char(10))
    
  3. Grant permissions to any new or existing object to be replicated in the primary database:

    grant all on T1 to public
    
  4. Create a test table in the replicate database:

    create table T1( a int, b char(10))
    
  5. Grant permissions to any new or existing object to be replicated in the replicate database, so that the Replication Server maintenance user can update this table:

    grant all on T1 to public
    
  6. Connect to the Replication Agent and run the following command to mark the table:

    pdb_setreptable T1, mark
    
  7. After the table is marked and the Replication Agent is in a replicating state, insert test data into the test table and commit it.

    By default, the work performed by the maintenance user of the primary connection is not replicated. The user ID used to insert transactions cannot be the same as the maintenance user defined in the primary connection. See “Configuring Replication Server for replication from the primary database”.

  8. Use your preferred IBM DB2 Universal Database query tool to examine the replicate site for results and compare the contents of your test table from both the primary and replicate sites.