Home  >  Article  >  Database  >  Configure Mysql master-slave service instance

Configure Mysql master-slave service instance

小云云
小云云Original
2018-01-13 14:23:091687browse

This article mainly introduces the relevant information for configuring Mysql master-slave service implementation examples. Friends who need it can refer to it. I hope it can help everyone.

Configure Mysql master-slave service implementation instance


Configure the master database my.cnf


server-id=1
log-bin=master-bin
log-bin-index=master-bin.index

Create a synchronization account on the master database



create user backup;
GRANT REPLICATION SLAVE ON *.* TO 'backup'@'192.168.%.%' IDENTIFIED BY 'mysql';

Configure the slave database my.cnf


server-id=2
relay-log-index=slave-relay-bin.index
relay- log=slave-relay-bin


Restart the mysql service


service mysqld restart

Connect to the Master service



change master to master_host='192.168.91.128',
master_port=3306,master_user='backup',master_password='mysql',
master_log_file='master-bin.000001',master_log_pos=0;

Start slave service


start slave;


Check Master service status


SHOW MASTER STATUS;

Check the Slave service status


SHOW slave STATUS \G;

Check whether the server_id is the same, it needs to be different


show variables like 'server_id';

Common Errors


Error:

Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.

Solution:

Check the server-uuid in auto.cnf in the data directory =******************** Whether they are the same, change it to differentRelated recommendations:

Mysql master-slave server architecture configuration

#########Mysql master-slave server configuration special issues############MySQL database configuration master-slave server to achieve dual-machine hot backup Example tutorial######

The above is the detailed content of Configure Mysql master-slave service instance. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn