1.主服务器:
vim /etc/ntp.conf
server 127.127.1.0
fudge 127.127.1.0 stratum 8
systemctl restart ntpd
systemctl enable ntpd
mysqladmin -uroot password 123
vim /etc/my.cnf
server-id = 11
log_bin = master-bin
log-slave-updates = true
systemctl restart mysqld
systemctl restart ntpd
mysql -u root -p
GRANT REPLICATION SLAVE ON . TO ‘myslave’@‘192.168.100.%’ IDENTIFIED BY ‘123’;
flush privileges;
show master status;
测试:(主服务器添加库)
create database lxn;
2.从服务器:
ntpdate 192.168.100.102
vim /etc/my.cnf
server_id = 22
relay-log=relay-log-bin
relay-log-index=slave-relay-bin.index
systemctl restrat mysqld
mysqladmin -uroot password 123
mysql -uroot -p
change master to
master_host=‘192.168.100.102’,master_user=‘myslave’,master__password=‘123’,master_log_file=‘master-bin.000003’,master_log_pos=120;
start slave;
show slave status\G;
测试(从服务器验证)
show databases;