由於羣集的Redis仍在工作,Resque中是否有機制會自動將故障轉移到Redis從服務器,如果主服務器出現故障?恢復故障轉移的解決方案redis
2
A
回答
1
我不這麼認爲。但是,您可以implement the master election mechanism yourself很容易使用Apache Zookeeper:
require "rubygems"
require "zookeeper"
def log(msg)
puts "[#{Process.pid}] #{msg}"
end
def debug(obj)
log(obj.inspect)
end
def on_master_changed(&block)
loop do
wcb = Zookeeper::WatcherCallback.new
resp = @zookeeper.get_children(:path => @base_path, :watcher => wcb, :watcher_context => @base_path)
children = resp[:children].map{|name| "#{@base_path}/#{name}"}
new_master = children.sort.first
block.call(new_master)
while !wcb.completed?
sleep(0.1)
end
end
end
@zookeeper = Zookeeper.new("localhost:2181")
if @zookeeper.state != Zookeeper::ZOO_CONNECTED_STATE
log 'Unable to connect to Zookeeper!'
exit(1)
end
@base_path = "/nodes"
@zookeeper.create(:path => @base_path)
resp = @zookeeper.create(:path => "#{@base_path}/node-", :ephemeral => true, :sequence => true, :data => Process.pid.to_s)
my_node = resp[:path]
is_master = false
log "My node is: #{my_node}"
on_master_changed do |new_master|
if new_master == my_node
if is_master
log "I am still the master. Bow before me or die!"
else
log "I am the new master. Behold!"
end
is_master = true
else
pid = @zookeeper.get(:path => new_master)[:data]
log "New master is process #{pid}"
end
end
您可以修改上面的腳本:Redis的服務器,而不是PID過程的
- 使用IP /端口
- 使用Redis的-cli以及SLAVEOF命令來處理「成爲主人」,「主人變更」和「不再主人」的情景。
0
我已經發布了一個redis_failover的寶石,提供Redis的故障轉移紅寶石動物園管理員:
相關問題
- 1. ASP.NET SMTP故障轉移解決方案
- 2. cxf故障轉移恢復
- 3. 針對linux服務故障轉移的解決方案
- 4. AWS Elasticache Redis故障轉移
- 5. ServiceStack Web服務的存儲轉發故障轉移解決方案
- 6. 移動MOSS網絡解決方案包時出現故障
- 7. Docker故障轉移:Redis,MySQL和Nginx
- 8. Redis羣集:沒有自動故障轉移爲主故障
- 9. Redis/Jedis沒有單點故障和自動故障轉移
- 10. MongoDB複製故障轉移
- 11. 故障轉移後WebSphere MQ恢復正在運行的消息
- 12. ActiveMQ - 恢復連接後的CreateSession故障轉移超時
- 13. 如何恢復我的解決方案來解決衝突?
- 14. 如何自動化Azure站點恢復故障轉移?
- 15. 故障恢復在C#
- 16. Heroku app的服務器(故障切換)冗餘解決方案
- 17. 需要解決方案的JavaScript小故障(可能很簡單)
- 18. Memcache故障轉移
- 19. 解決W2K8/SQL05中的故障轉移羣集問題
- 20. GlusterFS複製和故障轉移
- 21. Hazelcast故障轉移在WAN複製
- 22. Memcache羣集故障轉移複製
- 23. ActiveMQ服務故障轉移和數據庫故障轉移
- 24. RabbitMQ和Node.js如何處理故障轉移方案?
- 25. postgresql9.0中的故障轉移
- 26. M2E故障轉移的JUnit
- 27. ActiveMQ的故障轉移
- 28. Maven的故障轉移
- 29. WordPress的W3Total緩存和Redis的故障轉移
- 30. 關於Redis的春季會議 - 當Redis發生故障時,什麼是故障轉移