目錄結(jié)構(gòu)
├── conf
│ └── broker.conf
├── docker-compose.yaml
├── logs
└── store
docker-compose.yaml
version: '2'
services:
namesrv:
image: rocketmqinc/rocketmq
container_name: rmqnamesrv
restart: always
ports:
- 9876:9876
volumes:
- ./logs:/home/rocketmq/logs
- ./store:/home/rocketmq/store
command: sh mqnamesrv
broker:
image: rocketmqinc/rocketmq
container_name: rmqbroker
restart: always
ports:
- 10909:10909
- 10911:10911
- 10912:10912
volumes:
- ./logs:/home/rocketmq/logs
- ./store:/home/rocketmq/store
- ./conf/broker.conf:/opt/rocketmq-4.4.0/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
restart: always
ports:
- 8076:8080
depends_on:
- namesrv
environment:
- JAVA_OPTS= -Dlogging.level.root=info -Drocketmq.namesrv.addr=rmqnamesrv:9876
- Dcom.rocketmq.sendMessageWithVIPChannel=false
conf文件:
conf/broker.conf
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
# 如果是本地程序調(diào)用云主機 mq,這個需要設(shè)置成 云主機 IP
brokerIP1=192.168.2.234
在docker-compose.yaml同級目錄執(zhí)行
docker-compose up -d
docker-compose ps 查看啟動狀態(tài)
[root@argrace-ci rocketmq]# docker-compose ps
Name Command State Ports
-----------------------------------------------------------------------------------------------------------------------------------------------------
rmqbroker sh mqbroker -n namesrv:987 ... Up 0.0.0.0:10909->10909/tcp, 0.0.0.0:10911->10911/tcp, 0.0.0.0:10912->10912/tcp, 9876/tcp
rmqnamesrv sh mqnamesrv Up 10909/tcp, 10911/tcp, 0.0.0.0:9876->9876/tcp
rocketmq-console-ng sh -c java $JAVA_OPTS -jar ... Up 0.0.0.0:8076->8080/tcp
訪問ip+8076即可