When the levelDB is mounted to the MySQL engine, it is found that MySQL's heterogeneous data synchronization is simpler and more common when the actual storage is in the key-value format.
Take tair as an example to briefly describe a MySQL-based solution.
Heterogeneous Data Synchronization means that an application only updates MySQL, and some backend mechanisms apply these updates to other data storage services.
1. MySQL-Tair Engine
A) Use
B) Description
This is not a storage engine. In fact, data is stored on the tair server. When executing insert/update/delete, only put/remove the corresponding action to the tair server. Of course, this process is transparent to users.
2. How does MySQL-Tair Engine Update tair data?
First, there are two data update Methods: synchronous update and asynchronous update.
A) asynchronous update
Asynchronous update is introduced first. This is similar to the "read binlog to update data" solution. If you use the MySQL-Tair engine, the structure can be as follows:
Note: The tair table only exists on the Slave and has the same name as the table to be updated on the master database.
Completeness: In the background that the current master database uses a binglog structure in the row format. Here, all the information received on the Slave is the updated complete row information, and the key and value required can be extracted from it.
B) synchronously update
Synchronous update means that MySQL is updated on the application end. After both MySQL and tair are updated, MySQL returns that the user update is successful.
This mode is more like using tair as the MySQL network-level cache service. Of course, when the application reads data, it can bypass MySQL to directly access tair, which is only used as an update solution.
This mode allows the updated next access to directly hit the cache data in tair. Asynchronous mode cannot be guaranteed.
The structure is as follows:
Note: here, the object data table and the tair table are in the same database, with the same table structure and different engines. Use the trigger to trigger the same statement to update the tair table.
Completeness: Similarly, the trigger will get the full value of the updated new row.
3. Advantages of MySQL Synchronization
This has the following advantages, even if only the asynchronous update mode is considered:
A) You do not need to simulate a MySQL slave database or maintain the connection (MySQL comes with it)
B) binlog does not need to be parsed (when to switch the binlog, there are too many things to do)
C) more convenient monitoring. The existing monitoring interface of MySQL directly obtains tps, latency, and synchronization point.
D) more convenient management. If the master database crashes, run the Change master command. If you want to temporarily stop the update, stop slave and start slave.
E) more convenient extension. Directly use MySQL's cascade Master/Slave.
Of course, there are also synchronization options that cannot be implemented by the read binlog solution.
4. Others
Not limited to tair, just for example.
If the backend is a reliable storage, such as TFS, it can be used as a storage table. read/write is an SQL interface. What is the difference with directly updating TFS? Simply put, you can directly join the object table in MySQL.