MYSQL生產情境讀寫分離

來源:互聯網
上載者:User

標籤:mysql   生產情境   讀寫分離   

MYSQL生產情境讀寫分離

 

M --------à S

單向同步為保持資料一致性,只能在M上寫入資料

方法:

1、從庫,串連使用者授權上控制

2、Web程式寫指向主,讀指向從

3、讓從庫只能讀不能寫(read-only)

 

生產授權方案1:

主庫:grant select,delete,insert,update on *.*to [email protected]’%’ identified by ‘dongliqiang’;

從庫:grant select on *.* to [email protected]’%’ 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 [email protected]’%’ identified by ‘dongliqiang’;

從庫:grant select,delete,insert,update on *.*to [email protected]’%’ identified by ‘dongliqiang’;

REVOKE update,insert,delete on *.* [email protected]’%’;

生產授權方案3:

主庫:grant select,delete,insert,update on *.*to [email protected]’%’ identified by ‘dongliqiang’;

從庫:grant select,delete,insert,update on *.*to [email protected]’%’ identified by ‘dongliqiang’;

REVOKE update,insert,delete on *.* [email protected]’%’;

從庫my.cnf設定檔增加read-only或者在啟動mysql時增加-—read-only參數

[mysqld]

read-only

 

replication的slave端還有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生產情境讀寫分離

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.