--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
master操作:
mysql> grant all on *.* to 'mysql-proxy'@'192.168.0.%' identified by '123456';
mysql> select user,host from mysql.user;
slave操作:
mysql> grant all on *.* to 'mysql-proxy'@'192.168.0.%' identified by '123456';
mysql> select user,host from mysql.user;
vi /etc/init.d/mysql-proxy#编辑mysql-proxy管理脚本
#mysql-proxy.scripts,2015-11.25,linux
############################################
#!/bin/sh
export LUA_PATH=/application/mysql-proxy/share/doc/mysql-prox
y/?.lua:/applicaton/mysql-proxy/lib/mysql-proxy/lua/?.lua
mode=$1
if [ -z "$mode" ] ; then
mode="start"
fi
case $mode in
'start')
mysql-proxy --daemon \
--log-level=debug \
--user=mysql-proxy \
--keepalive \
--log-file=/var/log/mysql-proxy.log \
--plugins="proxy" \
#mysql-proxy.scripts
[iyunv@test-C ~]# mysql -umysql-proxy -p -h 192.168.0.149 --port 4040
Enter password: #多开几个终端,测试连接
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 32
Server version: 5.5.32-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select user,host from mysql.user;
[iyunv@test-C ~]# mysql -uadmin -p -h 192.168.0.149 --port 4041
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.99-agent-admin
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select * from backends;
+-------------+--------------------+---------+------+------+-------------------+
| backend_ndx | address | state | type | uuid | connected_clients |
+-------------+--------------------+---------+------+------+-------------------+
| 1 | 192.168.0.150:3306 | up | rw | NULL | 0 |
| 2 | 192.168.0.151:3307 | unknown | ro | NULL | 0 |
+-------------+--------------------+---------+------+------+-------------------+
2 rows in set (0.00 sec) 注意:因为rw-splitting.lua脚本默认有4个链接才启用分离;所以多开启几个终端;多测试几下;你也可以去修改里面的相关值
mysql> select * from backends;
+-------------+--------------------+-------+------+------+-------------------+
| backend_ndx | address | state | type | uuid | connected_clients |
+-------------+--------------------+-------+------+------+-------------------+
| 1 | 192.168.0.150:3306 | up | rw | NULL | 0 |
| 2 | 192.168.0.151:3307 | up | ro | NULL | 0 |
+-------------+--------------------+-------+------+------+-------------------+
2 rows in set (0.00 sec)
#出现两个up,代表读写分离成功。