一、准备两台Mysql服务器
示例:192.168.6.128和192.168.6.130
二、主库配置
1.vi /etc/my.cnf
文件尾部添加以下两行(示例):
server-id=1 //mysql服务ID,保持整个的集群环境唯一,取值范围:1到2^32-1
read-only=0 //权限:0可读可写,1只读
2.重启Mysql
systemctl restart mysqld
3.创建主从复制的账号并授权
#创建连接主库的账号itcast
create user 'itcast'@'%' identified with mysql_native_password by 'Root@1234';
#给itcast授权主从复制的权限
grant replication slave on *.* to 'itcast'@'%';