启动多个实例
for i in {7000..7002}
do
docker run -d --name Redis-cache-cluster-node-${i} \
--network=host \
-v Redis-cache-cluster-node-${i}_data:/data \
redis:6.0.6 \
redis-server --port ${i} --cluster-enabled yes --cluster-config-file nodes.conf -- cluster-node-timeout 5000 --appendonly yes
done
创建 cluster
docker run -it --rm --network=host redis \
redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002
在 Ubuntu 上面,是可以成功创建 cluster 的,但是在 macOS 上面却不行,一直卡在“Waiting for the cluster to join”,到底是为什么呢?
关于网络问题,我已经查阅了ip - Docker container doesn't expose ports when --net=host is mentioned in the docker run command - Stack Overflow、Block/disallow --net=host (host networking) on Mac OS · Issue #2716 · docker/for-mac,并且尝试过使用-p ${i}:${i} -p $((${i} + 10000)):$((${i} + 10000))替换--network=host,结果还是不行。
