This commit is contained in:
2026-05-19 15:36:16 +08:00
parent 431dd2ab36
commit cb6c0202f7
7 changed files with 39 additions and 13 deletions

View File

@@ -58,6 +58,8 @@ function ModifyConf {
protected-mode no
maxmemory 6442450944
maxmemory-policy volatile-random
timeout 300
maxclients 8192
" > /etc/redis.conf
while read kv; do
[ 'cluster-enabled=yes' == "$kv" ] && clusterEnabled=1
@@ -73,21 +75,20 @@ function DeployCluster {
local i=
local node=
local nodesId=
local clusterEnabled=
local clusterInfo=
local redisCliCmd="redis-cli ${REQUIREPASS:+-a $REQUIREPASS --no-auth-warning}"
[ 0 -ne ${#SLAVE_NODES[@]} -a ${#SLAVE_NODES[@]} -ne ${#MASTER_NODES[@]} ] \
&& Print The num of slave nodes not equal to the num of master nodes! \
&& exit 100
Print Checking the state of all nodes ...
for node in ${MASTER_NODES[@]} ${SLAVE_NODES[@]}; do
for i in {0..5}; do
[ 5 -eq $i ] \
&& Print Failed to connect to $node! \
&& exit 100
sleep 6
clusterEnabled=$($redisCliCmd --raw -d , -h ${node/:/ -p } \
CONFIG GET cluster-enabled) \
|| continue
[[ "$clusterEnabled" =~ ,yes$ ]] && break
sleep 2
clusterInfo=$($redisCliCmd -h ${node/:/ -p } info cluster) || continue
echo "$clusterInfo" | grep -q cluster_enabled:1 && break
Print $node not enable cluster mode! && exit 100
done
done