atlas mysql 读写分离_MySQL读写分离工具Atlas
大家好,我是anyux。本文介紹MySQL讀寫分離工具Atlas。
Atlas介紹
原來mha構架下有三臺服務器,利用率只有30%,可以使用Atlas數據庫中間件提高服務器利用率。即利用從庫讀,主庫寫
atlas架構
atlas安裝在應用程序和數據庫服務之間,使用時,應用程序直接連接atlas
注意:
atlas只能安裝在64位系統上
后端mysql版本須大于等于5.6
安裝過程
在新鏈接復制的虛擬機db116上安裝atlas
wget https://github.com/Qihoo360/Atlas/releases/download/2.2.1/Atlas-2.2.1.el6.x86_64.rpmrpm -ivh Atlas-2.2.1.el6.x86_64.rpmcd /usr/local/mysql-proxy/confmv test.cnf test.cnf.bakecho "export PATH=$PATH:/usr/local/mysql-proxy/bin/" >> /etc/profilesource /etc/profile
配置文件
配置文件項可以參考test.cnf.bak,因為atlas是國人基于MySQL-proxy二次開發的軟件產品,注釋也是漢字,很是方便
cat >test.cnf <
啟動atlas
test對應上面的test.cnf文件,可以管理多個mha節點
mysql-proxyd test startps -ef |grep [p]roxyss -lnatup | grep proxy
連接atlas生產端口
cat >/etc/yum.repos.d/mysql-community.repo <
服務器版本Server version:5.0.81
測試讀寫分離
模擬讀操作
select @@server_id;
模擬寫操作
begin;select @@server_id;commit;
添加生產用戶
主庫創建用戶
grant all on *.* to 'app'@'%' identified by 'app';flush privileges;
制作密碼
encrypt app
追加到配置文件
vim /usr/local/mysql-proxy/conf/test.cnfpwds = repl:3yb5jEku5h4=,mha:O2jBXONX098=,app:CsTF0xptdHU=
重啟atlas
mysql-proxyd test restart
測試連接
mysql -uapp -papp -h 192.168.255.116 -P 33060
測試新用戶讀寫分離
select @@server_id;
begin;select @@server_id;commit;
集群管理
連接管理端口
mysql -uatlas -patlas -h 127.0.0.1 -P 2345
連接截圖如下
查看幫助
select * from help;
select * from backends;
backend_ndx是atlas對數據庫節點的編號,使用編號對數據庫進行管理
set offline 2;
臨時停止對后端主機發送請求
set online 2;
開啟對后端數據庫的通信
add master "127.0.0.1:3306";
添加主節點,一般很不用到
remove backend 3;
刪除節點
add slave 192.168.255.115:3306;
添加從節點,較多使用
select * from clients;
查看連接白名單,如果白名單為空,則允許所有ip連接,否則只允許列表中的ip連接,詳情參考備份文件
add client 192.168.255.119;
添加連接白名單
remove client 192.168.255.119;
刪除連接白名單
select * from pwds;
首先要在后端主庫添加生產用戶
grant all on *.* to app01@'%' identified by 'app01';flush privileges;
在atlas中配置用戶
add pwd app01:app01
add enpwd app01:"umY97nPrOgE=";
enpwd表示加密后的密碼
remove pwd app;
save config;
保存修改內容到配置文件中
select version;
記錄的日志
cat log/test.log
總結
以上是生活随笔為你收集整理的atlas mysql 读写分离_MySQL读写分离工具Atlas的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 深度linux安装postgresql_
- 下一篇: linux cmake编译源码,linu