Data Synchronization Between TiDB and MySQL

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: TIDB和MySQL之间相互数据同步

| username: TiDBer_QHSxuEa1

I would like to ask everyone if there is any way to achieve data synchronization between MySQL and TiDB. For example, if I add, delete, or modify a piece of data in MySQL, TiDB can also synchronize the addition, deletion, or modification. When I add, delete, or modify a table in TiDB, MySQL can also perform the corresponding addition, deletion, or modification synchronously.

| username: WalterWj | Original post link

DM and TiDB TiCDC should not have this feature. It belongs to heterogeneous databases.

| username: 啦啦啦啦啦 | Original post link

One-way synchronization is relatively easy, while two-way synchronization is more difficult. Without a mechanism like MySQL server ID, a single SQL might loop indefinitely. However, two-way replication between two TiDB clusters is possible.

| username: zhanggame1 | Original post link

There is currently no good solution.

| username: redgame | Original post link

Use synchronization tools.

| username: tidb菜鸟一只 | Original post link

Two TiDB clusters can be synchronized bidirectionally through TiDB Binlog or TiCDC, but synchronization between MySQL and TiDB cannot be handled.

| username: TiDBer_QHSxuEa1 | Original post link

Are there any synchronization tools available?

| username: Kongdom | Original post link

:joy: This needs to have an identifier to determine whether the add, delete, modify, and query operations are synchronous or manual~ It’s a bit tricky~

| username: Hacker007 | Original post link

At present, there should be no such tool. DM can achieve synchronization from MySQL to TiDB. If you really need it, you may need to write code yourself to achieve synchronization from TiDB to MySQL.

| username: TiDB_C罗 | Original post link

Is this traffic replay? Look into middleware to see how to implement dual-write.

| username: cassblanca | Original post link

Using a heterogeneous data synchronization component mysql–>canal/seatunnel–>kafka–>flink–>Tidb can be a roundabout way to achieve the goal. The data link is a bit long and can easily encounter issues.

| username: 像风一样的男子 | Original post link

Is it possible to consider this architecture: mysql1=>dm=>tidb=>ticdc=>mysql2? This way, all operations in mysql and tidb will be executed in mysql2.

| username: 有猫万事足 | Original post link

If you have to do it this way, this solution is quite tempting.
Anyway, MySQL read-write separation is also a basic operation. :+1:

| username: 大飞哥online | Original post link

Third-party intervention is needed, such as from the British side, DSG.

| username: 孤君888 | Original post link

You can use the DM component to migrate from MySQL to TiDB, and the CDC component to migrate from TiDB to MySQL. Both have been lightly tested and are functional. If your requirements are highly customized, you will need to carefully review the documentation.

| username: cy6301567 | Original post link

Use DTS

| username: ajin0514 | Original post link

Can Alibaba Cloud DTS be used?