docker部署rocketmq(亲测有效)

1.docker 安装rocketmq

#拉取镜像 
docker pull foxiswho/rocketmq:server-4.7.0
docker pull foxiswho/rocketmq:broker-4.7.0

2.创建server和broker目录,并创建broker.conf

#创建目录
mkdir /opt/rocketmq-server
mkdir /opt/rocketmq-broker/conf -p
[root@localhost opt]# cat /opt/rocketmq-broker/conf/broker.conf 
namesrvAddr=192.168.1.200:9876
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
brokerIP1 = 192.168.1.200
listenPort=10911

3.启动容器

#启动rocketmq-server
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
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
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控制台

浏览器输入:192.168.1.200:8082

你可能感兴趣的:(docker,java-rocketmq,rocketmq)