Docker 部署rocketMq 以及遇到的一些问题
1.docker 安装rocketmq
#拉取镜像
sudo docker pull foxiswho/rocketmq:server-4.7.0
sudo docker pull foxiswho/rocketmq:broker-4.7.0
2.创建server和broker目录,并创建broker.conf
#创建目录
sudo mkdir /opt/rocketmq-server
sudo mkdir /opt/rocketmq-broker/conf -p
sudo vim /opt/rocketmq-broker/conf/broker.conf
#配置内容
namesrvAddr=服务器公网IP:9876
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
brokerIP1 = 服务器公网IP
listenPort=10911
3.启动容器
#启动rocketmq-server
sudo docker run -d \
--restart=always \
--name rmqnamesrv \
-p 9876:9876 \
-v /opt/rocketmq-server/logs:/root/logs \
-v /opt/rocketmq-server/store:/root/store \
-e "MAX_POSSIBLE_HEAP=100000000" \
foxiswho/rocketmq:4.7.0 \
sh mqnamesrv
#启动rocketmq-broker
sudo docker run -d \
--restart=always \
--name rmqbroker \
--link rmqnamesrv:namesrv \
-p 10911:10911 \
-p 10909:10909 \
-v /opt/rocketmq-broker/logs:/root/logs \
-v /opt/rocketmq-broker/store:/root/store \
-v /opt/rocketmq-broker/conf/broker.conf:/opt/rocketmq-4.7.0/conf/broker.conf \
-e "NAMESRV_ADDR=namesrv:9876" \
-e "MAX_POSSIBLE_HEAP=200000000" \
-e "autoCreateTopicEnable=true" \
foxiswho/rocketmq:4.7.0 \
sh mqbroker -c /opt/rocketmq-4.7.0/conf/broker.conf
#启动RocketMQ的管理工具rocketmq-console
sudo docker run -itd -e "JAVA_OPTS=-Drocketmq.namesrv.addr=192.168.1.200:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8082:8080 -t styletang/rocketmq-console-ng:latest
4.测试访问console控制台
浏览器输入 公网ip:8082
5.遇到的一些问题
RemotingConnectException: connect to failed
出现该错误有以下几种可能
- 没有创建broker.conf
- 关联的配置目录不对
- 公网ip端口未开放防火墙
.