MySQL Proxy
1.5.1. Ubuntu
安装环境 Ubuntu 13.04
$ sudo apt-get install mysql-proxy
ENABLED改为true
$ sudo vim /etc/default/mysql-proxy ENABLED="true" OPTIONS="--defaults-file=/etc/mysql/mysql-proxy.cnf"
配置 /etc/mysql/mysql-proxy.cnf
$ sudo vim /etc/mysql/mysql-proxy.cnf [mysql-proxy] daemon = true user = mysql proxy-skip-profiling = true keepalive = true max-open-files = 2048 event-threads = 50 pid-file = /var/run/mysql-proxy.pid log-file = /var/log/mysql-proxy.log log-level = debug admin-address=:4401 admin-username=admin admin-password=passw0rd admin-lua-script=/usr/local/lib/mysql-proxy/lua/admin.lua proxy-address = 0.0.0.0:3307 proxy-backend-addresses = 192.168.2.1:3306 proxy-read-only-backend-addresses=192.168.6.2:3306, 192.168.6.1:3306 proxy-lua-script=/usr/lib/mysql-proxy/lua/proxy/balance.lua
修改权限,这个步骤不能省略,否则无法启动。
$ sudo chmod 0660 /etc/mysql/mysql-proxy.cnf
启动mysql-proxy
$ sudo /etc/init.d/mysql-proxy start * Starting MySQL Proxy daemon... [ OK ]
测试3307端口
$ mysql -hlocalhost -P3307 -uroot -p