首页 > 数据库技术 > 详细

MYSQL生产场景读写分离

时间:2017-11-03 23:45:57      阅读:444      评论:0      收藏:0      [点我收藏+]

MYSQL生产场景读写分离

 

M --------à S

单向同步为保持数据一致性,只能在M上写入数据

方法:

1、从库,连接用户授权上控制

2、Web程序写指向主,读指向从

3、让从库只能读不能写(read-only

 

生产授权方案1

主库:grant select,delete,insert,update on *.*to rep@’%’ identified by ‘dongliqiang’;

从库:grant select on *.* to rep@’%’ identifiedby ‘dongliqiang’;

my.cnf 忽略授权表

binlog-ignore-db=mysql

binlog-ignore-db=information_schema

binlog-ignore-db=performance_schema

生产授权方案2

主库:grant select,delete,insert,update on *.*to rep@’%’ identified by ‘dongliqiang’;

从库:grant select,delete,insert,update on *.*to rep@’%’ identified by ‘dongliqiang’;

REVOKE update,insert,delete on *.* fromdonglq@’%’;

生产授权方案3

主库:grant select,delete,insert,update on *.*to rep@’%’ identified by ‘dongliqiang’;

从库:grant select,delete,insert,update on *.*to rep@’%’ identified by ‘dongliqiang’;

REVOKE update,insert,delete on *.* fromdonglq@’%’;

从库my.cnf配置文件增加read-only或者在启动mysql时增加-—read-only参数

[mysqld]

read-only

 

replicationslave端还有6个参数

1--replication-do-db               设定需要复制的数据库以逗号(,)分割

2--replication-ignore-db         设定需要排除的数据库以逗号(,)分割

3--replication-do-table           设定需要复制的表以逗号(,)分割

4--replication-ignore-table     设定需要排除的表以逗号(,)分割

5--replication-wild-do-db      等同于1,但可以加通配符

6--replication-wild-ignore-db等同于2,但可以加通配符


本文出自 “董利强” 博客,请务必保留此出处http://6207422.blog.51cto.com/6197422/1978796

MYSQL生产场景读写分离

原文:http://6207422.blog.51cto.com/6197422/1978796

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!