Help Center/ Data Replication Service/ FAQs/ Real-Time Synchronization/ How Do I Specify the Start Point for DRS Incremental Synchronization?
Updated on 2024-11-30 GMT+08:00

How Do I Specify the Start Point for DRS Incremental Synchronization?

MySQL as the Source

For a MySQL incremental synchronization task, you need to specify the start point on the Set Synchronization Task page. The source database logs of the task are obtained from the position after the start point (excluding the current start point).

Figure 1 Start Point

If the gtid_mode parameter of the database is set to on, a start point consists of three parts: file name (File), position (Position), and executed Global Transaction Identifiers Set (Executed_Gtid_Set). You can run the show master status command to obtain these values. If the source database version is MySQL 5.5, it is not supported. When setting Executed_Gtid_Set, you need to delete the newline characters.

For example, the start point about MySQL Community Edition is as follows:

Based on the obtained information, set Executed_Gtid_Set to c8cd8ff7-da6f-11ec-a945-00d861ef1161:1-3,f4f9537f-0c8b-11ec-a284-00d861ef116a:1-10820402.

Figure 2 Setting the start point

SQL Server as the Source

For a SQL Server incremental synchronization task, you need to specify the start point on the Set Synchronization Task page. The source database logs of the task are obtained from the position after the start point (excluding the current start point).

Figure 3 Start Point

Incremental synchronization of the SQL Server database is based on the CDC capability. The start point is the LSN of the SQL Server database. You can run select sys.fn_cdc_get_max_lsn(); to query the current point of the database.

For example, query the current LSN of the database.

Figure 4 Querying the LSN

According to the obtained information, the start point of the task is set as follows:

Figure 5 Setting the start point

DDS as the Source

For out-of-cloud synchronization from DDS to MongoDB and DDS to Kafka, you can specify a start point on the Set Synchronization Task page. The incremental logs of the source database are obtained from the start point (including the current start point). If you do not manually specify a start point, DRS automatically obtains the latest position of the source database.

Figure 6 Setting the start point

The start time of incremental synchronization. The value is in the format of timestamp:incre. timestamp is the Unix timestamp (unit: second), and incre is the command execution sequence in a second. A synchronization task obtains incremental logs of the source database from the start position (including the current start position).

  • For a replica set, run the db.getSiblingDB("local").oplog.rs.find({"ts":{$gte:new Timestamp(<second-level timestamp>,1)}},{"ts":1}).sort({$natural:1}).limit(1) command to query the source database oplog. The query result is in the format of { "ts" : Timestamp(<timestamp>, <inre>) }, which is converted into the format of timestamp:incre.
  • A cluster cannot query the oplog from mongos. timestamp can be converted into the Unix timestamp format based on the start time. The value of incre is 1.

For example, the source database is a DDS replica set, and the expected second-level timestamp for incremental synchronization is 1721382900 (2024-07-19T17:55:00+08:00). The following figure shows the query result in the source database. According to the obtained information, the start point of the task can be set to 1721382921:554.

Figure 7 Example of the oplog query result

Oracle as the Source

For an Oracle incremental synchronization task, you need to specify the start point on the Set Synchronization Task page. The source database logs of the task are obtained from the position after the start point.

Figure 8 Capture Start Point

The start point of incremental synchronization is the SCN of the source database.

You can run the select current_scn from v$database; command to obtain the current SCN of a database.