Redis Sentinel:实现高可用自动故障转移方案.pdfVIP

  • 1
  • 0
  • 约1.17万字
  • 约 12页
  • 2025-10-23 发布于北京
  • 举报

Redis Sentinel:实现高可用自动故障转移方案.pdf

集群1:——Sentinel

目前我们讲的Redis还只是主从⽅案,最终⼀致性。读者们可思考

过,如果主节点凌晨3点宕机?就坐等运维从爬起

来,然后⼿⼯进⾏从主切换,再所有的程序把地址统统改⼀遍重

新上线么?,这样的人⼯运维效率太低,事故发生时估计得

至少1个⼩时才能缓过来。如果是⼀个⼤型公司,这样的事故⾜以

上了。

所以须有⼀个⾼可⽤⽅案来抵抗节点故障,当故障发生时可以

自动进⾏从主切换,程序可以不⽤重启,运维可以继续睡⼤觉,仿佛

什么事也没发生⼀样。Redis官⽅了这样⼀种⽅案——Redis

Sentinel(哨兵)。

Cluster1:Sentinel

Atpresent,theRediswearetalkingaboutisonlyamaster-slavesolutionwith

eventualconsistency.Readersmayhavethoughtaboutwhattodoifthemaster

nodesuddenlygoesdownat3oclockinthemorning?Justwaitfortheoperation

andmaintenancetogetoutofbed,thenmanuallyswitchfromthemaster,andt

hennotifyallprogramstochangealltheaddressesandcomeonlineagain?Thereis

nodoubtthatsuchmanualoperationandmaintenanceistooinefficient.Whenan

accidentoccurs,itisestimatedthatitwilltakeatleastanhourtorecover.Ifyou

werealargecompany,anaccidentlikethiswouldbeenoughtomakethenews.

Therefore,wemusthaveahigh-availabilitysolutiontoresistnodefailure.Whena

failureoccurs,itcanautomaticallyswitchfromthemaster,theprogramdoesnot

needtoberestarted,andtheoperationandmaintenancecancontinuetosleepasif

nothinghappened.Redislyprovidessuchasolution-RedisSentinel.

我们可以将RedisSentinel集群看成是⼀个ZooKeeper集群,它

是集群⾼可⽤的⼼脏,它⼀般是由3~5个节点组成,这样挂了个别

节点集群还可以正常运转。

它负责持续主从节点的健康,当主节点挂掉时,自动选择⼀个最

优的从节点切换为主节点。客户端来连接集群时,会首先连接

sentinel,通过sentinel来查询主节点的地址,然后再去连接主节

点进⾏数据交互。当主节点发生故障时,客户端会重新向sentinel

要地

文档评论(0)

1亿VIP精品文档

相关文档