redis cluster叢集死一個master剩下的master節點還能提供服務嗎

賀子_DBA時代發表於2022-12-18
如果叢集模式中 其中一個叢集對應的master 和slave 都當機,那麼整個叢集會進入fail模式,不對外提供服務?其實是由引數cluster-require-full-coverage控制!
1、先關閉7001的slave節點,然後關閉7001例項,這個時候如下所示:
172.16.196.72:7002> cluster  nodes
80aaf55a3855d8fe1531189dac52e7be133c23b6 172.16.196.72:7002@17002 myself,master - 0 1670921700000 1 connected 5462-10922
02e1a0b030e84b464e50341f753cafeb77d3e20f 172.16.196.72:7003@17003 master - 0 1670921701000 2 connected 10923-16383
6af9846504361edaf86cdcfd2fd09dc425b7b26d 172.16.196.72:7004@17004 slave 02e1a0b030e84b464e50341f753cafeb77d3e20f 0 1670921701348 3 connected
20bb5db1495e50b830ebe19942b6ff3efd6f49ba 172.16.196.72:7006@17006 slave,fail f6f56d07b57ccbca269d435fc9aeba794d4b8e41 1670921675632 1670921674229 5 disconnected
7e22d642f2361a064be9ea3c9855e71c258aa9b9 172.16.196.72:7005@17005 slave 80aaf55a3855d8fe1531189dac52e7be133c23b6 0 1670921700000 4 connected
f6f56d07b57ccbca269d435fc9aeba794d4b8e41 172.16.196.72:7001@17001 master,fail - 1670921675632 1670921673226 0 disconnected 0-5461
2、嘗試寫資料:發現報錯,此時叢集已經不提供服務了!
172.16.196.72:7002> set liuwenhe liu
(error) CLUSTERDOWN The cluster is down
172.16.196.72:7002>
3、其實該特性由引數cluster-require-full-coverage控制;
當該引數為yes時(預設為yes),如果某個master以及它的slave都死了,那麼叢集就不提供服務了,
但是如果引數設定為 no,那麼此時叢集剩餘的master節點是可以提供服務的,但是當嘗試寫到已經down機的master節點時候,就會報錯,
具體如下所示:
1)該引數預設值為yes
172.16.196.72:7002> config get cluster-require-full-coverage
  1. "cluster-require-full-coverage"
  2. "yes"
2)修改引數為no
172.16.196.72:7002> config set cluster-require-full-coverage no
OK
172.16.196.72:7002> config get cluster-require-full-coverage
  1. "cluster-require-full-coverage"
  2. "no"
3)再次嘗試寫入key,發現可以了
172.16.196.72:7002> set liuwenhe liu
OK
4)嘗試寫到已經down機的master節點時候,就會報錯
172.16.196.72:7002> set liuwenhe1 liu
-> Redirected to slot [2299] located at 172.16.196.72:7001
Could not connect to Redis at 172.16.196.72:7001: Connection refused
Could not connect to Redis at 172.16.196.72:7001: Connection refused

但是注意: redis cluster切換的過程中,也會存在短暫的時間內(引數 cluster-node-timeout設定),叢集master節點部分不可用 ,這段時間內還會提供讀寫服務嗎?

切換的過程中cluster是可以部分提供服務,也就是例如三主三從,其中一個master1死了,叢集需要等待cluster-node-timeout時間,才會選擇新的master1,那麼這段時間內,不管你設定的是 cluster-require-full-coverage是yes或者no,叢集的剩餘master2和master3是可以繼續提供服務的,但是當你嘗試寫入故障的master1節點的時候,就會報錯!



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29654823/viewspace-2928500/,如需轉載,請註明出處,否則將追究法律責任。

相關文章