redis集群添加节点报错Either the node already knows other nodes (check with CLUSTER NODES) or contains some k
【README】 redis集群添加節(jié)點報錯
[ERR] Node 192.168.163.202:6380 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.??
【1】 原因
導致異常的主要原因是該節(jié)點中默認生成的配置或歷史存儲數(shù)據(jù)不一致導致的,清除對應節(jié)點的dump.rdb、nodes.conf文件,重啟之后即可。
dump.rdb是由Redis服務器自動生成的 默認情況下 每隔一段時間redis服務器程序會自動對數(shù)據(jù)庫做一次遍歷,把內(nèi)存快照寫在一個叫做“dump.rdb”的文件里,這個持久化機制叫做SNAPSHOT。有了SNAPSHOT后,如果服務器宕機,重新啟動redis服務器程序時redis會自動加載dump.rdb,將數(shù)據(jù)庫狀態(tài)恢復到上一次做SNAPSHOT時的狀態(tài)。
【2】解決步驟:
1、停止服務,刪除aof/rdb文件;
2、刪除nodes.conf
3、必要的情況下執(zhí)行flushdb。
原文鏈接:?http://www.choupangxia.com/2019/11/07/redis-node-is-not-empty/?
?
【3】報錯現(xiàn)場和實際解決方法??
1)?把 202:6380 添加到 機器201:6379所在集群,集群master節(jié)點的hash為 5571f088f9d8798dd0c2e973ced830c2cd8033a2??
[root@centos201 ~]# /usr/local/redis-cluster/bin/redis-trib.rb add-node --slave --master-id 5571f088f9d8798dd0c2e973ced830c2cd8033a2 192.168.163.202:6380 192.168.163.201:6379 >>> Adding node 192.168.163.202:6380 to cluster 192.168.163.201:6379 Connecting to node 192.168.163.201:6379: OK Connecting to node 192.168.163.203:6379: OK Connecting to node 192.168.163.202:6379: OK >>> Performing Cluster Check (using node 192.168.163.201:6379) M: 5571f088f9d8798dd0c2e973ced830c2cd8033a2 192.168.163.201:6379slots:0-5460 (5461 slots) master0 additional replica(s) M: 5c0ea563b464e58dd8dc9722cdfcb97a85c44714 192.168.163.203:6379slots:10923-16383 (5461 slots) master0 additional replica(s) M: 99a3516a03612dba4b73c32e7e1e03ff1145a660 192.168.163.202:6379slots:5461-10922 (5462 slots) master0 additional replica(s) [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. Connecting to node 192.168.163.202:6380: OK [ERR] Node 192.168.163.202:6380 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.補充: 對以上命令的說明,?命令作用:為redis集群添加節(jié)點 ,?把 202:6380 添加到 機器201:6379所在集群,集群master節(jié)點的hash為 5571f088f9d8798dd0c2e973ced830c2cd8033a2
?
2)停止202:6380 redis服務,并在202:6380機器上刪除 redis aof文件, nodes.conf 文件; 最后重新啟動 202:6380 redis服務
[root@centos202 ~]# ps -ef | grep redis root 1665 1 0 21:17 ? 00:00:09 /usr/local/bin/redis-server 192.168.163.202:6379 [cluster] root 1669 1 0 21:17 ? 00:00:07 /usr/local/bin/redis-server 192.168.163.202:6380 [cluster] root 1673 1 0 21:17 ? 00:00:07 /usr/local/bin/redis-server 192.168.163.202:6381 [cluster] root 1796 1694 0 23:04 pts/1 00:00:00 grep --color=auto redis [root@centos202 ~]# [root@centos202 ~]# kill -9 1669 [root@centos202 ~]# [root@centos202 ~]# ps -ef | grep redis root 1665 1 0 21:17 ? 00:00:09 /usr/local/bin/redis-server 192.168.163.202:6379 [cluster] root 1673 1 0 21:17 ? 00:00:07 /usr/local/bin/redis-server 192.168.163.202:6381 [cluster] root 1799 1694 0 23:06 pts/1 00:00:00 grep --color=auto redis [root@centos202 ~]# [root@centos202 6380]# cd data/ [root@centos202 data]# ll total 4 -rw-r--r--. 1 root root 0 Feb 18 21:17 appendonly.aof -rw-r--r--. 1 root root 229 Feb 18 22:49 nodes-6380.conf [root@centos202 data]# rm appendonly.aof rm: remove regular empty file 'appendonly.aof'? y [root@centos202 data]# ll total 4 -rw-r--r--. 1 root root 229 Feb 18 22:49 nodes-6380.conf [root@centos202 data]# rm -rf nodes-6380.conf [root@centos202 data]# ll total 0 [root@centos202 data]# [root@centos202 data]# /usr/local/bin/redis-server /usr/local/redis-cluster/6380/redis.conf [root@centos202 data]# [root@centos202 data]# ps -ef | grep redis root 1665 1 0 21:17 ? 00:00:10 /usr/local/bin/redis-server 192.168.163.202:6379 [cluster] root 1673 1 0 21:17 ? 00:00:07 /usr/local/bin/redis-server 192.168.163.202:6381 [cluster] root 1808 1 43 23:07 ? 00:00:01 /usr/local/bin/redis-server 192.168.163.202:6380 [cluster] root 1812 1694 0 23:07 pts/1 00:00:00 grep --color=auto redis3) 再次把 202:6380 添加到 機器201:6379所在集群
[root@centos201 ~]# /usr/local/redis-cluster/bin/redis-trib.rb add-node --slave --master-id 5571f088f9d8798dd0c2e973ced830c2cd8033a2 192.168.163.202:6380 192.168.163.201:6379 >>> Adding node 192.168.163.202:6380 to cluster 192.168.163.201:6379 Connecting to node 192.168.163.201:6379: OK Connecting to node 192.168.163.203:6379: OK Connecting to node 192.168.163.202:6379: OK >>> Performing Cluster Check (using node 192.168.163.201:6379) M: 5571f088f9d8798dd0c2e973ced830c2cd8033a2 192.168.163.201:6379slots:0-5460 (5461 slots) master0 additional replica(s) M: 5c0ea563b464e58dd8dc9722cdfcb97a85c44714 192.168.163.203:6379slots:10923-16383 (5461 slots) master0 additional replica(s) M: 99a3516a03612dba4b73c32e7e1e03ff1145a660 192.168.163.202:6379slots:5461-10922 (5462 slots) master0 additional replica(s) [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. Connecting to node 192.168.163.202:6380: OK >>> Send CLUSTER MEET to node 192.168.163.202:6380 to make it join the cluster. Waiting for the cluster to join. >>> Configure node as replica of 192.168.163.201:6379. [OK] New node added correctly.bingo 添加成功。
?
總結
以上是生活随笔為你收集整理的redis集群添加节点报错Either the node already knows other nodes (check with CLUSTER NODES) or contains some k的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: redis创建集群报错can‘t con
- 下一篇: 沈阳试点备案企业名单(沈阳试点备案)