首先我们主机上需要有docker环境
搭建NameServer
docker run -d --restart=always --name rmqnamesrv -p 9876:9876 -v D:\rocketmq\logs:/root/logs -v D:\rocketmq\store:/root/store -e "MAX_POSSIBLE_HEAP=100000000" foxiswho/rocketmq:4.7.0 sh mqnamesrv
搭建Broker
docker run -d --restart=always --name rmqbroker --link rmqnamesrv:namesrv -p 10911:10911 -p 10909:10909 -v D:\rocketmq\logs:/root/logs -v D:\rocketmq\store:/root/store -v D:\rocketmq\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```
搭建查看面板
docker run -itd -e "JAVA_OPTS=-Drocketmq.namesrv.addr=127.0.0.1:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8082:8080 -t styletang/rocketmq-console-ng:latest
- 其中 D:\rocketmq\conf\broker.conf 为rocketmq broker配置文件路径
broker.conf 配置内容为
namesrvAddr=172.26.16.1:9876 #宿主机地址
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
brokerIP1 = 172.26.16.1 #宿主机地址
listenPort = 10911
其中 172.26.16.1 为宿主机IP地址
运行之后 打开 http://localhost:8082/