redis.conf配置文件
(1)port 8001
(2)#bind 0.0.0.0
(3)cluster-enabled yes
(4)cluster-config-file nodes.conf
(5)cluster-node-timeout 5000
(6)appendonly yes
(7)cluster-announce-ip 192.168.1.96
# 保护模式
(8)protected-mode no
上面的(1)(7)要换成自己的地址和端口
docker pull redis
docker run -d --name my-redis8001 -p 8001:8001 -p 18001:18001 -v C:\\redis-cluster\\8001\\redis.conf:/etc/redis/redis.conf redis redis-server /etc/redis/redis.conf
docker run -d --name my-redis8002 -p 8002:8002 -p 18002:18002 -v C:\\redis-cluster\\8002\\redis.conf:/etc/redis/redis.conf redis redis-server /etc/redis/redis.conf
docker run -d --name my-redis8003 -p 8003:8003 -p 18003:18003 -v C:\\redis-cluster\\8003\\redis.conf:/etc/redis/redis.conf redis redis-server /etc/redis/redis.conf
docker run -d --name my-redis8004 -p 8004:8004 -p 18004:18004 -v C:\\redis-cluster\\8004\\redis.conf:/etc/redis/redis.conf redis redis-server /etc/redis/redis.conf
docker run -d --name my-redis8005 -p 8005:8005 -p 18005:18005 -v C:\\redis-cluster\\8005\\redis.conf:/etc/redis/redis.conf redis redis-server /etc/redis/redis.conf
docker run -d --name my-redis8006 -p 8006:8006 -p 18006:18006 -v C:\\redis-cluster\\8006\\redis.conf:/etc/redis/redis.conf redis redis-server /etc/redis/redis.conf
redis-cli --cluster create --cluster-replicas 1 192.168.1.96:8001 192.168.1.96:8002 192.168.1.96:8003 192.168.1.96:8004 192.168.1.96:8005 192.168.1.96:8006
这样集群就搭建完成了