Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
majulong opened this issue Feb 27, 2019 · 1 comment
Open

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

majulong opened this issue Feb 27, 2019 · 1 comment

Comments

@majulong
Copy link

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

@majulong
Copy link
Author

my goal is use nignx can find the master redis and only be the proxy for that. my plan is find the master's IP by sentinel, and set the IP as a parameter that I can use that in stream to proxy_pass.
Can this module achieve it?
thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant