mysql主从架构搭建

1.配置文件,开启二进制日志

  vim /etc/my.cnf

 在mysql下增加如下内容

 1 server-id=1

2 log-bin=mysql-bin

3 relay-log=mysql-relay 

2.登录到本地mysql上,给从slave主机授权,同步日志的权限

 1 mysql -uroot -p
 2 
 3 
 4 grant replication slave on *.* to 'tom'@'%' identified by '123';
 5 flush privileges;    #刷新权限
 6 
 7 show master status;
 8 
 9 stop slave;
10 change master to
11 master_host='ip',
12 master_user='tom',
13 master_password='123',
14 master_log_file='mysql-bin.000001',
15 master_log_pos=331;
16 
17 start slave;
18 
19 show slave status \G;  # 查看slave状态

 

posted @ 2019-11-30 17:05  Security  阅读(119)  评论(0编辑  收藏  举报