redis cluster 六台服务器做三主三从 初始化一直在等待
root@sunday:~# redis-cli -a 'Sunday123' --cluster create 192.168.77.81:6379 192.168.77.82:6379 192.168.77.83:6379 192.168.77.84:6379 192.168.77.85:6379 192.168.77.86:6379 --cluster-replicas 1
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 192.168.77.85:6379 to 192.168.77.81:6379
Adding replica 192.168.77.86:6379 to 192.168.77.82:6379
Adding replica 192.168.77.84:6379 to 192.168.77.83:6379
M: 4b35726c85c4f4108e1916bd6d384e10b7f54463 192.168.77.81:6379
slots:[0-5460] (5461 slots) master
M: 4b35726c85c4f4108e1916bd6d384e10b7f54463 192.168.77.82:6379
slots:[5461-10922] (5462 slots) master
M: be4ae88704537c5ece9c6a1c457cdd64d477dd18 192.168.77.83:6379
slots:[10923-16383] (5461 slots) master
S: 0ee52530290e1a63c781588996ca98ad1e701c11 192.168.77.84:6379
replicates be4ae88704537c5ece9c6a1c457cdd64d477dd18
S: 894403ddc2ac6ca7cb576aafd700b1ec86a6e8d1 192.168.77.85:6379
replicates 4b35726c85c4f4108e1916bd6d384e10b7f54463
S: 0f4c341314c3b5befbd06b5edcbad3ae4d03c9ea 192.168.77.86:6379
replicates 4b35726c85c4f4108e1916bd6d384e10b7f54463
Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join
.................................................................................................................................................................................................................................................................
其中发现192.168.77.81、192.168.77.83、192.168.77.84都会连接异常,且频繁 CONFIG REWRITE
root@sunday:~/redis-7.2.10# redis-cli
127.0.0.1:6379> auth Sunday123
OK
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> ping
Error: Server closed the connection
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> ping
Error: Server closed the connection
日志频繁重写 10秒一次
root@sunday:~# tail /usr/local/redis/log/redis.log
3747:M 11 Jul 2025 12:05:08.975 * Running mode=cluster, port=6379.
3747:M 11 Jul 2025 12:05:08.975 # Server initialized
3747:M 11 Jul 2025 12:05:08.976 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
3747:M 11 Jul 2025 12:05:08.977 * Ready to accept connections
3747:M 11 Jul 2025 12:05:08.977 # systemd supervision error: NOTIFY_SOCKET not found!
3747:M 11 Jul 2025 12:05:08.977 # systemd supervision error: NOTIFY_SOCKET not found!
3747:M 11 Jul 2025 12:05:09.544 # CONFIG REWRITE executed with success.
3747:M 11 Jul 2025 12:05:19.579 # CONFIG REWRITE executed with success.
3747:M 11 Jul 2025 12:05:29.652 # CONFIG REWRITE executed with success.
原因:之前哨兵模式有一台服务器未关闭服务导致的
解决:关闭这台哨兵服务后 cluster reset 重新初始化就正常了
1712:X 10 Jul 2025 01:57:34.057 * +convert-to-slave slave 192.168.77.81:6379 192.168.77.81 6379 @ mymaster 192.168.77.82 6379
1712:X 10 Jul 2025 01:57:35.607 * +reboot slave 192.168.77.83:6379 192.168.77.83 6379 @ mymaster 192.168.77.82 6379
1712:X 10 Jul 2025 01:57:35.678 # -sdown slave 192.168.77.83:6379 192.168.77.83 6379 @ mymaster 192.168.77.82 6379
1712:X 10 Jul 2025 01:57:41.333 * +reboot slave 192.168.77.84:6379 192.168.77.84 6379 @ mymaster 192.168.77.82 6379
1712:X 10 Jul 2025 01:57:41.391 # -sdown slave 192.168.77.84:6379 192.168.77.84 6379 @ mymaster 192.168.77.82 6379
1712:X 10 Jul 2025 01:57:44.086 * +convert-to-slave slave 192.168.77.81:6379 192.168.77.81 6379 @ mymaster 192.168.77.82 6379
1712:X 10 Jul 2025 01:57:45.654 * +convert-to-slave slave 192.168.77.83:6379 192.168.77.83 6379 @ mymaster 192.168.77.82 6379
1712:X 10 Jul 2025 01:57:51.371 * +convert-to-slave slave 192.168.77.84:6379 192.168.77.84 6379 @ mymaster 192.168.77.82 6379
1712:X 10 Jul 2025 01:57:54.149 * +convert-to-slave slave 192.168.77.81:6379 192.168.77.81 6379 @ mymaster 192.168.77.82 6379