我启动mysql-proxy的命令如下:
mysql-proxy --proxy-address=10.0.0.17:4040 \
--proxy-read-only-backend-addresses=10.0.0.17:3306 \
--proxy-backend-addresses=10.0.0.17:3307 \
--proxy-lua-script=/usr/local/share/doc/mysql-proxy/rw-splitting.lua我希望10.0.0.17:3306只被分配给读操作,而3307端口则既有读操作,又有写操作!但我发现如何分配读写取决与rw-splitting.lua这个脚本,而这个脚本把所有的读都分配给了3306端口,
有没有线程的脚本能够实现我所要求的?
mysql-proxy --proxy-address=10.0.0.17:4040 \
--proxy-read-only-backend-addresses=10.0.0.17:3306 \
--proxy-backend-addresses=10.0.0.17:3307 \
--proxy-lua-script=/usr/local/share/doc/mysql-proxy/rw-splitting.lua我希望10.0.0.17:3306只被分配给读操作,而3307端口则既有读操作,又有写操作!但我发现如何分配读写取决与rw-splitting.lua这个脚本,而这个脚本把所有的读都分配给了3306端口,
有没有线程的脚本能够实现我所要求的?
再测试测试!
感觉mysql proxy就是一个ip端口转发工具!
说明书上就是这么解释的啊。
14.6. MySQL Proxy
The MySQL Proxy is an application that communicates over the network using the MySQL Network Protocol and provides communication between one or more MySQL servers and one or more MySQL clients. In the most basic configuration, MySQL Proxy simply passes on queries from the client to the MySQL Server and returns the responses from the MySQL Server to the client. Because MySQL Proxy uses the MySQL network protocol, any MySQL compatible client (include the command line client, any clients using the MySQL client libraries, and any connector that supports the MySQL network protocol) can connect to the proxy without modification. In addition to the basic pass-through configuration, the MySQL Proxy is also capable of monitoring and altering the communication between the client and the server. This interception of the queries enables you to add profiling, and the interception of the exchanges is scriptable using the Lua scripting language. By intercepting the queries from the client, the proxy can insert additional queries into the list of queries sent to the server, and remove the additional results when they are returned by the server. Using this functionality you can add informational statements to each query, for example to monitor their execution time or progress, and separately log the results, while still returning the results from the original query to the client. The proxy allows you to perform additional monitoring, filtering or manipulation on queries without you having to make any modifications to the client and without the client even being aware that it is communicating with anything but a genuine MySQL server.
MySQL 数据设定两个IP(A,B),同时建立两个用户【Usr1,Usr2】;程序机器设定两个IP(C,D)。
Usr1 只允许C IP登录
Usr2 只允许D IP登录
到时看看相关操作连接应该可以一目了然,不需要修改端口那样惨。
能详细说说看吗?我要具体如何做,用哪个lua脚本?