BI-Direction

You can configure Repstance to synchronise databases both way (bi-direction configuration). Repstance tracks all the records changed by Apply Processes and by default (see “skipapply” parameter details for SQL Server and Oracle Capture Processes) these records are ignored by any Capture Processes.

BI-Direction configuration requires pair of the Capture and Apply Processes to be configure for each database and both databases to be prepared as a Source and Target. The SQL Server Apply Process supports “replication agent” mode (see “repuser” parameter for details), that is to force SQL Server to handle objects created with “NOT FOR REPlICATION” option as follow:

  • do not fire the triggers created with the “NOT FOR REPlICATION” option
  • do not run “cascade delete/update” operations for foreign keys 
  • do not cause the“identity” column value to be incremented 

The following example shows how to setup BI-direction replication to keep in sync “dbo” schema between two SQL Server databases.

Prepare Databases

Run the following commands to prepare first database as Source and Target:

[http://localhost:8796/] repcli>prepare database=source dbtype=mssql server=10.20.50.1 port=1433 user=sa password=xxx dbname=AdventureWorks2016 [http://localhost:8796/] repcli>prepare database=target dbtype=mssql server=10.20.50.1 port=1433 user=sa password=xxx dbname=AdventureWorks2016 

 

Run the following commands to prepare second database as Source and Target:

[http://localhost:8796/] repcli>prepare database=source dbtype=mssql server=10.20.50.2 port=1433 user=sa password=xxx dbname=AdventureWorks2016 [http://localhost:8796/] repcli>prepare database=target dbtype=mssql server=10.20.50.2 port=1433 user=sa password=xxx dbname=AdventureWorks2016 

 

Prepare Replication Processes

Run the following command to create pair of Capture and Apply Processes for the first database:

[http://localhost:8796/] repcli>prepare process=capture id=1 dbtype=mssql server=10.20.50.1 port=1433 user=sa password=xxx dbname=AdventureWorks2016 name=cap1 dmlinclude=dbo.% autostart=1[http://localhost:8796/] repcli>prepare process=apply id=1 dbtype=mssql capturename=cap2 server=10.20.50.1 port=1433 user=sa password=xxx dbname=AdventureWorks2016 repuser=1 autostart=1

 

Run the following command to create pair of Capture and Apply Processes for the seconds database:

[http://localhost:8796/] repcli>prepare process=capture id=2 dbtype=mssql server=10.20.50.2 port=1433 user=sa password=xxx dbname=AdventureWorks2016 name=cap1 dmlinclude=dbo.% autostart=1[http://localhost:8796/] repcli>prepare process=apply id=2 dbtype=mssql capturename=cap1 server=10.20.50.2 port=1433 user=sa password=xxx dbname=AdventureWorks2016 repuser=1 autostart=1

 

The configuration is done. User “status” and “report” commands to monitor the replication.