配置redis.conf : bind0.0.0.0 protected-modeyes port 6379 daemonizeno pidfile/var/run/redis_6379.pid dbfilenamedump.rdb dir /data masterauth 密码 requirepass 密码 cluster-enabledyes cluster-config-filenodes-6379.conf cluster-node-timeout15000 启动 docker run -d -p6379:6379 -p 16379:16379 -v /root/redis1.conf:/etc/redis.conf redis:6.0.9/usr/local/bin/redis-server /etc/redis.conf docker run -d -p6380:6379 -p 16380:16379 -v /root/redis2.conf:/etc/redis.conf redis:6.0.9/usr/local/bin/redis-server /etc/redis.conf dockerrun -d -p 6381:6379 -p 16381:16379 -v /root/redis3.conf:/etc/redis.confredis:6.0.9 /usr/local/bin/redis-server /etc/redis.conf 获取容器IP dockerinspect b079690b48c2 23d2ea40b6dc ac3bb0152844 | grep IPAdd 启动集群(至少3结点) dockerexec -it ac3bb0152844 /usr/local/bin/redis-cli -a 密码 --cluster create172.17.0.4:6379 172.17.0.3:6379 172.17.0.2:6379 --cluster-replicas 0 --cluster-replicas 指定副本数 此处是0 , 指定1 就是一主一备
|