mysql-proxy二进制版本安装测试

环境:

MySQL主库 192.168.160.250

mysql从库  192.168.160.233

mysqlproxy 192.168.110.110

 

 

[root@ local]# getconf LONG_BIT
64

wget http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-Proxy/

网站上下载

wget http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-Proxy/mysql-proxy-0.8.4-linux-rhel5-x86-64bit.tar.gz

tar zxvf mysql-proxy-0.8.3-linux-rhel5-x86-64bit.tar.gz  -C /usr/local/

cd /usr/local/

mv mysql-proxy-0.8.3-linux-rhel5-x86-64bit/ mysql-proxy

vim /etc/profile

export PATH=/usr/local/share/aclocal:/usr/local/mysql/bin:/usr/local/mysql-proxy/bin:$PATH
source /etc/profile

 

[root@xnile local]# mysql-proxy --help
Usage:
  mysql-proxy [OPTION...] - MySQL Proxy


Help Options:
  -?, --help                                              Show help options
  --help-all                                              Show all help options
  --help-proxy                                            Show options for the proxy-module


Application Options:
  -V, --version                                           Show version
  --defaults-file=<file>                                  configuration file
  --verbose-shutdown                                      Always log the exit code when shutting down
  --daemon                                                Start in daemon-mode
  --user=<user>                                           Run mysql-proxy as user
  --basedir=<absolute path>                               Base directory to prepend to relative paths in the config
  --pid-file=<file>                                       PID file in case we are started as daemon
  --plugin-dir=<path>                                     path to the plugins
  --plugins=<name>                                        plugins to load
  --log-level=(error|warning|info|message|debug)          log all messages of level ... or higher
  --log-file=<file>                                       log all messages in a file
  --log-use-syslog                                        log all messages to syslog
  --log-backtrace-on-crash                                try to invoke debugger on crash
  --keepalive                                             try to restart the proxy if it crashed
  --max-open-files                                        maximum number of open files (ulimit -n)
  --event-threads                                         number of event-handling threads (default: 1)
  --lua-path=<...>                                        set the LUA_PATH
  --lua-cpath=<...>                                       set the LUA_CPATH

 

[root@xnile local]# mysql-proxy --help-proxy
Usage:
  mysql-proxy [OPTION...] - MySQL Proxy


proxy-module
  -P, --proxy-address=<host:port>                         listening address:port of the proxy-server (default: :4040)
  -r, --proxy-read-only-backend-addresses=<host:port>     address:port of the remote slave-server (default: not set)
  -b, --proxy-backend-addresses=<host:port>               address:port of the remote backend-servers (default: 127.0.0.1:3306)
  --proxy-skip-profiling                                  disables profiling of queries (default: enabled)
  --proxy-fix-bug-25371                                   fix bug #25371 (mysqld > 5.1.12) for older libmysql versions
  -s, --proxy-lua-script=<file>                           filename of the lua script (default: not set)
  --no-proxy                                              don't start the proxy-module (default: enabled)
  --proxy-pool-no-change-user                             don't use CHANGE_USER to reset the connection coming from the pool (default: enabled)
  --proxy-connect-timeout                                 connect timeout in seconds (default: 2.0 seconds)
  --proxy-read-timeout                                    read timeout in seconds (default: 8 hours)
  --proxy-write-timeout                                   write timeout in seconds (default: 8 hours)

 

[root@xnile local]# vim /etc/mysql-proxy.cnf 

[mysql-proxy]

proxy-address=192.168.110.110:38141    可以修改端口

admin-username=root
admin-password=123456
admin-lua-script=/usr/local/mysql-proxy/lib/mysql-proxy/lua/admin.lua
proxy-backend-addresses=192.168.160.250:3306
proxy-read-only-backend-addresses=192.168.160.233:3306
proxy-lua-script=/usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua
log-file=/var/tmp/mysql-proxy.log
log-level=debug
daemon=true
keepalive=true

 

[root@xnile bin]# vim +40 /usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua 
 29 
 30 local commands    = require("proxy.commands")
 31 local tokenizer   = require("proxy.tokenizer")
 32 local lb          = require("proxy.balance")
 33 local auto_config = require("proxy.auto-config")
 34 
 35 --- config
 36 --
 37 -- connection pool
 38 if not proxy.global.config.rwsplit then
 39         proxy.global.config.rwsplit = {
 40                 min_idle_connections = 1,
 41                 max_idle_connections = 2,
 42 
 43                 is_debug = false
 44         }
 45 end
 46 

