1.docker-compose.yml 文件
version: '3'
services:
mqnamesrv:
image: apache/rocketmq:4.9.4
container_name: mqnamesrv
ports:
- "9876:9876"
environment:
JAVA_OPT: -server -Xms512m -Xmx512m
command: sh mqnamesrv
volumes:
- /usr/local/rocketmq/namesrv/logs:/home/rocketmq/logs/rocketmqlogs
mqbroker:
image: apache/rocketmq:4.9.4
container_name: mqbroker
ports:
- "10911:10911"
- "10909:10909"
- "10912:10912"
environment:
NAMESRV_ADDR: "mqnamesrv:9876"
JAVA_OPT_EXT: -server -Xms512M -Xmx512M -Xmn256m
command: ["sh","mqbroker","-c","/home/rocketmq/rocketmq-4.9.4/conf/broker.conf","-n","mqnamesrv:9876","autoCreateTopicEnable=true"]
depends_on:
- mqnamesrv
volumes:
- /usr/local/rocketmq/broker/conf/broker.conf:/home/rocketmq/rocketmq-4.9.4/conf/broker.conf
- /usr/local/rocketmq/broker/logs:/home/rocketmq/logs/rocketmqlogs
- /usr/local/rocketmq/broker/store:/home/rocketmq/store
mqconsole:
image: styletang/rocketmq-console-ng
container_name: mqconsole
ports:
- "9877:9877"
environment:
JAVA_OPTS: -Dserver.port=9877 -Drocketmq.namesrv.addr=mqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false
depends_on:
- mqnamesrv
2.broker.conf 配置
brokerClusterName = DefaultCluster
brokerName = broker1
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
节点需要配置ip1和ip2,从节点只需要配置ip1即可)
brokerIP1 = 42.192.166.196
namesrvAddr=mqnamesrv:9876
listenPort = 10911
autoCreateTopicEnable = true
autoCreateSubscriptionGroup = true
3.目录结构
[root@VM-0-8-centos rocketmq]
total 12
drwxrwxrwx 5 777 root 4096 Aug 30 20:15 broker
-rwxrwxrwx 1 777 root 1274 Aug 30 20:14 docker-compose.yml
drwxrwxrwx 3 777 root 4096 Aug 30 20:15 namesrv
[root@VM-0-8-centos rocketmq]
[root@VM-0-8-centos broker]
total 12
drwxrwxrwx 2 777 root 4096 Dec 27 13:54 conf
drwxrwxrwx 3 777 root 4096 Dec 26 20:12 logs
drwxrwxrwx 6 777 root 4096 Aug 30 21:24 store
[root@VM-0-8-centos broker]
[root@VM-0-8-centos broker]
[root@VM-0-8-centos conf]
total 4
-rwxrwxrwx 1 777 root 1603 Aug 30 20:15 broker.conf
4.特别注意 使用官方镜像 需要给整个rocketmq 文件夹可读可写权限 否则应用无法连接