mysql的MHA之Atlas 配置, 讀寫分離實現
阿新 • • 發佈:2019-05-11
用戶 http 安裝包 state crypt 進入 rpm 安裝 down
1.安裝 Atlas
#在主庫安裝,進入安裝包目錄 [[email protected]-db01 ~]# cd /home/oldboy/tools/ #下載Atlas [[email protected]-db01 tools]# wget httpss://github.com/Qihoo360/Atlas/releases/download/2.2.1/Atlas-2.2.1.el6.x86_64.rpm #安裝 [[email protected]-db01 tools]# rpm -ivh Atlas-2.2.1.el6.x86_64.rpm Preparing... ########################################### [100%] 1:Atlas ########################################### [100%]
2.編輯配置文件
#進入Atlas工具目錄 [[email protected]-db01 ~]# cd /usr/local/mysql-proxy/bin/ #生成密碼 [[email protected]-db01 bin]# ./encrypt oldboy123 #註意這裏的oldboy123是鏈接mysql的密碼, 我們的密碼是123456 他會生成如下: [[email protected] bin]# ./encrypt 123456 /iZxz+0GRoA= #生成密碼的密鑰對
[[email protected] ~]# vim /usr/local/mysql-proxy/conf/test.cnf #Atlas後端連接的MySQL主庫的IP和端口,可設置多項,用逗號分隔 proxy-backend-addresses = 10.0.0.50:3306 #Atlas後端連接的MySQL從庫的IP和端口 proxy-read-only-backend-addresses = 10.0.0.51:3306,10.0.0.52:3306 #用戶名與其對應的加密過的MySQL密碼 pwds = root:/iZxz+0GRoA= #SQL日誌的開關 sql-log = ON #Atlas監聽的工作接口IP和端口 proxy-address = 0.0.0.0:3307 #默認字符集,設置該項後客戶端不再需要執行SET NAMES語句 charset = utf8
3. 啟動測試
[[email protected] ~]# /usr/local/mysql-proxy/bin/mysql-proxyd test start
OK: MySQL-Proxy of test is started
4. 管理Atlas
#用atlas管理用戶登錄 [[email protected]-db01 ~]# mysql -uuser -ppwd -h127.0.0.1 -P2345 #查看可用命令幫助 mysql> select * from help; #查看後端代理的庫 mysql> SELECT * FROM backends; +-------------+----------------+-------+------+ | backend_ndx | address | state | type | +-------------+----------------+-------+------+ | 1 | 10.0.0.51:3307 | up | rw | | 2 | 10.0.0.53:3307 | up | ro | | 3 | 10.0.0.52:3307 | up | ro | +-------------+----------------+-------+------+ #平滑摘除mysql mysql> REMOVE BACKEND 2; Empty set (0.00 sec) #檢查是否摘除成功 mysql> SELECT * FROM backends; +-------------+----------------+-------+------+ | backend_ndx | address | state | type | +-------------+----------------+-------+------+ | 1 | 10.0.0.51:3307 | up | rw | | 2 | 10.0.0.52:3307 | up | ro | +-------------+----------------+-------+------+ #保存到配置文件中 mysql> SAVE CONFIG; Empty set (0.06 sec)
mysql的MHA之Atlas 配置, 讀寫分離實現