1、安装mysql
192.168.1.141 master
192.168.1.143 slave
账号,密码为:root root123456
2、在master创建备份账号,密码。backup backup123456
GRANT REPLICATION SLAVE,RELOAD,SUPER ON *.* TO 'backup'@'192.168.1.%' IDENTIFIED BY 'backup123456';
flush privileges;
3、修改my.cf
vi etc/my.cnf
增加如下内容:
server-id=1
log-bin=mysql-bin
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
至此,master配置完毕
4、配置slave
修改my.cf,增加如下内容:
server-id=1
log-bin=mysql-bin
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
在master中执行 show master status;
在slave中执行
change master to master_host='192.168.1.141',master_user='root',master_password='root123456',master_log_file='mysql-bin.000002',master_log_pos=154;
start slave;
可以,reset master;进行重新配置。
然后执行 show slave status\n;