docker 离线安装 rocketmq 5.2.0
sudo mkdir -p /opt/rocketmq/conf/broker
sudo mkdir -p /opt/rocketmq/conf/namesrv
sudo mkdir -p /opt/rocketmq/data/broker
### nameservice.conf
listenPort: 9876
storePathRootDir: /opt/rocketmq-5.2.0/store
### broker.conf
# 集群名称
brokerClusterName = DefaultCluster
# 节点名称
brokerName = rocketmq-broker
# broker id节点ID, 0 表示 master, 其他的正整数表示 slave,不能小于0
brokerId = 0
# Broker服务地址 String 内部使用填内网ip,如果是需要给外部使用填公网ip,自行更改
brokerIP1 = x.x.x.x
# Broker角色
brokerRole = ASYNC_MASTER
# 刷盘方式
flushDiskType = ASYNC_FLUSH
# 在每天的什么时间删除已经超过文件保留时间的 commit log,默认值04
deleteWhen = 04
# 以小时计算的文件保留时间 默认值72小时
fileReservedTime = 72
# 是否允许Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable = true
# 是否允许Broker自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup = true
#开启多队列分发特性
enableLmq = true
enableMultiDispatch = true
### docker-compose.yml
version: '3.7'
services:
# NameServer 服务
rocketmq-namesrv:
image: apache/rocketmq:5.2.0
container_name: rocketmq-namesrv
ports:
- "9876:9876" # 映射 NameServer 的端口
volumes:
- ./conf/namesrv:/opt/rocketmq-5.2.0/conf # 映射配置文件目录
command: sh mqnamesrv # 启动 NameServer
environment:
- TZ=Asia/Shanghai
# Broker 服务
rocketmq-broker:
image: apache/rocketmq:5.2.0
container_name: rocketmq-broker
depends_on:
- rocketmq-namesrv # 依赖于 NameServer 启动完毕
ports:
- "10911:10911" # 映射 Broker 的端口
- "10909:10909" # 映射 Broker 的 HA 端口
- "8081:8081"
volumes:
- ./conf/broker:/opt/rocketmq-5.2.0/conf
# 映射配置文件目录
command: sh mqbroker -c /opt/rocketmq-5.2.0/conf/broker.conf -n rocketmq-namesrv:9876 --enable-proxy autoCreateTopicEnable=true # 启动 Broker
environment:
- TZ=Asia/Shanghai
# RocketMQ Console 服务
rocketmq-console:
image: styletang/rocketmq-console-ng
container_name: rocketmq-console
ports:
- "8083:8080" # 映射 RocketMQ Console 的端口
environment:
- rocketmq.config.namesrvAddr=rocketmq-namesrv:9876 # 配置 RocketMQ Console 连接的 NameServer 地址
- TZ=Asia/Shanghai
在国内很多时候没有办法下载镜像,这里给了离线的镜像,方便使用:
链接:https://pan.baidu.com/s/1AHVeHJfV4C0D9rdIPvjueg?pwd=2333
sudo docker load -i rocketmq-5.2.0.tar
sudo docker load -i rocketmq-console-ng.tar