MySQL Data Synchronization-replication

Source: Internet
Author: User

1. Basic Steps for copying

It takes only three steps to create a simple copy.

  1. Configure a server as the Master database, that is, the Master database.
  2. Configure another server as the slave database, that is, the slave database.
  3. Connect the slave database to the master database.
2. Configure the master database
To configure the server as the master database, make sure that the server has an active binary log and a unique server ID. This binary log stores all data changes in the master database, the server ID is used to identify the server separately. To create a binary log and a server ID, stop the server and configure the my. cnf configuration file. The operations on the master database mainly include the configuration of binary log files and the addition of accounts for replication;
2.1 configure the binary log file
I added the following three lines to my master database configuration file:
  1. Log-bin = master-bin
  2. Log-bin-Index= Master-bin.Index
  3. Server-id = 1
After I added these three lines, I restarted the service and found two more files under the Data Directory: master-bin.000001, master-bin.index. These two files play a major role in master-slave synchronization.
In fact, in addition to these three configurations, you can also add some other configurations, such as binlog-ignore-db configuration databases that do not need to be synchronized.
2.2 Add a duplicate account
Create account: create user repl_user; Grant Account replication permission: grant replication slave on *. * to repl_user identified by 'pwd ';
  • 1
  • 2
  • 3
  • Next Page

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.