Redis:我的哨兵在本地运行,但是没有哨兵可用。 (Redis :: CannotConnectError)

时间:2018-11-11 16:12:26

标签: ruby-on-rails redis redis-sentinel

在本地,我正在使用以下信息运行redis前哨

redis-cli -p 26379

127.0.0.1:26379> info

服务器

redis_version:3.0.4
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:ee774adfcab9032f
redis_mode:sentinel
os:Darwin 16.7.0 x86_64
arch_bits:64
multiplexing_api:kqueue
gcc_version:4.2.1
process_id:53388
run_id:685daaf76ce1bf378011d851afa7742d6e2da10b
tcp_port:26379
uptime_in_seconds:10
uptime_in_days:0
hz:15
lru_clock:15224205
config_file:/usr/local/opt/redis/sentinel.conf

前哨

sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
master0:name=mymaster, 
status=odown,
address=127.0.0.1:6666,
slaves=2,
sentinels=1

这是我的sentinel.conf file

我正在Rails应用程序中使用redis gem的4.0.3版本

当我打开gem进行调试并放置哨兵时

def sentinel_detect
  puts "#{@sentinels} -- Sentinels"
  @sentinels.each do |sentinel|
    client = Client.new(@options.merge({
      :host => sentinel[:host],
      :port => sentinel[:port],
      :reconnect_attempts => 0,
    }))

基于this documentation,我得到[{:host=>"127.0.0.1", :port=>26379, :url=>"redis://mymaster", :role=>:master}]是正确的

启动Rails服务器时,即使我正在运行哨兵,我也会得到No sentinels available. (Redis::CannotConnectError)。我想念什么?我假设有一些配置?预先感谢

0 个答案:

没有答案