Redis 如何在 Rails 中配置 Redis 集群?

lzm420241 · June 20, 2016 · Last by hfpp2012 replied at June 28, 2016 · 9407 hits

我使用 redis gem 包,从 redis 文档中看到提供 sentinel 的支持,其中其配置如下 (link:https://github.com/redis/redis-rb)

SENTINELS = [{:host => "127.0.0.1", :port => 26380},
             {:host => "127.0.0.1", :port => 26381}]

redis = Redis.new(:url => "redis://mymaster", :sentinels => SENTINELS, :role => :master)

但是根据上述配置,返回的 redis 是 nil,不知道哪里有问题,还望各位大牛指教?

redis 要启动 sentinel 啦,这样是合理的,或者你也可以用 redis 的 cluster 模式,再加上 nginx 配上 tcp load balance

#1 楼 @hfpp2012 你意思是我还要配置 sentinel 相关的文件吗?我觉得不需要啊,redis 里面不是集成了 sentinel 吗?

#2 楼 @lzm420241 redis 是从 2.8 开始就有 sentinel 功能,有这个功能,不代别你不用做任何事就能用它呀,不仅要配置,你还要启动一个 sentinel 进程

You need to Sign in before reply, if you don't have an account, please Sign up first.