Several implementations of data synchronization the fifth is based on software application synchronization (the first four based on the database level, the fourth to do cluster one master multi-slave. )

Source: Internet
Author: User

Some information about data synchronization that was collected on the previous network

A publish/subscribe approach for synchronization

Publish/subscribe is a mechanism of database backup which is brought by SQL Server, which can quickly realize the synchronization of data backup without writing any code.

This kind of data is synchronized in a way that has some of the following problems:

    1. The table structure cannot be changed, the table structure of both sides of the synchronization must be the same, and the database snapshot needs to be rebuilt once the table structure changes.
    2. There is no reliable guarantee for the synchronization of large data volumes.
    3. Synchronization is not guaranteed in the case of network instability.

In general, this kind of data backup synchronization method, in the table structure consistent, the amount of data is not particularly large case is a very efficient synchronization.

Two data synchronization by SQL job mode

The basic principle of implementing synchronization through SQL job timed jobs is through the connection of the destination server and the source server, and then by writing SQL statements, reading the data from the source server, and then updating to the target server.

Three data synchronization via SQL Server Service Broker Message Queuing

Http://www.cnblogs.com/downmoon/archive/2011/04/05/2005900.html

Four SQL Server AlwaysOn Read and write separations implement a master multiple slave

Disadvantages, can not realize multi-master multi-Slave

Five ORM-based implementations

This is the way your company is used, implemented within the program, using an ORM framework.

5.1 If there is data generated through the manipulation of the interface, it must be saved unless the ORM invokes the Save method

5.2 Increase the listener event at the save point. Save the trigger by adding, deleting, and changing the SQL

5.3 Using another synchronous data service, the SQL data is synchronized to achieve the purpose of synchronizing data

5.4 Using Nhinberate. Methods in File SessionImpl.cs



 public override void Aftertransactioncompletion (bool success, ITransaction TX) {using (New Sessionidlo Ggingcontext (base. SessionId)) {log.                Debug ("Transaction completion"); if (base. Factory.Statistics.IsStatisticsEnabled) {base.                Factory.StatisticsImplementor.EndTransaction (Success);                } this.connectionManager.AfterTransaction ();                This.persistenceContext.AfterTransactionCompletion ();                This.actionQueue.AfterTransactionCompletion (Success); if (this.rootsession = = null) {try {This.int Erceptor.                    Aftertransactioncompletion (TX); } catch (Exception Exception) {log.                    Error ("Exception in Interceptor Aftertransactioncompletion ()", exception);    }                }            if (tx! = NULL) && success)//Important added code {Iaftertransactioncompletioneven  t[] Transactioneventlisteners = this.listeners.TransactionEventListeners;                        The event interface defines for itself the addition of if (Transactioneventlisteners.length > 0) { Dbchangeaction[] Dbchangeaction = this.                        Connectionmanager.getdbchangeaction ();                            for (int i = 0; i < transactioneventlisteners.length; i = (int) (i + 1)) { Transactioneventlisteners[i].                        Ontransactioncompletion (dbchangeaction, this); }                    }                }}        }

  

5.5 in their own programs to implement the interface how to handle the synchronization of data can be

public class Datachangelistener:iaftertransactioncompletionevent    {               private static DataTable cacheddatatasktable = null;        public void Ontransactioncompletion (nhibernate.action.dbchangeaction[] actions, NHibernate.Engine.ISessionImplementor session)        {            //self-determined to process        }/*   var lstn = new Datachangelistener () ;     Eventlisteners.transactioneventlisteners =      New nhibernate.event.iaftertransactioncompletionevent[] {lstn};*/

  

Six uses Moebius for SQL Server Database components, but this component requires a fee

Summary: At present, the best is the fifth or sixth way. There is one other way that I think about the third, and the fifth one. is to create a trigger that increases, deletes, and changes on each table. The changed data is then converted into XML to be automatically stored in another table (this table does not contain a trigger for pruning, using the SQL statement of mode three).
It then uses the program to convert the corresponding XML statements into SQL statements.
Then synchronize the SQL statements to achieve the purpose of synchronizing the data.

Several implementations of data synchronization fifth software-based applications for synchronization (the first four based on the database level, the fourth to do cluster one master multi-slave. )

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.