MySQL代理和基本故障转移(检测状态)

时间:2012-02-16 12:19:22

标签: mysql proxy lua failover mysql-proxy

我刚安装了mysql proxy 0.8.2,并开始玩它。我和两个MySQL 5.5服务器一起使用它,监听3306,代理运行在4040.哦,操作系统是Win 7 32位。

我的问题是,mysql代理检查服务器的状态似乎不应该。

我启动脚本,它按预期运行。但是当我关闭主服务器时,脚本似乎没有意识到 - 它仍然试图连接到它......

版本信息

mysql-proxy 0.8.2
chassis: mysql-proxy 0.8.2
glib2: 2.16.6
libevent: 1.4.12-stable
LUA: Lua 5.1.2
package.path: C:\ProgramX86\dev\mysql-proxy\lib\mysql-proxy\lua\?.lua
package.cpath: C:\ProgramX86\dev\mysql-proxy\bin\lua-?.dll
-- modules
proxy: 0.8.2*

我的配置

[mysql-proxy]
proxy-address = :4040
proxy-backend-addresses = 10.3.0.9:3306,192.168.4.100:3306
proxy-lua-script = C:/ProgramX86/dev/mysql-proxy/failover3.lua
daemon = true

故障转移lua脚本

function connect_server()
    if proxy.global.backends[1].state == proxy.BACKEND_STATE_DOWN then
        proxy.connection.backend_ndx = 2
    else
        proxy.connection.backend_ndx = 1
    end
    print ("s Connecting: " .. proxy.global.backends[proxy.connection.backend_ndx].dst.name)
end 

function read_query(packet)
    if proxy.global.backends[1].state == proxy.BACKEND_STATE_DOWN then
        proxy.connection.backend_ndx = 2
    else
        proxy.connection.backend_ndx = 1
    end
    print ("q Connecting: " .. proxy.global.backends[proxy.connection.backend_ndx].dst.name)
end

0 个答案:

没有答案