当前位置:网站首页>Mysql5.7 master-slave hot standby settings on CentOS

Mysql5.7 master-slave hot standby settings on CentOS

2022-07-27 16:16:00 Carrot eating crocodile

mysql Installation :https://blog.csdn.net/qq_37135484/article/details/78594782
Premise : Make sure that servers can communicate with each other ping through , Mutual login .

1. Server introduction

Lord (master):192.168.78.154
from (slave):192.168.78.155
All users are root, The password for :123456

2. Main server configuration

1) Set up /etc/my.cnf
Main configuration server-id( Each server is required id only )
and log Binary system (log-bin=mysql-bin)

vim  /etc/my.cnf

Add... At the end

server-id=1
log-bin=mysql-bin
binlog-ignore-db=mysql

The effect is shown in the small picture :

 Insert picture description here
2) Set the user permissions of the slave server , It is convenient to read and copy the contents of the master server from the server users

grant replication slave,replication on *.* to 'root'@'192.168.78.155' identified by '123456';

User name and IP All are slave servers
May come across Your password does not satisfy the current policy requirements This mistake , Refer to the blog at this time https://blog.csdn.net/qq_37135484/article/details/98735515

3) Log in to the main server mysql View the status of the primary server

show master status;

 Insert picture description here

Remember this time File and Position, It will be used when configuring the slave service
4) Refresh

flush privileges;

 Insert picture description here

3. Slave server configuration

1) Configure from the server /etc/my.cnf

 Insert picture description here
2) land mysql stay mysql Execute the following command at the command line :

CHANGE MASTER TO MASTER_HOST='192.168.78.154',MASTER_USER='root',MASTER_PASSWORD='123456',MASTER_LOG_FILE='mysql-bin.000004',MASTER_LOG_POS=763;

Among them MASTER_LOG_FILE=‘mysql-bin.000004’,MASTER_LOG_POS=763;
Execute the command corresponding to the main server above show master status; Display data
 Insert picture description here
Then start slave;

 start slave;

 Insert picture description here
3) see slave state

show slave status\G

 Insert picture description here
If Slave_IO_Running and Slave_SQL_Running All items are yes It means that the master-slave replication configuration is successful , Otherwise failure , Don't panic about failure , There will be an error prompt below .

原网站

版权声明
本文为[Carrot eating crocodile]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/208/202207271439465415.html