保证主从同步可以安装SemiSyncReplication插件

测试挺简单,不写了

[root@xnile bin]# more  /var/tmp/mysql-proxy.log
2014-05-21 11:16:25: (debug) chassis-unix-daemon.c:121: we are the child: 7306
2014-05-21 11:16:25: (message) chassis-unix-daemon.c:136: [angel] we try to keep PID=7306 alive2014-05-21 11:16:25: (critical) plugin proxy 0.8.3 started


2014-05-21 11:16:25: (debug) max open file-descriptors = 65535
2014-05-21 11:16:25: (debug) chassis-unix-daemon.c:157: waiting for 7306
2014-05-21 11:16:25: (message) proxy listening on port :4040
2014-05-21 11:16:25: (message) added read/write backend: 192.168.160.250:3306
2014-05-21 11:16:25: (message) added read-only backend: 192.168.160.233:3306
2014-05-21 11:17:00: (message) chassis-unix-daemon.c:136: [angel] we try to keep PID=7320 alive
2014-05-21 11:17:00: (debug) chassis-unix-daemon.c:157: waiting for 7320
2014-05-21 11:17:00: (debug) chassis-unix-daemon.c:121: we are the child: 7320
2014-05-21 11:17:00: (critical) plugin proxy 0.8.3 started
2014-05-21 11:17:00: (debug) max open file-descriptors = 65535
2014-05-21 11:17:00: (message) proxy listening on port :4040
2014-05-21 11:17:00: (message) added read/write backend: 192.168.160.250:3306
2014-05-21 11:17:00: (message) added read-only backend: 192.168.160.233:3306
2014-05-21 11:25:34: (message) proxy-plugin.c.1664: connect(192.168.160.250:3306) failed: Connection refused. Retrying with different backend.
2014-05-21 11:25:34: (critical) proxy-plugin.c.1773: Cannot connect, all backends are down.
2014-05-21 11:27:34: (debug) network-backend.c.184: backend 192.168.160.250:3306 was down for more than 4 sec, waking it up
2014-05-21 11:40:21: (message) chassis-unix-daemon.c:136: [angel] we try to keep PID=7476 alive
2014-05-21 11:40:21: (debug) chassis-unix-daemon.c:121: we are the child: 7476
2014-05-21 11:40:21: (debug) chassis-unix-daemon.c:157: waiting for 7476
2014-05-21 11:40:21: (critical) plugin proxy 0.8.3 started
2014-05-21 11:40:21: (debug) max open file-descriptors = 65535
2014-05-21 11:40:21: (critical) network-socket.c:451: bind(0.0.148.253:3306) failed: Address already in use (98)
2014-05-21 11:40:21: (critical) chassis-mainloop.c:267: applying config of plugin proxy failed
2014-05-21 11:40:21: (critical) mysql-proxy-cli.c:597: Failure from chassis_mainloop. Shutting down.
2014-05-21 11:40:21: (message) Initiating shutdown, requested from mysql-proxy-cli.c:598
2014-05-21 11:40:21: (message) shutting down normally, exit code is: 1
2014-05-21 11:40:21: (debug) chassis-unix-daemon.c:167: 7476 returned: 7476
2014-05-21 11:40:21: (message) chassis-unix-daemon.c:176: [angel] PID=7476 exited normally with exit-code = 1 (it used 1 kBytes max)
2014-05-21 11:40:21: (message) Initiating shutdown, requested from mysql-proxy-cli.c:273
2014-05-21 11:40:21: (message) shutting down normally, exit code is: 1
2014-05-21 11:41:18: (critical) mysql-proxy-cli.c:503: Unknown option -p (use --help to show all options)
2014-05-21 11:41:18: (message) Initiating shutdown, requested from mysql-proxy-cli.c:513
2014-05-21 11:41:18: (message) shutting down normally, exit code is: 1
2014-05-21 11:41:22: (critical) mysql-proxy-cli.c:503: Unknown option -p (use --help to show all options)
2014-05-21 11:41:22: (message) Initiating shutdown, requested from mysql-proxy-cli.c:513
2014-05-21 11:41:22: (message) shutting down normally, exit code is: 1
2014-05-21 11:49:32: (message) chassis-unix-daemon.c:136: [angel] we try to keep PID=7524 alive2014-05-21 11:49:32: (debug) chassis-unix-daemon.c:121: we are the child: 7524

转载于:https://my.oschina.net/u/588516/blog/756914

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值