Skip to content

use sentinel connect find the master IP is the pod ip  #28

Description

@majulong

I used the sentinel to connect, is the pod IP.
Also, how to use get_master method. my Code is
local rc = require("resty.redis.connector").new(redis)

local redis, err = rc:connect{
url = "sentinel://mymaster:a/2",
sentinels = {
{ host = "10.62.108.88", port = 32641 },
}
}
if not redis then
ngx.say("close redis error : ", err)
end

local master, err = require("resty.redis.sentinel").get_master(sentinels, master_name)
if not master then
ngx.say("close redis error : ", err)
end

I already changed the sentinels in the default table. like:
sentinels = {
{ host = "10.62.108.88", port = 32641 },
}
the Output is

2019/02/27 02:09:43 [error] 32187#32187: *46 lua tcp socket connect timed out, when connecting to 172.30.63.147:6379, client: 127.0.0.1, server: , request: "GET /lua_redis_basic HTTP/1.1", host: "localhost:800"
2019/02/27 02:09:43 [error] 32187#32187: *46 lua entry thread aborted: runtime error: ...y/lua-resty-redis-connector/lib/resty/redis/sentinel.lua:18: attempt to index local 'sentinel' (a nil value)
stack traceback:
coroutine 0:
...y/lua-resty-redis-connector/lib/resty/redis/sentinel.lua: in function 'get_master'
/usr/local/openresty/nginx/conf/test.lua:14: in function </usr/local/openresty/nginx/conf/test.lua:1>, client: 127.0.0.1, server: , request: "GET /lua_redis_basic HTTP/1.1", host: "localhost:800"
curl: (52) Empty reply from server

what can I do? Thanks! @pintsized @andrewsharpe @stockrt

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions