Node XXX is not empty. Either the node already knows other nodes or contains some key in database 0

本文介绍了解决Redis集群启动及添加主从节点时出现的[ERR]Node...问题的方法,包括删除备份文件、清空数据库等步骤,并提供详细的解决流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

关于启动redis集群或者集群(主、从)节点添加时:[ERR] Node 192.168.1.115:7007 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.的问题

1.启动redis集群报该错误解决办法:
1)将每个节点下aof、rdb、nodes.conf本地备份文件删除;
[root@localhost 7001]# rm -rf appendonly.aof dump.rdb
……
2)192.168.1.115:7001> flushdb 清空当前数据库
3)重新连接redis集群,成功

[root@localhost redis-cluster]# vi startCluster.sh 
./redis-trib.rb create --replicas l 192.168.1.115:7001 192.168.1.115:7002 192.168.1.115:7003 192.168.1.115:7004 192.168.1.115:7005 192.168.1.115:7006
[root@localhost redis-cluster]# chmod 777 startCluster.sh 
[root@localhost redis-cluster]# ./startCluster.sh 
>>> Creating cluster
Connecting to node 192.168.1.115:7001: OK
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.1.115:7001 
192.168.1.115:7002 
192.168.1.115:7003
..............
..............
Can I set the above configuration? (type 'yes' to accept): yes
.............
.............
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

这种情况发生在每次非正常关闭redis集群的时候

2.集群(主、从)节点添加报该错误解决办法:
错误原因:如果原来该结点在集群中的配置信息已经生成到cluster-config-file指定的配置文件中(如果cluster-config-file没有指定则默认为nodes.conf),这时可能会报错:
[ERR] Node XXXXXX is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0

解决方法:删除生成的配置文件nodes.conf,删除后再执行./redis-trib.rb add-node指令

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值