MySQL Master-slave configuration

Source: Internet
Author: User

The        mysql built-in replication feature is the foundation for building MySQL-based large-scale, high-performance applications that use the so-called "horizontal scaling" architecture.          Replication solves the basic problem of keeping one server's data in sync with other servers. Data from one master library can be synchronized to multiple standby libraries. The repository itself can also be configured as the main repository for another server. There are several combinations of primary and standby.          MySQL supports replication in 2 ways: row-based replication and statement-based replication. Both of these methods enable asynchronous data replication by recording binary logs on the main library and replaying the logs in the standby repository. This means that at the same point in time, the data on the standby may be inconsistent with the primary inventory, and there is no guarantee of the delay between the primary and standby, and some large statements can cause the standby to generate a delay of several seconds, a few minutes or even a few hours.         mysql replication is mostly backwards compatible, and the new version of the server can be used as a repository for older versions, but not in the reverse. For possible reasons, the old version may not be able to resolve the new feature or syntax used by the new version, and the binary file used may have a different format. Therefore, it is a good idea to test the replication settings before making a large version upgrade. However, for minor version number upgrades, it is usually compatible.        Replication typically does not increase the overhead of the main library, primarily the overhead of enabling binary logging, primarily the overhead of enabling binary logging, but it is also necessary to be in a backup or to recover from a crash in a timely manner, In addition, the repository adds some load to the main library, such as network I/O overhead, which can result in higher I/O overhead, especially when the repository request reads the old binary log files from the main library. At the same time, the mechanism of competition may hinder the submission of things. Finally, if you are replicating multiple repositories from a high-throughput primary library, the overhead of waking up multiple replication threads to send events is cumulative.          MySQL replication allows read operations to be distributed across multiple servers for read-intensive optimizations. Replication is a significant technical supplement for backups, but replication is neither a backup nor a substitute for backup. Replication can help the application avoid MySQL single point failure.          figure: How MySQL replication works   Configuring replication for MySQL servers is simple,Due to different scenarios, there will be a slight difference of 1, create replication account 2 on each server, configure the master and Standby 3, notify the repository to connect to the main library and copy data from the main library  1, create a replication account mysql> grant  Replication slave,replication client on *.* to [email protected] ' 192.168.110.136 '  identified by  ' abc-123 '; query ok, 0 rows affected  (0.01 sec)   Open Some settings on the main library, you need to turn on the binary log and specify a unique sever ID Add or modify the following content in the My.cnf file of the main library masterlog_bin = mysql-binserver_id = 5  If you do not specify the Log-bin option in the previous MySQL configuration file, you will need to restart MySQL, and you can use show Master status to check  slavelog_bin = mysql-binserver_ id = 6relay_log = /var/lib/mysql/relay-binlog_slave_updates = 1read_only =  1  Restart slave perform replication stop slave;change master to master_host= ' 192.168.110.135 ', master_ User= ' Rep1 ', master_password= ' abc-123 ';start slave;  view slave status show slave status\g;    can see the copied thread  end from the main library and from the Library with show Processlist!   This article mainly refer to "high performance MySQL"  

MySQL master-slave configuration

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.