标签:user status 信息 systemctl osi sql fir word replica
centos 7 配置 mysql 5.7 主从复制
1. 主库从库所在服务器关闭防火墙
Systemctl stop firewalld
2. 主从库安装mysql 5.7
3. 修改主库/etc/my.cnf添加如下内容:
log-bin=mysql-bin
server-id=663
4. 重启主库mysql数据库
/etc/init.d/mysqld restart
5. 查看主库状态
show master status;
记录好File和Position,后面要用
6. 在主库上建立帐户
create user ‘repl’@’192.168.66.2’ identified by ‘mysql’;
7. 授权
grant replication slave on *.* to ‘repl’@’192.168.66.2’ identified by ‘mysql’;
8. 刷新权限
Flush privileges;
9. 修改从库/etc/my.cnf添加如下内容:
server-id=662
log-bin=mysql-bin
10. 重启从库mysql数据库
/etc/init.d/mysqld restart
11. 配置连接主服务器的信息:
mysql> stop slave;mysql> CHANGE MASTER TO
-> MASTER_HOST=‘192.168.66.3‘,
-> MASTER_USER=‘repl‘,
-> MASTER_PASSWORD=‘mysql‘,
-> MASTER_PORT=3306,
-> MASTER_LOG_FILE=‘mysql-bin.000001‘,
-> MASTER_LOG_POS=154;
mysql> start slave;
12. 查看状态
Show slave status\G;
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
标签:user status 信息 systemctl osi sql fir word replica
原文地址:https://www.cnblogs.com/orcl-2018/p/11437653.html