docker 安装 rocketMq 就是这么简单?

废话不多说 , 上才艺

  • rocketMq github : docker
  • rocketMq Version:
  • springboot 集成 RocketMq:
1.先把源码拉下来并执行构建脚本# 创建存储目录mkdir -p /home/service# 拉取源码git clone docker.git# 进入脚本目录cd /home/service/rocketmq-docker/image-build# 执行构建sh build-image.sh 4.7.1 alpine
docker 安装 rocketMq 就是这么简单?文章插图
注意:发现在构建的时候一直开在下载alpine , 下载的版本是v3.9 , 如果发现自己卡在那 , 请参考第二步 , 换成你自己的版本2. 替换下载源为阿里的站点 , 编辑 Dockerfile-alpine 文件(不替换忒慢 。。。 )# 找到 RUN apk add --no-cache bash gettext nmap-ncat openssl busybox-extras , 在上面添加以下2行替换命令RUN echo -e> /etc/apk/repositoriesRUN echo -e>> /etc/apk/repositories
docker 安装 rocketMq 就是这么简单?文章插图
3. 继续执行构建# 4.7.1 是我当时的最新版本了 , 可以根据上面那个 RocketMQ Version 查看新的版本sh build-image.sh 4.7.1 alpine
docker 安装 rocketMq 就是这么简单?文章插图
注意:然后我又发现卡在下载rocketmq-all-x-bin-release.zip4.没错 。。 继续换站点
  • 我们先去到 rocketMq 的官网: , 找到自己下载的版本对应的链接
  • 这是4.7.1的
  • 站点列表
  • 这是国内站点之一:
最终Dockerfile-alpine文件内容 , 仅供参考FROM openjdk:8-alpineRUN echo -e> /etc/apk/repositoriesRUN echo -e>> /etc/apk/repositoriesRUN apk add --no-cache bash gettext nmap-ncat openssl busybox-extrasARG user=rocketmqARG group=rocketmqARG uid=3000ARG gid=3000# RocketMQ is run with user `rocketmq`, uid = 3000# If you bind mount a volume from the host or a data container,# ensure you use the same uidRUN addgroup --gid ${gid} ${group} \\apk add --virtual .build-deps curl gnupg unzip; \curl -L /apache/rocketmq/${ROCKETMQ_VERSION}/rocketmq-all-${ROCKETMQ_VERSION}-bin-release.zip -o rocketmq.zip; \curl -L ${ROCKETMQ_VERSION}/rocketmq-all-${ROCKETMQ_VERSION}-bin-release.zip.asc -o rocketmq.zip.asc; \#curl -L-o KEYS; \\gpg --import KEYS; \gpg --batch --verify rocketmq.zip.asc rocketmq.zip; \unzip rocketmq.zip; \mv rocketmq-all*/* . ; \rmdir rocketmq-all* ; \rm rocketmq.zip rocketmq.zip.asc KEYS; \apk del .build-deps ; \rm -rf /var/cache/apk/* ; \rm -rf /tmp/*# Copy customized scriptsCOPY scripts/ ${ROCKETMQ_HOME}/bin/RUN chown -R ${uid}:${gid} ${ROCKETMQ_HOME}# Expose namesrv portEXPOSE 9876# Override customized scripts for namesrvRUN mv ${ROCKETMQ_HOME}/bin/runserver-customize.sh ${ROCKETMQ_HOME}/bin/runserver.sh \SYNC_MASTER 同步双写Master; SLAVEbrokerRole = ASYNC_MASTER# 刷盘方式 ASYNC_FLUSH 异步刷盘; SYNC_FLUSH 同步刷盘flushDiskType = ASYNC_FLUSH#set `brokerIP1` if you want to set physical IP as broker IP.brokerIP1=192.168.0.30 #change you own physical IP Address#是否开启自动注册topicautoCreateTopicEnable=false#是否开启自动注册groupautoCreateSubscriptionGroup=true#是否开启过滤查询enablePropertyFilter=true#再次执行docker run --restart=always -d -p 10911-10912:10911-10912 -p 10909:10909 --name rmqbroker \-v /home/config/docker/rocketmq/broker/logs:/root/logs \-v /home/config/docker/rocketmq/broker/store:/root/store \-v /home/config/docker/rocketmq/broker/conf/broker.conf:/home/rocketmq/rocketmq-4.7.1/conf/broker.conf \--link rmqnamesrv:namesrv \-e "NAMESRV_ADDR=namesrv:9876" \-e "JAVA_OPT=${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m -XX:PermSize=128m -XX:MaxPermSize=128m" \apacherocketmq/rocketmq:4.7.1-alpine sh mqbroker -c ../conf/broker.conf


推荐阅读