問題示例:
執行創建redis集羣命令時,
# 我這裏ip都是172.17.0.1是因爲我這裏的redis節點都是docker容器,每個容器都已經映射到了主機172.17.0.1的不同端口
redis-cli --cluster create 172.17.0.1:6391 172.17.0.1:6392 172.17.0.1:6393 172.17.0.1:6394 172.17.0.1:6395 172.17.0.1:6396 --cluster-replicas 1
報錯:
>> Creating cluster
[ERR] Node 172.17.0.1:6379 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.
解決辦法:
- 1.停止所有redis進程(我集羣節點是 docker-compose 創建的,所以只需要docker-compose down即可)
- 2.將每個節點對應的.aof,.rdb .conf 文件刪除,(注意:啓動配置文件也是.conf後綴,請不要誤刪),具體文件對應位置需要查看每一個redis節點的啓動配置文件的配置項,如我的集羣配置文件:
dbfilename dump-6379.rdb
appendfilename "appendonly_6379.aof"
cluster-config-file "cluster/nodes-6379.conf"
- 3.啓動redis進程(.我集羣節點是 docker-compose 創建的,所以只需要docker-compose -d up即可),並重新創建集羣
redis-cli --cluster create 172.17.0.1:6391 172.17.0.1:6392 172.17.0.1:6393 172.17.0.1:6394 172.17.0.1:6395 172.17.0.1:6396 --cluster-replicas 1
參考文章:
1.
標題:[ERR] Node xxxxx is not empty. Either the node already knows other nodes (check with CLUSTER NODES)
地址:https://cloud.tencent.com/developer/article/1351139
2.
標題:[ERR] Node 172.168.63.202:7001 is not empty. Either the nodealready knows other nodes (check with CLUSTER NODES) or contains some
地址:https://www.cnblogs.com/huxinga/p/6644226.html