You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/connectors/mysql-cdc.md
+73-5Lines changed: 73 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -218,10 +218,44 @@ Connector Options
218
218
<td>optional</td>
219
219
<td style="word-wrap: break-word;">initial</td>
220
220
<td>String</td>
221
-
<td>Optional startup mode for MySQL CDC consumer, valid enumerations are "initial"
222
-
and "latest-offset".
223
-
Please see <a href="#startup-reading-position">Startup Reading Position</a>section for more detailed information.</td>
224
-
</tr>
221
+
<td>Optional startup mode for MySQL CDC consumer, valid enumerations are "initial", "earliest-offset", "latest-offset", "specific-offset" and "timestamp".
222
+
Please see <a href="#startup-reading-position">Startup Reading Position</a> section for more detailed information.</td>
223
+
</tr>
224
+
<tr>
225
+
<td>scan.startup.specific-offset.file</td>
226
+
<td>optional</td>
227
+
<td style="word-wrap: break-word;">(none)</td>
228
+
<td>String</td>
229
+
<td>Optional binlog file name used in case of "specific-offset" startup mode</td>
230
+
</tr>
231
+
<tr>
232
+
<td>scan.startup.specific-offset.pos</td>
233
+
<td>optional</td>
234
+
<td style="word-wrap: break-word;">(none)</td>
235
+
<td>Long</td>
236
+
<td>Optional binlog file position used in case of "specific-offset" startup mode</td>
237
+
</tr>
238
+
<tr>
239
+
<td>scan.startup.specific-offset.gtid-set</td>
240
+
<td>optional</td>
241
+
<td style="word-wrap: break-word;">(none)</td>
242
+
<td>String</td>
243
+
<td>Optional GTID set used in case of "specific-offset" startup mode</td>
244
+
</tr>
245
+
<tr>
246
+
<td>scan.startup.specific-offset.skip-events</td>
247
+
<td>optional</td>
248
+
<td style="word-wrap: break-word;">(none)</td>
249
+
<td>String</td>
250
+
<td>Optional number of events to skip after the specific starting offset</td>
251
+
</tr>
252
+
<tr>
253
+
<td>scan.startup.specific-offset.skip-rows</td>
254
+
<td>optional</td>
255
+
<td style="word-wrap: break-word;">(none)</td>
256
+
<td>String</td>
257
+
<td>Optional number of rows to skip after the specific starting offset</td>
258
+
</tr>
225
259
<tr>
226
260
<td>server-time-zone</td>
227
261
<td>optional</td>
@@ -527,10 +561,44 @@ both snapshot phase and binlog phase, MySQL CDC connector read with **exactly-on
527
561
The config option `scan.startup.mode` specifies the startup mode for MySQL CDC consumer. The valid enumerations are:
528
562
529
563
-`initial` (default): Performs an initial snapshot on the monitored database tables upon first startup, and continue to read the latest binlog.
564
+
-`earliest-offset`: Skip snapshot phase and start reading binlog events from the earliest accessible binlog offset.
530
565
-`latest-offset`: Never to perform snapshot on the monitored database tables upon first startup, just read from
531
566
the end of the binlog which means only have the changes since the connector was started.
567
+
-`specific-offset`: Skip snapshot phase and start reading binlog events from a specific offset. The offset could be
568
+
specified with binlog filename and position, or a GTID set if GTID is enabled on server.
569
+
-`timestamp`: Skip snapshot phase and start reading binlog events from a specific timestamp.
570
+
571
+
For example in DataStream API:
572
+
```java
573
+
MySQLSource.builder()
574
+
.startupOptions(StartupOptions.earliest()) // Start from earliest offset
575
+
.startupOptions(StartupOptions.latest()) // Start from latest offset
576
+
.startupOptions(StartupOptions.specificOffset("mysql-bin.000003", 4L) // Start from binlog file and offset
577
+
.startupOptions(StartupOptions.specificOffset("24DA167-0C0C-11E8-8442-00059A3C7B00:1-19")) // Start from GTID set
578
+
.startupOptions(StartupOptions.timestamp(1667232000000L) // Start from timestamp
579
+
...
580
+
.build()
581
+
```
582
+
583
+
and with SQL:
584
+
585
+
```SQL
586
+
CREATETABLE mysql_source (...) WITH (
587
+
'connector'='mysql-cdc',
588
+
'scan.startup.mode'='earliest-offset', --Start from earliest offset
589
+
'scan.startup.mode'='latest-offset', --Start from latest offset
590
+
'scan.startup.mode'='specific-offset', --Start from specific offset
591
+
'scan.startup.mode'='timestamp', --Start from timestamp
592
+
'scan.startup.specific-offset.file'='mysql-bin.000003', --Binlog filename under specific offset startup mode
593
+
'scan.startup.specific-offset.pos'='4', --Binlog position under specific offset mode
594
+
'scan.startup.specific-offset.gtid-set'='24DA167-0C0C-11E8-8442-00059A3C7B00:1-19', --GTID set under specific offset startup mode
595
+
'scan.startup.timestamp-millis'='1667232000000'--Timestamp under timestamp startup mode
596
+
...
597
+
)
598
+
```
532
599
533
-
_Note: the mechanism of `scan.startup.mode` option relying on Debezium's `snapshot.mode` configuration. So please do not using them together. If you speicifying both `scan.startup.mode` and `debezium.snapshot.mode` options in the table DDL, it may make `scan.startup.mode` doesn't work._
600
+
**Note:**MySQL source will print the current binlog position into logs with INFO level on checkpoint, with the prefix
601
+
"Binlog offset on checkpoint {checkpoint-id}".It could be useful if you want to restart the job from a specific checkpointed position.
0 commit comments