Atlas
Atlas是由 Qihoo 360, Web平台部基础架构团队开发维护的一个基于MySQL协议的数据中间层项目。
它是在mysql-proxy 0.8.2版本的基础上,对其进行了优化,增加了一些新的功能特性。
360内部使用Atlas运行的mysql业务,每天承载的读写请求数达几十亿条。
下载地址
https://github.com/Qihoo360/Atlas/releases
注意:
1、Atlas只能安装运行在64位的系统上
2、Centos 5.X安装 Atlas-XX.el5.x86_64.rpm,Centos 6.X安装Atlas-XX.el6.x86_64.rpm。
3、后端mysql版本应大于5.1,建议使用Mysql 5.6以上
部署:
不分表安装
wget https://github.com/Qihoo360/Atlas/releases/download/2.2.1/Atlas-2.2.1.el6.x86_64.rpm
yum install -y Atlas-2.2.1.el6.x86_64.rpm
[root@db03 ~]# ll /usr/local/mysql-proxy/ 安装目录
总用量 8
drwxr-xr-x. 2 root root 125 11月 27 15:58 bin
drwxr-xr-x. 2 root root 22 11月 27 15:58 conf 有模板文件 中文
drwxr-xr-x. 2 root root 4096 11月 27 15:58 include
drwxr-xr-x. 4 root root 4096 11月 27 15:58 lib
drwxr-xr-x. 2 root root 6 5月 19 2015 libexec
drwxr-xr-x. 2 root root 22 11月 27 15:58 log
drwxr-xr-x. 3 root root 17 11月 27 15:58 share
cat > test.cnf <<EOF
[mysql-proxy]
admin-username = user ## 管理用户密码
admin-password = pwd
proxy-backend-addresses = 192.168.122.122:3306 #写节点
proxy-read-only-backend-addresses = 192.168.122.104:3306,192.168.122.105:3306 #读节点
pwds = repl:3yb5jEku5h4=,mha:O2jBXONX098= #mysql中管理用户密码
daemon = true
keepalive = true
event-threads = 8
log-level = message
log-path = /usr/local/mysql-proxy/log
sql-log=ON
proxy-address = 0.0.0.0:33060 #连接端口
admin-address = 0.0.0.0:2345
charset=utf8
EOF
启动
root@db03 conf]# /usr/local/mysql-proxy/bin/mysql-proxyd test start ##注意这个test跟配置文件对应
OK: MySQL-Proxy of test is started
登录
mysql -umha -pmha -h 192.168.122.105 -P 33060
db03 [(none)]>select @@server_id;
+-------------+
| @@server_id |
+-------------+
| 104 |
+-------------+
db03 [(none)]>select @@server_id;
+-------------+
| @@server_id |
+-------------+
| 105 |
+-------------+
db03 [(none)]>begin;select @@server_id;commit;
+-------------+
| @@server_id |
+-------------+
| 103 |
+-------------+
可以看到 在查询轮换
在主库创建 管理用户
grant all on *.* to root@'192.168.122.%' identified by '456';
[root@db03 conf]# /usr/local/mysql-proxy/bin/encrypt 456
OoCn/XdFpIg=
vim test.cnf
pwds = repl:3yb5jEku5h4=,mha:O2jBXONX098=,root:OoCn/XdFpIg=
/usr/local/mysql-proxy/bin/mysql-proxyd test restart
mysql -uroot -p456 -h 192.168.122.105 -P 33060
管理
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.55:3306 | up | rw |
| 2 | 10.0.0.51:3306 | up | ro |
| 3 | 10.0.0.53:3306 | up | ro |
+-------------+----------------+-------+------+
REMOVE BACKEND 3; ##移除节点
ADD SLAVE 10.0.0.53:3306; ##添加节点
SAVE CONFIG; ##保存配置
课外拓展
MySQL-Router ---> MySQL官方
ProxySQL --->Percona
Maxscale ---> MariaDB
网友评论