docker 在多机器上进行redis集群搭建(解决Waiting for the cluster to join)

错误Waiting for the cluster to join

root@36dfbf058500:/data# redis-cli -a 123456 --cluster create 192.168.1.120:6379 192.168.1.128:6379 192.168.1.128:6380 192.168.1.128:6381 --cluster-replicas 0
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Performing hash slots allocation on 4 nodes...
Master[0] -> Slots 0 - 4095
Master[1] -> Slots 4096 - 8191
Master[2] -> Slots 8192 - 12287
Master[3] -> Slots 12288 - 16383
M: 3c45a838ff75d722f0fa611491908cbe674fa349 192.168.1.120:6379
   slots:[0-4095] (4096 slots) master
M: 8f20b5e86ad23aa5f79bbacedc1c64cb4e6d9761 192.168.1.128:6379
   slots:[4096-8191] (4096 slots) master
M: 63ade837c0408caa3f9dd16d08fdef42a57877ac 192.168.1.128:6380
   slots:[8192-12287] (4096 slots) master
M: 5ff4208e009a24e0326e50539d2c27f8220f7db0 192.168.1.128:6381
   slots:[12288-16383] (4096 slots) master
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
............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

 

等了好久好久,

其实不用等了,

再等也没用。。。

解决Waiting for the cluster to join

这问题如果在多台机器上,并用docker创建redis,且用-p 进行端口映射是不行的。

改用网络模式为host即--net host

指定端口即--port 6379

创建redis

  •         主机1(192.168.1.120)
docker run -itd --name redis-node0 --net host  -v /home/workspace/redis-node0/data:/data  -e TZ="Asia/Shanghai" --restart=always redis:latest redis-server --appendonly yes  --requirepass 123456 --cluster-enabled yes --port 6379
  •         主机2(192.168.1.128)
docker run -itd --name redis-node1 --net host -v /home/workspace/redis-node1/data:/data  -e TZ="Asia/Shanghai" --restart=always  redis:latest  redis-server --appendonly yes  --requirepass 123456 --cluster-enabled yes --port 6379
docker run -itd --name redis-node2 --net host -v /home/workspace/redis-node2/data:/data  -e TZ="Asia/Shanghai" --restart=always  redis:latest  redis-server --appendonly yes  --requirepass 123456 --cluster-enabled yes --port 6380
docker run -itd --name redis-node3 --net host -v /home/workspace/redis-node3/data:/data  -e TZ="Asia/Shanghai" --restart=always  redis:latest  redis-server --appendonly yes  --requirepass 123456 --cluster-enabled yes --port 6381

 

组建集群

## 进入随意一个节点的容器,以redis-node0为例
docker exec -it redis-node0 /bin/bash
## 执行命令
redis-cli -a 123456 --cluster create 192.168.1.120:6379 192.168.1.128:6379 192.168.1.128:6380 192.168.1.128:6381 --cluster-replicas 0

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值