5.1.4. Setting the Replication Start Position

Positions within the Oracle replication processe can be identified and/or set using the Oracle System Change Number (SCN) reference. By setting the replication to start at a specific SCN you can take advantage of provisioning, or starting replication on specific known boundaries, for example, after a specific backup operation, or snapshot, has taken place.

By default tpm sets up Oracle replication to start at the current position of the Oracle DBMS, which is denoted by the current SCN. The replicator represents this value using the word NOW. To enable default behavior simply install normally and include the tpm --start-and-report option in the installation. The replicator will extract the first transaction committed after the time when the replicator was installed.

5.1.4.1. Setting a Specific Start Position

To start replication at a specific SCN in the past, you must bring the replicator online explicitly with an option that specifies the exact SCN where replication should start. Here are the exact steps.

  1. Determine the SCN from which you would like to begin replication.

  2. When installing the replicator do not include the --start-and-report option. tpm will install the replicator but will not start the service or bring it online.

  3. After installation completes successfully, start the replicator on the source Oracle instance and bring it online using the following commands:

    shell> replicator start offline
    shell> trepctl online -from-event #####
  4. Start the target replicator(s) normally using:

    shell> replicator start

Replication will now start at the target SCN value. Here is a short example of how to select the target SCN and then bring the replicator online to pick up older changes.

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
14140241

Depending on how old the SCN is the replicator may take a while to extract up to the current position of the Oracle instance. You can confirm that older data were extracted by looking in the log using the thl utility.

5.1.4.2. Resetting Existing Replication to a specific SCN

You can reset replicators to begin extracting from a specific SCN after replication has been installed using the following procedure:

  1. Reset target and source replicators using the reset command to clear all logs:

    shell> multi_trepctl offline
    shell> multi_trepctl -service servicename reset -y
  2. Bring the source replicator online starting at the desired SCN:

    shell> trepctl -host sourcehost online -from-event 14140241
  3. Bring the target replicator online normally:

    shell> trepctl -host targethost online

5.1.4.3. Forcing replication to restart from a new SCN without resetting the THL

You can use the -from-event command to change the position of replication in the source Oracle instance. This allows you to skip over parts of the log or reposition replication without disturbing target replicators.

  1. Bring the source replicator offline and reset the redo component only.

    shell> trepctl -host sourcehost offline
    shell> trepctl -host sourcehost -service servicename reset -redo -y
  2. Bring the source replicator online starting at the desired SCN.

    shell> trepctl -host sourcehost online -from-event 61754320

Target replicators will automatically reconnect to the source replicator.