1、配置文件准备
1.1、 新建目录:/home/docker/data/rocketmq/conf
mkdir /home/docker/data/rocketmq/conf
1.2、 在上面目录下新建文件broker.conf文件,内容如下
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH# 主机IP
brokerIP1 = 192.168.17.173
2、创建目录并赋权
mkdir -p /home/docker/data/rocketmq/data
3、编辑docker-compose-rocketmq.yml文件
进入/home/docker目录,新建docker-compose-rocketmq.yml文件,内容如下:
version: '3'
services:namesrv:image: rocketmqinc/rocketmqcontainer_name: rmqnamesrvports:- 9876:9876volumes:- /home/docker/data/rocketmq/logs:/home/rocketmq/logs- /home/docker/data/rocketmq/store:/home/rocketmq/storecommand: sh mqnamesrvbroker:image: rocketmqinc/rocketmqcontainer_name: rmqbrokerports:- 10909:10909- 10911:10911- 10912:10912volumes:- /home/docker/data/rocketmq/logs:/home/rocketmq/logs- /home/docker/data/rocketmq/store:/home/rocketmq/store- /home/docker/data/rocketmq/conf/broker.conf:/opt/rocketmq/conf/broker.confcommand: sh mqbroker -n namesrv:9876 -c /home/docker/data/rocketmq/conf/broker.confdepends_on:- namesrvenvironment:- JAVA_HOME=/usr/lib/jvm/jreconsole:image: styletang/rocketmq-console-ngcontainer_name: rocketmq-console-ngports:- 8087:8080depends_on:- namesrvenvironment:- JAVA_OPTS= -Dlogging.level.root=info -Drocketmq.namesrv.addr=rmqnamesrv:9876 - Dcom.rocketmq.sendMessageWithVIPChannel=false
4、启动Rocketmq
docker-compose -f docker-compose-rocketmq.yml up -d
5、效果展示
浏览器访问:http://192.168.17.173:8087/#/,效果图如下,至此,docker compose 搭建Rocketmq完成