Write zookeeper, rocketmq mirrored by Dockerfile

I. Background

    Since the company will be used zookeeper, rocketmq middleware, middleware and these require isolation in a test environment, so we decided to make zookeeper, rocketmq of the mirror and then you can run these images in each environment, you can greatly reduce the operation is repeated deployments.

Second, the production zookeeper mirror

2.1 write Dockerfile zookeeper mirror

  1. Extract the good zookeeper centos copied to the mirror comprising the jdk
  2. /Opt/zookeeper/conf/zoo.cfg modify configuration files
  3. Authorization / opt / zookeeper zookeeper belongs to the group and owner
  4. Zookeeper zookeeper started by the user, and the information on the terminal printer to redirect zookeeper.log
  5. You can perform positional parameters passed sysinit.sh
FROM registry.moguyun.com/centos7-jdk8
MAINTAINER lijun registry.moguyun.com
ENV REFRESHED_AT 20190726

ENV ZOO_HOME /opt/zookeeper
ENV ZOO_USER zookeeper
ENV ZOO_CLUSTER 1

RUN groupadd zookeeper && useradd zookeeper -g zookeeper -s /sbin/nologin -M
RUN yum install -y telnet lsof

ADD zookeeper $ZOO_HOME
WORKDIR /opt/zookeeper
RUN echo 'sed -i "s|zk${1}-mg-addr|0.0.0.0|g" '$ZOO_HOME'/conf/zoo.cfg' >> /bin/sysinit.sh && \
    echo 'echo ${1} > '$ZOO_HOME'/data/myid' >> /bin/sysinit.sh && \
    echo "chown -R zookeeper:zookeeper $ZOO_HOME" >> /bin/sysinit.sh && \
    echo "su $ZOO_USER -s /bin/bash -c \"cd $ZOO_HOME/bin && ./zkServer.sh start-foreground | tee ../logs/zookeeper.log \"" >> /bin/sysinit.sh

EXPOSE 2181 2888 3888

CMD ["sh", "-c", "/bin/sysinit.sh $ZOO_CLUSTER"]

Third, the production rocktmq mirror

3.1 Writing mq-namesrv mirror Dockerfile

  1. Extract the good rocketmq centos copied to the mirror comprising the jdk
  2. Optimization XMS (initialization heap memory size), Xmx (maximum heap memory), XMN (the young generation size) parameters, reference parameter tuning: the Xms, Xmx, tuning parameters Xmn
  3. Mqnamesrv startup script execution
FROM registry.moguyun.com/centos7-jdk8
MAINTAINER lijun registry.moguyun.com
ENV REFRESHED_AT 2019-08-14

ENV MQ_HOME=/opt/mq-namesrv

RUN groupadd messageQueue && useradd messageQueue -g messageQueue -s /sbin/nologin -M \
      && cd /opt && wget http://10.30.221.72/down/alibaba-rocketmq-3.2.6.tar.gz \
      && tar zxvf alibaba-rocketmq-3.2.6.tar.gz && mv alibaba-rocketmq $MQ_HOME \
      && rm alibaba-rocketmq-3.2.6.tar.gz && cd $MQ_HOME/bin \
      && sed -i "s/-Xms4g -Xmx4g -Xmn2g/-Xms2g -Xmx2g -Xmn1g/g" $MQ_HOME/bin/runserver.sh

EXPOSE 9876
CMD ["sh","/opt/mq-namesrv/bin/mqnamesrv"]

3.2 write mq-broker mirroring Dockerfile

  1. Extract the mq-broker good catalog copy image contains the jdk centos
  2. Mq-namesrv specified address and startup configuration file starts mq-broker
FROM registry.moguyun.com/centos7-jdk8
MAINTAINER lijun registry.moguyun.com
ENV REFRESHED_AT 2019-08-02

ENV MQ_HOME /opt/mq-broker
ENV MQ_NAMESRV "mq-mg-addr:9876"
ENV MQ_BROKER_CONF conf/2m-2s-async/broker-a.properties

ADD mq-broker $MQ_HOME
WORKDIR $MQ_HOME

RUN groupadd $MQ_USER && useradd $MQ_USER -g $MQ_USER -s /sbin/nologin -M && \
    echo "cat /etc/sysinit.sh" >> /etc/sysinit.sh && \
    echo "cd $MQ_HOME/bin ; sh mqbroker -n $MQ_NAMESRV -c $MQ_HOME/${1} " >> /etc/sysinit.sh

EXPOSE 10911
CMD ["sh","-c","/bin/sysinit.sh \"$MQ_BROKER_CONF\""]

 

Published 161 original articles · won praise 40 · views 120 000 +

Guess you like

Origin blog.csdn.net/qq_36441027/article/details/98944548