Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: TIDB和MySQL之间相互数据同步
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.
DM and TiDB TiCDC should not have this feature. It belongs to heterogeneous databases.
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.
There is currently no good solution.
Use synchronization tools.
Two TiDB clusters can be synchronized bidirectionally through TiDB Binlog or TiCDC, but synchronization between MySQL and TiDB cannot be handled.
Are there any synchronization tools available?
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~
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.
Is this traffic replay? Look into middleware to see how to implement dual-write.
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.
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.
If you have to do it this way, this solution is quite tempting.
Anyway, MySQL read-write separation is also a basic operation.
Third-party intervention is needed, such as from the British side, DSG.
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.
Can Alibaba Cloud DTS be used?