一、项目架构图
二、项目环境
准备六台linux虚拟机(centos7)
master,slave1,slave2(安装mysql8.0)
router1,router2(安装mysqlrouter,keepalived)
client(安装mysql8.0)
一键安装mysql8.0https://blog.csdn.net/asdfkajhaf/article/details/127520693?spm=1001.2014.3001.5502
三、项目步骤
1、关闭防火墙
systemctl disable firewalld
2、在master、slave1、slave2上开启二进制日志且server-id不能一样
vi /etc/my.cnf打开mysql修改配置文件,添加以下内容
server-id = 136
bin_log
然后刷新服务service mysql restart
3、master创建用来复制二进制日志的用户并给与权限
mysql> create user 'yan'@'%' identified by 'Yan2022!';
Query OK, 0 rows affected (0.13 sec)
mysql> grant replication slave on *.* to 'yan'@'%';
Query OK, 0 rows affected (0.00 sec)
4、master刷新日志并记录位置号
mysql> flush logs;
Query OK, 0 rows affected (0.02 sec)
mysql> show master status;
+----------------+----------+--------------+------------------+------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+----------------+----------+--------------+------------------+------------------------------------------+
| 192-bin.000011 | 197 |