MySQL database synchronization with the master-slave synchronization from a single master table

reference

MySQL database is now common database, due to some business needs, a number of different databases on the server needs to synchronize data or part of data synchronization. How to synchronize? How is synchronous to that simple?

Currently there are several options (Reference):

  1. Logical codes to achieve level, the timing to update. More trouble need to compare data between databases, time-consuming, cumbersome, space.
  2. Established by source data triggers real-time synchronization. The disadvantage is reducing business performance, affect the business system
  3. By log synchronize files with a certain delay.
  4. Timestamp: the source table to be synchronized with a timestamp field, whenever the data changes, the time stamp records the time changes.
  5. Comparative data: source data by comparing the data on both sides to complete data synchronization. Generally used for less demanding real-time scene.
  6. Full copies Table: Empty timing of object data source, the data source data source data source overall copied to the destination. Generally the amount of data is small, less demanding real-time scene.

reference

Master-slave synchronization so that data can be copied from one database server to another server, the data is copied, a server acts as the master (Master), from the rest of the server acts as the server (slave).

  1. Rationale:

    1. Binlog log read from the master database IO thread database, writing to, reading from the relay database log file from the SQL database thread from the relay log native native SQL command is executed, data synchronization is completed ;
    2. If a master-slave configuration database inconsistency before the data, SQL thread will error; if an authorized user is created in the main database error, making it impossible to connect the main database from the database, IO thread will error;
    3. When executed relay logs inside SQL command failed SQL thread from the database, SQL thread will immediately shoot down

    Note: Before the master-slave configuration MySQL database, the data can not ensure more than the primary database from the database

  2. Master-slave synchronization configuration instructions:

    1. Modify the my.cnf file on the master:

    2. Modify the configuration file my.cnf from:

    3. Create a synchronization of the main users:

    4. Synchronized to the master library (from the operation):

    5. Open slave state

    6. In the verification from the

    7. From the reset sync:

    8. From the stop synchronization:

Guess you like

Origin www.cnblogs.com/mysql-sql/p/11018438.html
Recommended