我可能错过了,但我不知道您是否可以将其配置为从从服务器读取?但是,这是我的主服务器+2个从服务器的配置:
config.cache_store = :redis_store, {
url: 'redis://prestwick/1',
sentinels: [{host: 'prestwick.i', port: 26379}, {host: 'carnoustie.i', port: 26379}, {host: 'birkdale.i', port: 26379}],
role: 'master',
expires_in: 1.hour
}
如果有用的话,这是我为一般REDIS对象和Sidekiq进行配置的(这在config/initializers/001_redis.rb中):
redis_options = {
url: 'redis://prestwick/0',
sentinels: [{host: 'prestwick.i', port: 26379}, {host: 'carnoustie.i', port: 26379}, {host: 'birkdale.i', port: 26379}],
role: 'master'
}
redis_sidekiq_options = {
url: 'redis://prestwick/2',
sentinels: [{host: 'prestwick.i', port: 26379}, {host: 'carnoustie.i', port: 26379}, {host: 'birkdale.i', port: 26379}],
role: 'master'
}
REDIS = Redis.new(redis_options)
Sidekiq.configure_server do |config|
config.redis = redis_sidekiq_options
end
Sidekiq.configure_client do |config|
config.redis = redis_sidekiq_options
end