哈哈,随意查询了一下docker安装rocketmq。基本都是用的rocketmqinc/rocketmq,foxiswho/rocketmq 这两个镜像。仔细一看都最少2年没维护了(;′⌒`)
直接贴docker-compose.yml
services:
#Service for nameserver
namesrv:
image: apache/rocketmq:4.9.4
container_name: rmqnamesrv
ports:
- 9876:9876
environment:
JAVA_OPT_EXT: "-server -Xms128m -Xmx128m -Xmn128m"
volumes:
- /data/namesrv/logs:/root/logs
command: sh mqnamesrv
#Service for broker
broker:
image: apache/rocketmq:4.9.4
container_name: rmqbroker
links:
- namesrv
depends_on:
- namesrv
ports:
- 10909:10909
- 10911:10911
- 10912:10912
environment:
NAMESRV_ADDR: "namesrv:9876"
JAVA_OPT_EXT: "-server -Xms128m -Xmx128m -Xmn128m"
volumes:
- /data/broker/logs:/root/logs
- /data/broker/store:/root/store
- /data/broker/conf/broker.conf:/home/rocketmq/rocketmq-4.9.4/conf/broker.conf
command: sh mqbroker -c /home/rocketmq/rocketmq-4.9.4/conf/broker.conf
rocketmq-console:
image: styletang/rocketmq-console-ng
container_name: rocketmq-console
ports:
- 9090:8080
environment:
JAVA_OPTS: -Drocketmq.namesrv.addr=rmqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false
depends_on:
- broker
任意位置创建docker-compose.yml文件复制进去 docker-compose up 启动
image 可以修改为你需要的版本(主要新版本映射的地址是在/root下面)
注意事项 提前创建好挂载的目录
mkdir -p /data/namesrv/logs
mkdir -p /data/broker/logs
mkdir -p /data/broker/store
mkdir -p /data/broker/conf
将配置文件 broker.conf 放在 /data/broker/conf 目录下
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
#set `brokerIP1` if you want to set physical IP as broker IP.
brokerIP1=192.168.229.25
autoCreateTopicEnable = true
配置说明
brokerIP1 为你的服务器地址
autoCreateTopicEnable = true 自动创建topic
最后访问 IP:9090 查看rocketmq-console 页面