如果叢集模式中 其中一個叢集對應的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
- "cluster-require-full-coverage"
- "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
- "cluster-require-full-coverage"
- "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