MySQL5.6 master-slave replication and errors encountered

Source: Internet
Author: User
MySQL replication process: each time a write operation is executed, it will save a copy to its own database. At the same time, this write operation will also be stored in a binary log file, and

MySQL replication process: each time a write operation is executed, it will save a copy to its own database. At the same time, this write operation will also be stored in a binary log file, and

MySQL replication process: each time a write operation is executed, it stores a copy in its own database. At the same time, this write operation is also stored in a binary log file, and save them as events. Therefore, each write operation or modification operation on the front-end data in this database will save an event, we will send the event to another server through port 3306 of the mysql server. The other server will receive the event and save it to a local log file, then read an event from this log file and execute it locally, and save it in the database. This process is called mysql replication.

We will not talk about the installation of mysql. We will directly start the configuration process of master-slave replication:

1. Enable the binary log function of the master and slave, that is, in the mysql master configuration file/usr/local/mysql/etc/my. in cnf, add log_bin = mysql-bin, set server_id of master to 1, and server_id of slave to 2.

Below is the master configuration file

[Root @ localhost ~] # Cat/usr/local/mysql/etc/my. cnf | grep-v ^ # | grep-v ^ $
[Mysqld]
Server_id = 1
Log_bin = mysql-bin
Log-bin-index = mysql-bin.index
Log-error =/var/log/mysql/mysql-error.log
General_log = 1
General_log_file =/var/log/mysql. log
User = mysql
Basedir =/usr/local/mysql
Datadir =/datadir
Port = 3306
Socket =/var/lib/mysql/mysql5.sock
SQL _mode = NO_ENGINE_SUBSTITUTION, STRICT_TRANS_TABLES


Next is the slave configuration file.

[Root @ wordpress ~] # Cat/usr/local/mysql/etc/my. cnf | grep-
V ^ # | grep-v ^ $
[Mysqld]
Server_id = 2
Log_bin = mysql-bin
Log-bin-index = mysql-bin.index
General_log = 1
General_log_file =/var/log/mysql. log
Log-error =/var/log/mysql. error
Basedir =/usr/local/mysql
Datadir =/database
Port = 3306
Socket =/var/run/mysqld/mysql. sock
SQL _mode = NO_ENGINE_SUBSTITUTION, STRICT_TRANS_TABLES

Recommended reading:

Load Nginx in Ubuntu for high-performance WEB Server 5 --- MySQL master/Master Synchronization

Production Environment MySQL master/Master synchronization primary key conflict handling

MySQL Master/Slave failure error Got fatal error 1236

MySQL master-slave replication, implemented on a single server

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.