首先去这里下载https://github.com/apache/rocketmq-externals
帮助文档在这https://github.com/apache/rocketmq-externals/tree/master/rocketmq-docker
官方文档已经很清晰的教给怎么用docker部署了
先创建目录/home/data/rocketmq,broker.conf还有docker-compose.yml放在该目录下
ps 这一步可以跳过,可以用docker-compose.yml直接下载镜像
拉下来代码后
进入/home/rocketmq-externals-master/rocketmq-docker/image-build
执行 sh build-image.sh RMQ-4.3.0 这里是RMQ-版本
然后返回上一级
执行 sh stage.sh 4.3.0 后边这个是版本,这个命令会在stage目录下生成4.3.0/templates两个目录
进入 /home/rocketmq-externals-master/rocketmq-docker/stages/4.3.0/templates
单节点的话执行./play-docker.sh 命令
集群部署 官方文档也给了说明
这个命令会下载相关镜像
接下来我们来编写docker-rocketmq-compose.yml 文件
vi docker-rocketmq-compose.yml
version: '3.5'
services:
rmqnamesrv:
image: rocketmqinc/rocketmq:4.3.0
container_name: rmqnamesrv
ports:
- 9876:9876
volumes:
- /opt/logs:/opt/logs
- /opt/store:/opt/store
command: sh mqnamesrv
networks:
rmq:
aliases:
- rmqnamesrv
rmqbroker:
image: rocketmqinc/rocketmq:4.3.0
container_name: rmqbroker
ports:
- 10909:10909
- 10911:10911
volumes:
- /opt/logs:/opt/logs
- /opt/store:/opt/store
- /home/data/rocketmq/broker.conf:/opt/rocketmq-4.3.0/conf/broker.conf
environment:
TZ: Asia/Shanghai
NAMESRV_ADDR: "rmqnamesrv:9876"
JAVA_OPTS: " -Duser.home=/opt"
JAVA_OPT_EXT: "-server -Xms512m -Xmx512m -Xmn512m"
command: sh mqbroker rmqnamesrv:9876 -c /opt/rocketmq-4.3.0/conf/broker.conf autoCreateTopicEnable=true
depends_on:
- rmqnamesrv
networks:
rmq:
aliases:
- rmqbroker
rmqconsole:
image: styletang/rocketmq-console-ng
container_name: rmqconsole
ports:
- 9001:8080
environment:
JAVA_OPTS: "-Drocketmq.namesrv.addr=rmqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=true"
depends_on:
- rmqnamesrv
networks:
rmq:
aliases:
- rmqconsole
networks:
rmq:
name: rmq
driver: bridge
创建broker.conf,用来替换镜像里的broker.conf
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
brokerIP1=外网ip
brokerIP2=外网ip
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
autoCreateTopicEnable=true
执行 docker-compose -f docker-rocketmq-compose.yml up -d
这个命令会自动运行容器镜像
控制台可能会有问题,消费者 版本会显示HigherVersion,但是可以正常消费
来源:CSDN
作者:bpqdwo
链接:https://blog.csdn.net/bpqdwo/article/details/93203805