So konfigurieren Sie die bidirektionale Replikation für eine einzige Tabelle in symmetricDS

2196
Eric Leschinski

Ich habe die Datenbankreplikationssoftware von http://www.symmetricds.org/ auf dem Client und dem Server installiert und konfiguriert . Ich habe die Anweisungen zum Einrichten der Beispielreplikation befolgt und alles funktioniert wie angekündigt.

Ich interessiere mich für die bidirektionale Replikation an einem einzigen Tisch. Das bedeutet, dass jede Datenbank auf dem Client und dem Server eingefügt / aktualisiert / gelöscht werden kann und Änderungen in der anderen Datenbank auftreten. Jede Tabelle ist sowohl Ursprung als auch Ziel des Inhalts für die andere.

Ich habe das gesamte Handbuch für symmetricDS gelesen und es gibt kein Beispiel für die Konfiguration einer bidirektionalen Tabelle. Es gibt einen einzigen Absatz im Handbuch, der besagt, dass dies möglich ist, aber nicht wie.

Wo sind die Anweisungen zum Erstellen der bidirektionalen Datenbankreplikation in symmetricDS? Das Standardbeispiel, das sie bereitstellen, sind Pumpen mit Einzelrichtungsreplikation.

Mein System:

Client: Fedora 17 Linux with postgresql Server: Windows 8 with mysql 

Mein mutmaßlicher Versuch mit bidirektionalen Pumpen ist fehlgeschlagen:

Der Auslöser sym_trigger_routerdefiniert die Richtung, in die die Daten pumpen. Ich erstelle eine Pumpe in beide Richtungen. Dies verursacht jedoch ein Problem mit durch Schlüssel erzwungenen Konflikten. Wenn ein Einfügen, Aktualisieren oder Löschen zum selben Zeitpunkt für denselben Schlüssel ausgeführt wird, muss die Datenbank Abhilfemaßnahmen ergreifen, um die Integrität wiederherzustellen.

Gibt es Anweisungen dazu oder hat jemand dies getan?

0

1 Antwort auf die Frage

0
Eric Leschinski

Bi directional table replication in symmetricDS

Bi directional table replication is not trivial because you must deal with every kind of conflict that could arise. One example conflict is when a row is inserted on both the server and client that would together violate a unique key. Both the client and the server both allow the insert/update to occur because they do not know that there is an incoming update that would violate the key.

The synchronization engine on both sides think: "Oh no, we both told our users that it was OK to add this row based on what we knew, but we can't synchronize now because it would violate uniqueness."

The synchronization engine has a choice:

1. Take the last insert/update by timestamp and destroy the request that came first. This is undesirable because the first person thought they committed, successfully when in reality their transaction was erased without anyone's consent. 2. Reject both rows, if I can't make everyone happy, I'm not letting anything through, and log the conflict to an external table to be dealt with later. The two users who thought they submitted data will find their transaction in a queue. 3. Merge the rows, take a little from one, and a little from the other, and create a hybrid row. Or take one or the other based on some priority system or based on how filled out it is. 

This is just one example of a conflict. There are hundreds of conceivable circumstances where a conflict would arise that you must plan for.

The hundreds of conceivable circumstances where a conflict could happen must have a remedial action defined in the configuration table: sym_conflict.

You could direct symmetricDS to merge the rows according to rules, deny the transactions until a human has reviewed the rows, or even program it to throw out the baby with the bathwater. This is defined in Chapter 3.8 of the user guide, configuring data conflict and resolution.

The number of potential conflicts are based upon the configuration and limitations of your database table. As you add conditions and limitations on your table, the number of potential conflicts increases exponentially. If you have unique keys, you need to prepare for unique key conflicts and define resolutions. If you have primary/foreign keys on other tables, you need conflict resolutions for those. If you get 90% of the conflicts but miss a few, then when the conflicts occur, the databases will not be identical on client and server.