Centos6.5 configure mysql master-slave synchronization process records

Source: Internet
Author: User
Set the mysql Master/Slave function on centos6.5 and record it. Server 1 (master) IP: 192.168.1.201 System Version: centos6.5mysql version: mysql5.5 Server 2 (slave) IP: 192.168.1.202 System Version: centos6.5mysql version: mysql5.5 the system versions of the two servers are the same as those of mysql.

Set the mysql Master/Slave function on centos 6.5 and record it. Server 1 (master) IP: 192.168.1.201 System Version: centos 6.5 mysql version: mysql 5.5 Server 2 (slave) IP: 192.168.1.202 System Version: centos 6.5 mysql version: in mysql 5.5, the system versions of the two servers are the same as those of mysql.

Set the mysql Master/Slave function on centos 6.5 and record it.

Server 1 (master)
IP: 192.168.1.201
System Version: centos 6.5
Mysql version: mysql 5.5

Server 2 (slave)
IP: 192.168.1.202
System Version: centos 6.5
Mysql version: mysql 5.5

The system versions of the two servers are the same as those of mysql, which is also officially recommended. It is best to ensure that the master database is consistent with the slave database before setting.

1. master database and slave database creation synchronization user

Mysql> grant replication slave, replication client on *. * to repl @ '2017. 192.% 'identified by 'Password ';

Master/Slave synchronization is restricted in the LAN.

2. Master Database Configuration

Edit the mysql configuration file/etc/my. cnf and set the following Configuration:

log-bin=mysql-binbinlog_format=mixedserver-id = 1

Binlog_format uses the hybrid mode, which is also the default value of my. cnf in the mysql 5.5 installation package.

3. Slave Database Configuration

Edit the mysql configuration file/etc/my. cnf and set the following Configuration:

log-bin=mysql-binbinlog_format=mixedserver-id = 2relay_log = /var/lib/mysql/mysql-relay-binlog_slave_updates = 1read_only = 1

4. Start the slave Database

mysql> change master to master_host='192.168.1.201',master_user='repl',master_password='100301',master_log_file='mysql-bin.000001',master_log_pos=0;

Enable synchronization

mysql> start slave;

View status

mysql> show slave status\G

View copy status from database

If all the configurations are correct, the master and slave nodes start to work. If the master and slave nodes do not work properly, debug them using the mysql command.

Error debugging

Use show slave status to view Last_IO_Error status information:

mysql> show slave status\G

An error occurred while configuring the connection between the master and slave nodes.

In this case, the master database cannot be connected normally. Because the master database cannot be connected, Slave_IO_State will always display Connecting to master. You can connect to the master database through the mysql client on the slave database for debugging.

$ Mysql-h master database-u repl-p

View Worker Process

View processes on the master database:

mysql> show processlist\G

View master database threads

The State information shows that the master database has sent all binlogs.

View processes from the database:

mysql> show processlist\G

View slave database threads

One is an I/O thread and the other is an SQL thread.

Reprinted, please note: Happy programming» set mysql master-slave synchronization process records in centos 6.5

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.