docker快速部署rocketmq
操作步骤如下:
前提:已经安装了docker
1.docker search rocketmq
2.docker pull rocketmqinc/rocketmq
3. 创建 mq 配置文件 broker.conf
,文件放置到 /opt/rocketmq/conf
,配置如下:
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
brokerIP1 = x.x.x.x
4.创建如下文件夹:/opt/rocketmq/logs,/opt/rocketmq/store,最后创建 docker-compose.yml 文件,配置如下:version: '2'
version: '2'
services:
namesrv:
image: rocketmqinc/rocketmq
container_name: rmqnamesrv
ports:
- 9876:9876
volumes:
- /opt/rocketmq/logs:/home/rocketmq/logs
- /opt/rocketmq/store:/home/rocketmq/store
command: sh mqnamesrv
broker:
image: rocketmqinc/rocketmq
container_name: rmqbroker
ports:
- 10909:10909
- 10911:10911
- 10912:10912
volumes:
- /opt/rocketmq/logs:/home/rocketmq/logs
- /opt/rocketmq/store:/home/rocketmq/store
- /opt/rocketmq/conf/broker.conf:/opt/rocketmq/conf/broker.conf
#command: sh mqbroker -n namesrv:9876
command: sh mqbroker -n namesrv:9876 -c ../conf/broker.conf
depends_on:
- namesrv
environment:
- JAVA_HOME=/usr/lib/jvm/jre
console:
image: styletang/rocketmq-console-ng
container_name: rocketmq-console-ng
ports:
- 8087:8080
depends_on:
- namesrv
environment:
- JAVA_OPTS= -Dlogging.level.root=info -Drocketmq.namesrv.addr=rmqnamesrv:9876
- Dcom.rocketmq.sendMessageWithVIPChannel=false
5.配置完成之后,运行 docker-compose up 启动三个容器,启动成功后,访问 ip:8087,查看 mq 外部控制台,如果可以看到以下信息,rocketmq 服务启动成功。