centOS7 MySQL主从
修改 /etc/sysconfig/network-scripts/ifcfg-ens33 的ONBOOT=yes
重启网卡 service network restart
yum install mariadb*
systemctl start mariadb
mysql -uroot -p
无密码
修改密码:SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
[mysqld]
log-bin=mysql-bin //二进制日志路径
server-id=1 //服务器ID
创建账号:grant replication slave on *.* to 'dbadmin'@'192.168.34.%' identified by '123123';
从服务器
设置服务器ID server-id=2
配置主从同步
CHANGE MASTER TO
MASTER_HOST='192.168.34.133',
MASTER_USER='dbadmin',
MASTER_PASSWORD='',
MASTER_LOG_FILE='mysql-bin.000001';
start slace
show slave status \G