redis集群dockerfile(有问题)
温馨提示:
本文最后更新于 2021年04月28日,已超过 1,260 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我。
FROM centos:8
ENV REDIS_VERSION 6.2.2
ENV PORT_01 9001
ENV PORT_02 9002
ENV PORT_03 9003
ENV PORT_04 9004
ENV PORT_05 9005
ENV PORT_06 9006
RUN yum -y update
RUN yum install -y wget
RUN yum install -y gcc gcc-c++ make
RUN mkdir /redis
RUN cd /redis\
&& wget https://download.redis.io/releases/redis-${REDIS_VERSION}.tar.gz -O redis.tar.gz\
&& mkdir -p redis \
&& tar -zvxf redis.tar.gz \
&& rm -rf redis.tar.gz\
&& cd redis-${REDIS_VERSION}\
&& make
## 建立集群目录
RUN mkdir /redis/redis01 /redis/redis02 /redis/redis03 /redis/redis04 /redis/redis05 /redis/redis06
## 复制redis文件
RUN cp /redis/redis-${REDIS_VERSION}/{redis.conf,src/redis-server,src/redis-cli} /redis/redis01/
## 修改监听地址
RUN sed -i "s/\(^bind.*\)/\#\1\nbind 0.0.0.0/" /redis/redis01/redis.conf
## 开启集群配置
RUN sed -i "s/\(^\#.\*cluster-enabled yes.\*\)/\ncluster-enabled yes/" /redis/redis01/redis.conf
RUN sed -i "s/\(^daemonize.*\)/\daemonize yes/" /redis/redis01/redis.conf
RUN cp -rf /redis/redis01/* /redis/redis02/\
&& cp -rf /redis/redis01/* /redis/redis03/\
&& cp -rf /redis/redis01/* /redis/redis04/\
&& cp -rf /redis/redis01/* /redis/redis05/\
&& cp -rf /redis/redis01/* /redis/redis06/
RUN sed -i "s/\(^port.*\)/\#\1\nport ${PORT_01}/" /redis/redis01/redis.conf
RUN sed -i "s/\(^port.*\)/\#\1\nport ${PORT_02}/" /redis/redis02/redis.conf
RUN sed -i "s/\(^port.*\)/\#\1\nport ${PORT_03}/" /redis/redis03/redis.conf
RUN sed -i "s/\(^port.*\)/\#\1\nport ${PORT_04}/" /redis/redis04/redis.conf
RUN sed -i "s/\(^port.*\)/\#\1\nport ${PORT_05}/" /redis/redis05/redis.conf
RUN sed -i "s/\(^port.*\)/\#\1\nport ${PORT_06}/" /redis/redis06/redis.conf
WORKDIR /redis
CMD cd /redis/redis01 && /redis/redis01/redis-server /redis/redis01/redis.conf;\
&& cd /redis/redis02 && /redis/redis02/redis-server /redis/redis02/redis.conf;\
&& cd /redis/redis03 && /redis/redis03/redis-server /redis/redis03/redis.conf;\
&& cd /redis/redis04 && /redis/redis04/redis-server /redis/redis04/redis.conf;\
&& cd /redis/redis05 && /redis/redis05/redis-server /redis/redis05/redis.conf;\
&& cd /redis/redis06 && /redis/redis06/redis-server /redis/redis06/redis.conf;
CMD /redis/redis01/redis-cli --cluster create 127.0.0.1:${PORT_01} 127.0.0.1:${PORT_02} 127.0.0.1:${PORT_03} 127.0.0.1:${PORT_04} 127.0.0.1:${PORT_05} 127.0.0.1:${PORT_06} --cluster-replicas 1
EXPOSE ${PORT_01} ${PORT_02} ${PORT_03} ${PORT_04} ${PORT_05} ${PORT_06}
正文到此结束
- 本文标签: 乱七八糟
- 本文链接: https://www.php20.cn/article/285
- 版权声明: 本文由仙士可原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权