标签:运行 for ash out redis block enable 数值 bash
1.下载redis镜像2.在host目录创建6个目录为7000,7001,7002,7003,7004,7005,7006,每个目录复制一份redis.conf:
#修改配置,7005为对应的端口,cluster-announce-bus-port为10000+该端口的数值
port 7005
cluster-enabled yes
cluster-config-file nodes-7005.conf
cluster-node-timeout 10000
cluster-announce-ip 外网ip或内网ip(添加到docker的命令:ifconfig eth1:0 ip netmask 255.255.255.0 up)
cluster-announce-port 7005
cluster-announce-bus-port 17005
appendonly yes
3.启动redis节点
docker run -p 7000:7000 -p 17000:17000 --name redis7000 -v host目录/7000/redis.conf:/etc/redis/redis.conf -v /htdocs/redis/7000:/data -d redis redis-server /etc/redis/redis.conf
docker run -p 7001:7001 -p 17001:17001 --name redis7001 -v host目录/7001/redis.conf:/etc/redis/redis.conf -v /htdocs/redis/7001:/data -d redis redis-server /etc/redis/redis.conf
docker run -p 7002:7002 -p 17002:17002 --name redis7002 -v host目录/7002/redis.conf:/etc/redis/redis.conf -v /htdocs/redis/7002:/data -d redis redis-server /etc/redis/redis.conf
docker run -p 7003:7003 -p 17003:17003 --name redis7003 -v host目录/7003/redis.conf:/etc/redis/redis.conf -v /htdocs/redis/7003:/data -d redis redis-server /etc/redis/redis.conf
docker run -p 7004:7004 -p 17004:17004 --name redis7004 -v host目录/7004/redis.conf:/etc/redis/redis.conf -v /htdocs/redis/7004:/data -d redis redis-server /etc/redis/redis.conf
docker run -p 7005:7005 -p 17005:17005 --name redis7005 -v host目录/7005/redis.conf:/etc/redis/redis.conf -v /htdocs/redis/7005:/data -d redis redis-server /etc/redis/redis.conf
(1)-p是将容器的端口绑定到host的端口
(2)--name是容器名
(3)-v是将host的目录复制到容器目录下
(4)-d是容器后台运行
4.启动集群:
docker exec -it 某一个redis节点容器id /bin/bash 进入某一个redis容器后运行命令:
redis-cli --cluster create 外网ip或内网ip:7000 外网ip或内网ip:7001 外网ip或内网ip:7002 外网ip或内网ip:7003 外网ip或内网ip:7004 外网ip或内网ip:7005 --cluster-replicas 1
如果看到有输出
[OK] All nodes agree about slots configuration.
\>>> Check for open slots...
\>>> Check slots coverage...
[OK] All 16384 slots covered.
则创建成功
我一直都是Waiting for the cluster to join,基本就是网路问题了,最后配置修改成如上所示则终于成功
标签:运行 for ash out redis block enable 数值 bash
原文地址:https://blog.51cto.com/hjun169/2433684