Home / Knowledge base / 5. HOW TO USE REPSTANCE

To replicate data Repstance uses Capture and Apply Processes. The Capture Process extracts data from the Source Database and puts it into locally stored Trail Files in the same sequential order as the transactions occurred in the database. The Trial Files are consumed by Apply Process to insert the captured data into the Target Database. The Apply Process can also modify data or/and data definition if the appropriable transformation rules are configured.

Before running the Capture and Apply Processes both Source and Target Databases need to be prepared by meaning that the minimal set of the Repstance’s objects must be installed. Repstance has built-in functionality that allows it to prepare databases by simply running the CLI or REST API command (see chapter 7.1 Prepare Source and Target Databases) or via Web UI (see chapter 8.2.1 Database Configuration).

Once it is done, we recommend validate both databases by running the “validate” command (see chapter 7.3 Validate Source and Target Database if using CLI or REST API, or chapter 8.2.1 Database Configuration for Web UI) to make sure that the necessary functionality is installed.

The next step is to configure the replication processes.

This is to be done in two parts, the first is to configure the Capture Process, which is extracting the data from the specified Source Database, and the second is to configure the corresponding Apply Process, which will insert the “captured” data into the specified Target Database. The both Processes can be configured either using CLI or REST API (see chapter 7.4 Prepare Capture Process and 7.9 Prepare Apply Process) or through the Web UI (see chapter 8.2.2 Processes Configuration).

The data to be replicated will be defined during the Capture Process configuration. Validation of correctly constructed Capture or Apply Processes can be checked using the “validate” command. See chapters 7.7 Validate Capture Process, 7.12 Validate Apply Process or 8.2.2 Process Configuration for the details.

For MS SQL Server the Capture Process will enable CDC on the specified tables only the first time it is run. If the Capture Process is “altered” at any point, during the next “run” it will disable CDC on the unwanted tables and initialize CDC on any new tables that are specified.

The first time Capture Process is run, is the first point and the only point at which data will start to be captured by this Process.

Assuming that the Capture Process has been properly configured and run, only at this point it will start to produce Trail Files, which can be used by Apply Process.

In order for an Apply Process to succeed, of necessity the Trail Files of the corresponding Capture Process must exist.

In order to ensure that an Apply Process will start from the specified LSN/SCN, this LSN/SCN must exist in the Trail Files and the “reset” command (see chapter 7.13 Reset Apply Process) can be used to point this Apply Process at the required LSN/SCN. If the Apply Process has not been reset, it will start processing data from the first available transaction found in the Trail File.

Once the Apply Process has been configured to use and the proper LSN/SCN (if needed) has been specified, the Apply Process can be run (see chapter 7.15.1 Run any Capture or Apply Processes and 8.2.2 Process Configuration).

At the point when both the Capture and Apply Processes are running, the “status” command (see chapter 7.15.3 Status of any Capture or Apply Process and 8.2.2.4 Processes Monitoring and Maintenance) can be used to monitor them.

In the event it is necessary to ”stop” any currently running processes use the “stop” command (see chapter 7.15.2 Stop any Capture or Apply Processes and 8.2.2.4 Processes Monitoring and Maintenance).

The following example demonstrates how to setup simple DML and DDL replications between two MS SQL Server databases for all objects located in the dbo schema using repcli tool:

repcli>prepare database=source dbtype=mssql server=source.repstance.com port=1433 user=ds password=secret dbname=sdemo
[Completed]: Database [source.repstance.com:1433,sdemo] has been prepared

 

repcli>prepare database=target dbtype=mssql dbtype=mssql server=target.repstance.com port=1433 user=ds password=secret dbname=tdemo
[Completed]: Database [target.repstance.com:1433,tdemo] has been prepared

 

repcli>validate  database=source dbtype=mssql server=source.repstance.com port=1433 user=ds password=secret dbname=sdemo
[Valid]: Database SDEMO is valid

 

repcli>validate database=target dbtype=mssql server=target.repstance.com port=1433 user=ds password=secret dbname=tdemo
[Valid]: Database TDEMO is valid

 

repcli>prepare process=capture dbtype=mssql id=1 name=rep1 server=source.repstance.com port=1433 user=ds password=secret dbname=sdemo dmlinclude=dbo.% ddlinclude=dbo.%
[Completed]: Capture 1 has been added

 

repcli>validate process=capture id=1
[Valid]: Capture process 1 is valid

 

repcli>run process=capture id=1
[In Process]: Command [RUN] has been sent. Use [status] command to monitor the Capture 1 process

 

repcli>prepare process=apply id=1 dbtype=mssql capturename=rep1 server=target.repstance.com port=1433 user=ds password=secret dbname=tdemo repuser=1
[Completed]: Apply 1 has been added

 

repcli>validate process=apply id=1
[Valid]: Apply process 1 is valid

 

repcli>run process=apply id=1
[In Process]: Command [RUN] has been sent. Use [status] command to monitor the Apply 1 process

 

repcli>status
Capture Process 1, Name: rep1, DB: sdemo, Server: source.repstance.com
  RUN (In Process), Waiting for Transactions
    Last Source DB Change : 2019/02/25 21:13:00.173 UTC (0x00000044000002AE0004)
    Last Captured DB Change : 2019/02/25 21:13:00.173 UTC (0x00000044000002AE0004)
  Total since  2019/02/25 21:10:00.983 UTC (0x000000440000020A0004):
    Processing the Transactions :  00:00:05.289
    Waiting for Transactions    :  00:02:44.396
    Average Speed (ops)   :  1.134
    Transactions: 6 (DDL: 0,  Delete: 3,  Insert: 3,  Update: 0)
Apply Process 1, Transactions Provider (Capture): rep1, DB: tdemo, Server: target.repstance.com
  RUN (In Process), Waiting for Transactions
    Last Source DB Change  : 2019/02/25 21:13:00.173 UTC (0x00000044000002AE0004)
    Last Applied DB Change : 2019/02/25 21:13:00.173 UTC (0x00000044000002AE0004)
    Lag                    :  00:00:00.000
  Total since  2019/02/25 21:13:00.150 UTC (0x00000000000000000001):
   Processing the Transactions :  00:00:02.065
   Waiting for Transactions    :  00:00:08.284
   Average Speed (ops)   :  2.905
   Transactions: 6 (DDL: 0,  Delete: 3,  Insert: 3,  Update: 0)

 

On this page