Docker 安装 rocketmq

本文详细介绍了如何使用Docker部署RocketMQ的namesrv和broker,包括下载镜像、设置环境变量、启动容器和配置文件。同时,也展示了启动RocketMQ监控Console的步骤,并提供了访问地址。在遇到启动问题时,通过检查日志和添加配置文件解决了问题,确保服务正常运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.下载docker镜像

本例选用的rockectmq镜像为:foxiswho/rocketmq

console镜像为:styletang/rocketmq-console-ng

docker pull foxiswho/rocketmq:4.8.0
docker pull styletang/rocketmq-console-ng

2.启动名称服务器namesrv

docker run -d -v /data/logs/rocketmq/logs:/home/rocketmq/logs \
--name rmqnamesrv \
-e "JAVA_OPT_EXT=-Xms512M -Xmx512M -Xmn128m" \
-p 9876:9876 \
foxiswho/rocketmq:4.8.0 \
sh mqnamesrv

映射本地目录logs权限一定要设置为 777 权限,否则启动不成功

3.启动broker

docker run -d -v /data/logs/rocketmq/logs:/home/rocketmq/logs \
-v /data/docker/store:/home/rocketmq/store \
-v /data/docker/conf:/home/rocketmq/conf \
--name rmqbroker \
-e "NAMESRV_ADDR=rmqnamesrv:9876" \
-e "JAVA_OPT_EXT=-Xms512M -Xmx512M -Xmn128m" \
-p 10911:10911 -p 10912:10912 -p 10909:10909 \
foxiswho/rocketmq:4.8.0 \
sh mqbroker -c /home/rocketmq/conf/broker.conf

查了下docker启动的容器,发现没有成功

 查看启动日志没有找到配置文件

在配置文件映射的位置/data/docker/conf下加上配置文件

附上配置文件内容

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
# 写自己的ip
brokerIP1 = 0.0.0.0
autoCreateTopicEnable = true

 再次启动,服务成功启动

 

4.启动console

docker run -d --name rmqcomsole \
-e "JAVA_OPTS=-Drocketmq.namesrv.addr=0.0.0.0:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" \
-p 8180:8080 -t styletang/rocketmq-console-ng

访问地址localhost:8180

 

参考地址:Docker Hub

RocketMQ-Docker安装 | 晓风残月的博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值