CentOS 6.5 setup MySQL master-slave synchronization process record

Source: Internet
Author: User
Tags mysql client mysql version

The MySQL master and slave feature is set on CentOS 6.5 and recorded.

Server 1 (primary)
ip:192.168.137.144
System version: CentOS 6.5
MySQL version: MySQL 5.5

Server 2 (from)
ip:192.168.137.185
System version: CentOS 6.5
MySQL version: MySQL 5.5

The system version and MySQL version of both servers here are consistent, which is also the official recommended practice. It is a good idea to ensure that the main library and the library are consistent before starting the setup.

1. Create a sync user from the main library and from the library

mysql> grant replication Slave, replication Client on *. * to [e-mail protected] ' 192.168.137.144 ' identified by ' root ';

2. Main Library Configuration

To edit the MySQL configuration file vim/etc/my.cnf, configure the following settings:

Log-bin=mysql-binbinlog_format=mixedserver-id = 144 #这里设置为服务器地址最后一位

Binlog_format here is the hybrid mode, which is the default value of the my.cnf in the MySQL 5.5 installation package.

3, from the library configuration

To edit the MySQL configuration file/etc/my.cnf, configure the following settings:

Log-bin=mysql-binbinlog_format=mixedserver-id = 2relay_log =/var/lib/mysql/mysql-relay-binlog_slave_updates = 1read _only = 1

4. Boot from library

mysql> Change Master to master_host= ' 192.168.137.144 ', master_user= ' repl ', master_password= ' 100301 ', Master_log_ File= ' mysql-bin.000001 ', master_log_pos=0;

Turn on Sync

mysql> start slave;

View status

Mysql> Show Slave Status\g

Viewing replication status from a library

If the configuration is all right, then master and slave will start to work. If the master-slave is not working properly, you can debug it with the command from MySQL.

Debug error

Use show slave status to view last_io_error status information:

Mysql> Show Slave Status\g

Error in master/slave setup Connection

The above scenario indicates that the main library cannot be connected properly. Because the main library cannot be connected, slave_io_state will always show connecting to master. You can debug from the library by connecting to the main library from the MySQL client.

$ mysql-h Main Library-U repl-p

View worker Processes

View processes on the main library:

Mysql> Show Processlist\g

View the main library thread

From the state information, you can see that the main library has sent all the Binlog

To view a process from a library:

Mysql> Show Processlist\g

View from Library threads

One is an I/O thread and one is an SQL thread.

CentOS 6.5 setup MySQL master-slave synchronization process record

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.