docker 配置Redis 单主单从配置

三主三从的Redis 出现了,在外部无法分配key到其他主节点的情况(本机上没有任何问题),由于项目着急上线,目前使用一主一从的配置,具体配置情况如下。

dockerfile 

FROM redis
COPY redis.conf /usr/local/etc/redis/redis.conf
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]

主节点的redis 配置

bind 0.0.0.0
port 6379

daemonize yes
pidfile /root/redis/redis_6379.pid

#cluster-enabled yes // 必须注掉这行,要不默认是配置集群的
cluster-config-file nodes_6379.conf
cluster-node-timeout 15000
appendonly yes

从节点的配置

#bind 0.0.0.0 从节点必须注掉这行,要不连接不到外面
port 6380

daemonize yes
pidfile /root/redis/redis_6380.pid

#cluster-enabled yes
cluster-config-file nodes_6380.conf
cluster-node-timeout 15000
appendonly yes
slaveof xx.xxx.xxx.xx(主节点的IP) 6379
                        

分别用这两个 配置文件创建主的镜像 和从的镜像

启动容器,为了省去配置端口的麻烦可以使考虑使用 --net=host  这个配置启动容器,这样默认所有端口都能访问的。

这样一主一从的Redis 就配置完了。

如果没有启动成功的话 可以考虑进入容器重启redis 服务 

redis-server /usr/local/etc/redis/redis.conf



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值