1.1 搭建两台MySQL
192.168.1.30 master
192.168.1.31 slave
1.1 关闭防火墙
systemctl stop firewalld
1.1 修改主服务器(master)配置:
vim /etc/my.cnf [mysqld] log-bin=mysql-bin server-id=111
1.1 修改从服务器(slave)配置:
vim /etc/my.cnf [mysqld] server-id=112
1.1 重启主从两个mysql服务
service mysqld restart
1.1 在主库建一个专用来备份的 MySQL 账户
grant replication slave,reload,super on *.* to 'backup'@'192.168.1.31' identified by 'password'; flush privileges; show master status;
backup:账号名 password:密码 192.168.1.31:从库IP地址
1.1 修改从库配置
change master to master_host='192.168.1.30', master_user='backup', master_password='password', master_log_file='mysql-bin.000001', master_log_pos=425;
1.1 启动查看
start slave ;
show slave statusG;