我启动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端口,
有没有线程的脚本能够实现我所要求的?

解决方案 »

  1.   

    如果你的操作仅是一个读的操作,那只会分到10.0.0.17:3306 上;如果你某个连接有写的,则会分到10.0.0.17:3307上,而这个连接只要没断,你当然也可以进行读操作。如果要像你想的将那些非包含有写操作的连接,也要发送到10.0.0.17:3307上,根据我的了解,好象mysql-proxy目前达不到吧(这个有空要作大量测试才知道了)
      

  2.   

    目前,我写了lua脚本,确实好像很难达到!!!
    再测试测试!
      

  3.   

    mysql proxy好像就是分配初始的连接,如果将某次的连接分配好了,该连接就被导向了相应的mysql不会再变!
    感觉mysql proxy就是一个ip端口转发工具!
      

  4.   


    说明书上就是这么解释的啊。
    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. 
      

  5.   

    如果你想测试这个其实也是比较简单的,
    MySQL 数据设定两个IP(A,B),同时建立两个用户【Usr1,Usr2】;程序机器设定两个IP(C,D)。
    Usr1 只允许C IP登录
    Usr2 只允许D IP登录
    到时看看相关操作连接应该可以一目了然,不需要修改端口那样惨。
      

  6.   

    不用rw-splitting.lua就是你要的效果。
      

  7.   

    你在windows安装过两个服务器没设置就是两个不同的服务名两个不同的用户不同的端口
      

  8.   

    你在windows安装过两个服务器没设置不同端口
      

  9.   


    能详细说说看吗?我要具体如何做,用哪个lua脚本?