Rails 请教 Sidekiq 启动链接 redis 报密码错误 问题

ghn645568344 · 2017年07月25日 · 最后由 Rei 回复于 2017年07月25日 · 2302 次阅读

RT redis 是有密码的,

sidekiq -C sidekiq.yml 

配置代码如下

idekiq.configure_server do |config|
  p redis_server
  p ENV['REDIS_PASSWORD']
  config.redis = { url: 'redis://localhost:6379/0',password:  ENV['REDIS_PASSWORD'], namespace: "kalading-sidekiq/#{Rails.env}"}
end

Sidekiq.configure_client do |config|
  config.redis = { url: 'redis://localhost:6379/0',password:  ENV['REDIS_PASSWORD'] , namespace: "kalading-sidekiq/#{Rails.env}" }
end

启动,报

2017-07-25T10:03:06.526Z 12643 TID-or6mz2sug INFO: Booting Sidekiq 4.1.4 with redis options {:url=>"redis://localhost:6379/0", :password=>"REDACTED", :namespace=>"kalading-sidekiq/development"}


         m,
         `$b
    .ss,  $$:         .,d$
    `$$P,d$P'    .,md$P"'
     ,$$$$$bmmd$$$P^'
   .d$$$$$$$$$$P'
   $$^' `"^$$$'       ____  _     _      _    _
   $:     ,$$:       / ___|(_) __| | ___| | _(_) __ _
   `b     :$$        \___ \| |/ _` |/ _ \ |/ / |/ _` |
          $$:         ___) | | (_| |  __/   <| | (_| |
          $$         |____/|_|\__,_|\___|_|\_\_|\__, |
        .d$$                                       |_|

2017-07-25T10:03:09.018Z 12643 TID-or6mz2sug INFO: Running in ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
2017-07-25T10:03:09.018Z 12643 TID-or6mz2sug INFO: See LICENSE and the LGPL-3.0 for licensing details.
2017-07-25T10:03:09.018Z 12643 TID-or6mz2sug INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org
ERR invalid password
/usr/local/lib/ruby/gems/2.2.0/gems/redis-3.3.1/lib/redis/client.rb:121:in `call'
/usr/local/lib/ruby/gems/2.2.0/gems/peek-redis-1.2.0/lib/peek/views/redis.rb:9:in `call'
/usr/local/lib/ruby/gems/2.2.0/gems/redis-3.3.1/lib/redis/client.rb:102:in `block in connect'
/usr/local/lib/ruby/gems/2.2.0/gems/redis-3.3.1/lib/redis/client.rb:293:in `with_reconnect'
/usr/local/lib/ruby/gems/2.2.0/gems/redis-3.3.1/lib/redis/client.rb:100:in `connect'
/usr/local/lib/ruby/gems/2.2.0/gems/redis-3.3.1/lib/redis/client.rb:364:in `ensure_connected'
/usr/local/lib/ruby/gems/2.2.0/gems/redis-3.3.1/lib/redis/client.rb:221:in `block in process'
/usr/local/lib/ruby/gems/2.2.0/gems/redis-3.3.1/lib/redis/client.rb:306:in `logging'
/usr/local/lib/ruby/gems/2.2.0/gems/redis-3.3.1/lib/redis/client.rb:220:in `process'
/usr/local/lib/ruby/gems/2.2.0/gems/redis-3.3.1/lib/redis/client.rb:120:in `call'
/usr/local/lib/ruby/gems/2.2.0/gems/peek-redis-1.2.0/lib/peek/views/redis.rb:9:in `call'
/usr/local/lib/ruby/gems/2.2.0/gems/redis-3.3.1/lib/redis.rb:251:in `block in info'
/usr/local/lib/ruby/gems/2.2.0/gems/redis-3.3.1/lib/redis.rb:58:in `block in synchronize'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/lib/ruby/gems/2.2.0/gems/redis-3.3.1/lib/redis.rb:58:in `synchronize'
/usr/local/lib/ruby/gems/2.2.0/gems/redis-3.3.1/lib/redis.rb:250:in `info'
/usr/local/lib/ruby/gems/2.2.0/gems/sidekiq-4.1.4/lib/sidekiq.rb:108:in `block in redis_info'
/usr/local/lib/ruby/gems/2.2.0/gems/sidekiq-4.1.4/lib/sidekiq.rb:92:in `block in redis'
/usr/local/lib/ruby/gems/2.2.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:64:in `block (2 levels) in with'
/usr/local/lib/ruby/gems/2.2.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:63:in `handle_interrupt'
/usr/local/lib/ruby/gems/2.2.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:63:in `block in with'
/usr/local/lib/ruby/gems/2.2.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:60:in `handle_interrupt'
/usr/local/lib/ruby/gems/2.2.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:60:in `with'
/usr/local/lib/ruby/gems/2.2.0/gems/sidekiq-4.1.4/lib/sidekiq.rb:89:in `redis'
/usr/local/lib/ruby/gems/2.2.0/gems/sidekiq-4.1.4/lib/sidekiq.rb:103:in `redis_info'
/usr/local/lib/ruby/gems/2.2.0/gems/sidekiq-4.1.4/lib/sidekiq/cli.rb:71:in `run'
/usr/local/lib/ruby/gems/2.2.0/gems/sidekiq-4.1.4/bin/sidekiq:12:in `<top (required)>'
/usr/local/bin/sidekiq:23:in `load'
/usr/local/bin/sidekiq:23:in `<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `load'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `kernel_load'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:24:in `run'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/cli.rb:304:in `exec'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/cli.rb:11:in `start'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/exe/bundle:27:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/exe/bundle:19:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'

密码肯定是对的,这个我敢保证,就是一直提示错误。。。。

问题肯定出在配置上,查文档应该能解决。既然你是本地访问 redis,你配置一下把 redis 的外网访问关了,然后取消密码好了。

lgn21st 回复

外网访问就是关的,领导就是让加密码😤

错误提示很明显啊。不行的话就在出错的地方调试:https://github.com/redis/redis-rb/blob/v3.3.1/lib/redis/client.rb#L121

把 password 写到 URL 里

ghn645568344 关闭了讨论。 07月26日 11:27
需要 登录 后方可回复, 如果你还没有账号请 注册新账号