resty.upstream.healthcheck和一致性hash模块(https://www.nginx.com/resources/wiki/modules/consistent_hash/)一起使用时,worker启动不了

343 views
Skip to first unread message

ch ren

unread,
Apr 13, 2016, 6:19:20 AM4/13/16
to openresty

    upstream ats_servers {
        server 192.168.1.211:80;
        server 192.168.1.212:80;
        consistent_hash $host$request_uri;
    }

    init_worker_by_lua_block {
        local hc = require "resty.upstream.healthcheck"
        
        local ok, err = hc.spawn_checker{
            shm = "healthcheck",  -- defined by "lua_shared_dict"
            upstream = "ats_servers", -- defined by "upstream"
            type = "http",

            http_req = "GET /status HTTP/1.0\r\nHost: foo.com\r\n\r\n",
                    -- raw HTTP request for checking

            interval = 2000,  -- run the check cycle every 2 sec
            timeout = 1000,   -- 1 sec is the timeout for network operations
            fall = 3,  -- # of successive failures before turning a peer down
            rise = 2,  -- # of successive successes before turning a peer up
            valid_statuses = {200, 302},  -- a list valid HTTP status code
            concurrency = 10,  -- concurrency level for test requests
        }
        if not ok then
            ngx.log(ngx.ERR, "failed to spawn health checker: ", err)
            return
        end
    }

如上是我的配置,一致性hash模块来自https://www.nginx.com/resources/wiki/modules/consistent_hash/,单独使用没问题,和resty.upstream.healthcheck一起使用时worker启动时会coredump,起不来,gdb调试如下:


DeJiang Zhu

unread,
Apr 13, 2016, 9:30:09 AM4/13/16
to open...@googlegroups.com
Hello,

这个模块是第三方的,或许会有兼容性问题吧,你可以使用 nginx 标准的 chash


--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html

jzh...@gmail.com

unread,
Apr 21, 2017, 6:28:51 AM4/21/17
to openresty
非常感谢,我也是这个问题现在解决了一部分,网页可以查询了,
 
但是还有 No checkers的问题,现在还不知道怎么解决。
Upstream tomcat (NO checkers)
 
后面是解决consistent_hash
 
        #consistent_hash $key;
        hash $key consistent;
 
 

在 2016年4月13日星期三 UTC+8下午9:30:09,doujiang写道:

jzh...@gmail.com

unread,
Apr 23, 2017, 10:31:04 PM4/23/17
to openresty
春哥回复了,有解决思路不?应该是需要改health check的lua模块吧?
agentzh commented 2 days ago

@jzh800 Thanks for the report. Mind to propose a patch? Thanks!

 
 

在 2017年4月21日星期五 UTC+8下午6:28:51,jzh...@gmail.com写道:
Reply all
Reply to author
Forward
0 new messages