Home / Repstance User Guide / CONFIGURE REPLICATION WITH REPSTANCE / Basic Replication Configuration

Basic Replication Configuration

The following steps are to setup simple one-direction replication between two SQL Server databases, assuming that Repstance is up and running and has access to both Source and Target databases having “dbo” schema with the same set of tables and data. In this example we configure replication using repcli tool, however the same configuration can be implemented via Web User Interface or REST API.

 

Invoke "repcli" Utility

Use SSH protocol to connect to the Repstance Server and run repcli command to enter “Fully Interactive Mode“:

[ec2-user@ip-172-31-36-221 ~]$ repcli
Repstance CLI [Version 5.2.0095(AWS)]
Copyright (c) 2020 Collabcloud Limited.
 
[http://localhost:8796/] repcli>

 

Configure Source Database

The Capture Process requires minimal set of the Repstance’s objects to be installed in the Source Database. To simplify the configuration process Repstance implements the "prepare database" command that creates all the objects needed for the process. The command is also used to generate SQL script to be run directly in the database. 

Run the “prepare database” command to configure Source database:

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

The “database=source” parameter instructs Repstance to create "Capture" objects, the “dbtype=mssql”  says that the RDBMS type is SQL Server (see Prepare Source Database for the details) and the rest of the parameters are to provide connectivity details. 

Configure Capture Process

Run the following repcli command to create the Capture Process:

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

The  “id=1” specifies Capture ID, that is used to start, stop, modify or delete the process and the "name=rep1"  provides name of the Capture Process that is used by Apply Process/Processes to “link” this Capture Process (see Prepare Capture Process for more details).

The “dmlinclude=dbo.%”  and “ddlinclude=dbo.%”  tells Repstance to replicate all DML and DDL changes in the “dbo” schema. See Capture Objects Specification for the details.

Configure Target Database 

Likewise the Source database the Target database should be prepared.

Run the following repcli command to prepare Target database:

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

You can find more details on how to prepare SQL Server or any other databases as a Target in chapter Prepare Target Database.

Configure Apply Process

Run the following repcli command to create Apply Process:

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

The “capturename=rep1”  is to connect the Apply Process to the “rep1” Capture Process, while rest of parameters are similar to the Capture Process ones.

See chapter Prepare Apply Process for more details.

Start the Processes 

Once the processes are configured run the following commands to start the processes, that is to start the replication:

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

 

Monitor Replication Status

Use “status” command to view the replication details:

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)