Creating a replication set using the console

After you enable a Db2® Warehouse SaaS database for replication, you create a replication set to specify a set of tables to be replicated to a designated target.

Before you begin

Ensure that your tables meet replication key requirements.

About this task

Typically your replication set would include tables for which you want to maintain transactional consistency, for example all of the tables that are used by an application. For a replication set, all dependent transactions are applied to the target in the source commit order and other transactions are applied in parallel.

Important: Replication must be activated on the target before a system can be added as a target for replication.

Restrictions:

  • Do not include the same source table in more than one replication set.
  • If you must add a unique constraint to a column-organized table for replication, you must deactivate and reactivate the database before adding the table to the replication set. Otherwise, Db2 performance for delete operations on the table can be significantly degraded because Db2 supplemental logging does not detect the constraint until its cache is refreshed on all data members in the system.

Procedure

  1. From the replication home page of the web console, click Create Replication Set.

  2. Enter the details for connecting to the target database.

    Provide the following information:

    • Database host name or IP address
    • Database port number
    • Replication API server host name
    • Replication API server port number
    • Database name
    • User ID
    • Password

    You can obtain these values by running the following SQL query on the target site:

    
    SELECT PROP_KEY, PROP_VALUE_CHAR, PROP_VALUE_INT
    FROM ASN.IBMQREP_RESTAPI_PROPERTIES
    WHERE PROP_KEY IN (
      'LOCAL_DB2_HOSTNAME',
      'LOCAL_DB2U_EXTERNAL_SSLPORT',
      'LOCAL_CLUSTER_INFRA_HOSTNAME',
      'LOCAL_QREP_REST_EXTERNAL_PORT',
      'LOCAL_DBNAME'
    );
    

    The above query returns the values, that you can enter for adding to the target site:

    • LOCAL_DB2_HOSTNAME – Database host name or IP address
    • LOCAL_DB2U_EXTERNAL_SSLPORT – Database port number (default: 50001)
    • LOCAL_CLUSTER_INFRA_HOSTNAME – Replication API server host name
    • LOCAL_QREP_REST_EXTERNAL_PORT – Replication API server port number (default: 9444)
    • LOCAL_DBNAME – Database name (default: BLUDB)

    Additionally, provide an administrative user ID and password for the target database. The user must belong to the admin (bluadmin) group on the target site. Replication requires administrative privileges for certain operations. Without the required privileges, replication might not function as expected.

  3. Select tables to add to the replication set. You can filter by schema and select all tables that belong to a given schema.

    The console finds all schemas and tables from the source database and gets row counts from the Db2 catalogs. It also checks to see if tables have a unique constraint.

    • To select all tables in a schemas, use the check box to the left of each schema.
    • To select a subset of the tables, click the schema row to view all tables that are part of the schema and select individual tables from the right-side area. The number of tables that you selected appears in the upper right corner. You can search for tables based on the name by using the search boxes.

    When you create the set, one or more target tables are created to match the source tables that you specified for the set, unless such tables already exists.

    Note: The process of preparing the target for replication can take up to 5 minutes. During this time, some Db2 Warehouse SaaS features may be unavailable until the preparation is complete. Adding a target does not block backend operations; however, users must remain on the current page and should not navigate to other screens until the add target operation finishes. Only console operations are restricted during this period.

  4. Enter a name for the replication set and choose among the following options:
    Start replication immediately
    Uncheck this option if you want to manually start replication individually for each table or for groups of tables after the set is created.
    Copy existing table data and replicate future updates
    The target tables are truncated and loaded with the data from the source. Any changes to the source table during the target loading process are staged and applied after the load completes.
    Important: Do not choose this option if you want to preserve the data in the target tables, as in the following examples:
    • The source and target tables are already in sync.
    • Replication is configured in both directions and the load needs to be performed in only one direction (for example, if you are setting up reverse replication from a standby server back to the primary server for supporting a failover/failback scenario).
    Only replicate future updates
    Changes to the source table are replicated to this target. Choose this option when setting up reverse direction replication.

Results

While the target table is prepared, the Replication Set Status column on the replication home page shows a value of Configuring. If you selected Start replication automatically, the value changes to Active when the process completes. Otherwise it changes to Inactive and you should start the set manually.

When you create a replication set:

  • IBM® MQ objects including message queues are created at the target system.
  • Q Replication subscriptions are created and activated for all selected tables.
  • If you specified Copy existing table data and replicate future updates, tables are created at the target database to match the source tables.
  • Target tables are loaded with data from the source by using remote external table load, and are synchronized with the source.

None of these processes affect applications at the source that work with source tables.