[java two database synchronization] databases with almost the same table structure on the two servers, each has its own data entry, how to ensure that the data of the two tables are synchronized

I feel like doing this, and I will take myself into the pit later. . . And if you do this, why do you need to distinguish between online and offline? Since there is a need to distinguish, there must be some differences. Your needs are a bit unclear.

It is recommended that offline is offline, online is online, and the distinction is made. Offline data is needed. Copy the database file directly from the line. The simple and crude cost is low and it is not easy to go wrong.

In addition, the double-write situation is the MM architecture and design. If the database field is self-increasing, it is impossible to add the same primary key ID online and offline, but the data is different, you will cry, you need to program Compromise, the programmer must be too lazy to change, if the master-slave design, only one can write, do not satisfy your scene.

Preferably, what you call online and offline is the difference between programs, not the difference between data, so that the data falls online, but the data will have some fields to distinguish it, and then, you can make a piece of data offline For example, the master-slave method is used to synchronize the online, but it can not be changed, it is relatively simple, so complicated, and the maintenance cost is too high.

In addition, when MySql is the master and slave, you can mask the table and only synchronize individual tables. You can also look at it. Otherwise, if there is a problem, you will cry when you repair the data.

Guess you like

Origin www.cnblogs.com/sqlserver-mysql/p/12724138.html