systemctl stop firewalld
systemctl start docker
docker run -d --name redis-node-1 --net host --privileged=true -v /data/redis/share/redis-node-1:/data redis:6.2.7 --cluster-enabled yes --appendonly yes --port 6381
docker run -d --name redis-node-2 --net host --privileged=true -v /data/redis/share/redis-node-2:/data redis:6.2.7 --cluster-enabled yes --appendonly yes --port 6382
docker run -d --name redis-node-3 --net host --privileged=true -v /data/redis/share/redis-node-3:/data redis:6.2.7 --cluster-enabled yes --appendonly yes --port 6383
docker run -d --name redis-node-4 --net host --privileged=true -v /data/redis/share/redis-node-4:/data redis:6.2.7 --cluster-enabled yes --appendonly yes --port 6384
docker run -d --name redis-node-5 --net host --privileged=true -v /data/redis/share/redis-node-5:/data redis:6.2.7 --cluster-enabled yes --appendonly yes --port 6385
docker run -d --name redis-node-6 --net host --privileged=true -v /data/redis/share/redis-node-6:/data redis:6.2.7 --cluster-enabled yes --appendonly yes --port 6386
docker exec -it redis-node-1 /bin/bash
进入docker容器后,执行下面的命令,注意自己的IP地址
redis-cli --cluster create 192.168.10.109:6381 192.168.10.109:6382 192.168.10.109:6383 192.168.10.109:6384 192.168.10.109:6385 192.168.10.109:6386 --cluster-replicas 1
- 1
–cluster-replicas 1表示为每个master创建一个slave节点
redis-cli -p 6381
cluster info
cluster nodes