docker 部署rocketmq 5.0

docker 部署rocketmq 5.0.0

  • broker
    • namesrv
    • dashboard

broker

Dockerfile

FROM openjdk:8-jdk

ENV ROCKETMQ_VERSION 5.0.0

ENV BROKER_HOME="/home/rocketmq" JAVA_OPT="-Duser.home=/home/rocketmq"

WORKDIR ${BROKER_HOME}

RUN mkdir -p /home/rocketmq/logs /home/rocketmq/store

RUN curl https://dist.apache.org/repos/dist/release/rocketmq/${ROCKETMQ_VERSION}/rocketmq-all-${ROCKETMQ_VERSION}-bin-release.zip -o rocketmq.zip \
    && unzip rocketmq.zip \
    && rm -f rocketmq.zip \
    && mv rocketmq-all-${ROCKETMQ_VERSION}-bin-release/* ./ \
    && rm -rf rocketmq-all-${ROCKETMQ_VERSION}-bin-release \
    && cd ${BROKER_HOME}/bin \
    && sed -i 's#-Xms[0-9]\+[gm]#-Xms512m#g' runbroker.sh \
    && sed -i 's#-Xmx[0-9]\+[gm]#-Xms512m#g' runbroker.sh \
    && sed -i 's#-Xmn[0-9]\+[gm]#-Xms128m#g' runbroker.sh \
    && chmod +x ./mqbroker

EXPOSE 10909 10911 10912

VOLUME ["/home/rocketmq/logs", "/home/rocketmq/store"]

CMD sh ${BROKER_HOME}/bin/mqbroker -c /home/rocketmq/conf/broker.conf -n rocketmq-namesrv:9876 autoCreateTopicEnable=true

namesrv

Dockerfile

FROM openjdk:8-jdk

ENV ROCKETMQ_VERSION 5.0.0

ENV NAMESRV_HOME="/home/rocketmq/namesrv-${ROCKETMQ_VERSION}" JAVA_OPT="-Duser.home=/home/rocketmq"

WORKDIR ${NAMESRV_HOME}

RUN mkdir -p /home/rocketmq/logs /home/rocketmq/store

RUN curl https://dist.apache.org/repos/dist/release/rocketmq/${ROCKETMQ_VERSION}/rocketmq-all-${ROCKETMQ_VERSION}-bin-release.zip -o rocketmq.zip \
    && unzip rocketmq.zip \
    && rm -f rocketmq.zip \
    && ls \
    && mv rocketmq-all-${ROCKETMQ_VERSION}-bin-release/* ./ \
    && rm -rf rocketmq-all-${ROCKETMQ_VERSION}-bin-release \
    && cd ${NAMESRV_HOME}/bin \
    && sed -i 's#-Xms[0-9]\+[gm]#-Xms512m#g' runserver.sh \
    && sed -i 's#-Xmx[0-9]\+[gm]#-Xms512m#g' runserver.sh \
    && sed -i 's#-Xmn[0-9]\+[gm]#-Xms128m#g' runserver.sh \
    && sed -i 's#-XX:MetaspaceSize=[0-9]\+[gm]#-XX:MetaspaceSize=128m#' runserver.sh \
    && sed -i 's#-XX:MaxMetaspaceSize=[0-9]\+[gm]#-XX:MaxMetaspaceSize=320m#' runserver.sh \
    && chmod +x ./mqnamesrv

CMD sh ${NAMESRV_HOME}/bin/mqnamesrv

EXPOSE 9876

VOLUME ["/home/rocketmq/logs", "/home/rocketmq/store"]

dashboard

Dockerfile

FROM openjdk:8-jdk
VOLUME /tmp
ADD rocketmq-dashboard-1.0.0.jar rocketmq-dashboard.jar
RUN sh -c 'touch /rocketmq-dashboard.jar'
ENV JAVA_OPTS=""
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -jar /rocketmq-dashboard.jar" ]

##步骤

#版本V5.0.0
1.准备前置文件
namesrv Dockerfile:
broker Dockerfile:
dashboard Dockerfile:
下载地址
https://github.com/apache/rocketmq-dashboard/tree/release-1.0.0

Maven打包生成rocketmq-dashboard-1.0.0.jar与Dockerfile放置同一目录下。
2.构建镜像
namesrv
docker build -f Dockerfile -t rmq-namesrv:5.0.0 .

broker
docker build -f Dockerfile -t rmq-broker:5.0.0 .

dashboard
docker build -t rmq-dashboard:laster .

3.运行容器

namesrv
docker run -d --name rmq-namesrv -e “JAVA_OPT_EXT=-Xms512M -Xmx512M -Xmn128M” -p 9876:9876 -v /localdata/rocketmq/logs:/home/rocketmq/logs -v /localdata/rocketmq/store:/home/rocketmq/store rmq-namesrv:5.0.0

broker
docker run -d --name rmq-broker -e “JAVA_OPT_EXT=-Xmx512M -Xmx512M -Xmn128M” -p 10909:10909 -p 10911:10911 -p 10912:10912 -v /localdata/rocketmq/conf/broker.conf:/home/rocketmq/conf/broker.conf -v /localdata/rocketmq/logs:/home/rocketmq/logs -v /localdata/rocketmq/store:/home/rocketmq/store rmq-broker:5.0.0 bash /home/rocketmq/bin/mqbroker -c /home/rocketmq/conf/broker.conf -n **#ip **:9876 autoCreateTopicEnable=true

dashboard
docker run --name rmq-dashboard -e “JAVA_OPTS=-Drocketmq.namesrv.addr=**#ip **:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false” -p 8099:8080 -t rmq-dashboard:laster

docker 部署rocketmq 5.0_第1张图片
附broker.conf

# 所属集群名称,如果节点较多可以配置多个
brokerClusterName = DefaultCluster
#broker名称,master和slave使用相同的名称,表明他们的主从关系 
brokerName = broker-a
#0表示Master,大于0表示不同的
slave brokerId = 0
#表示几点做消息删除动作,默认是凌晨4点 
deleteWhen = 04
#在磁盘上保留消息的时长,单位是小时 
fileReservedTime = 48
#有三个值:SYNC_MASTER,ASYNC_MASTER,SLAVE;同步和异步表示Master和Slave之间同步数据的机 制;
brokerRole = ASYNC_MASTER
#刷盘策略,取值为:ASYNC_FLUSH,SYNC_FLUSH表示同步刷盘和异步刷盘;SYNC_FLUSH消息写入磁盘后 才返回成功状态,ASYNC_FLUSH不需要;
flushDiskType = ASYNC_FLUSH
# 设置broker节点所在服务器的ip地址 
brokerIP1 = {broker_ip}
#剩余磁盘比例 
diskMaxUsedSpaceRatio=99
#自动创建topic
autoCreateTopicEnable=true

broker.conf中{broker_ip} 替换为当前服务器ip

你可能感兴趣的:(docker,java-rocketmq,rocketmq)