Docker配置RocketMQ

1、拉取RocketMQ镜像

1
docker pull foxiswho/rocketmq:broker-4.5.1

2、启动注册中心Nameserver

1
docker run -d -p 9876:9876 --name rmqserver foxiswho/rocketmq:server-4.5.1

3、创建RocketMQ配置文件

image-20240411235840559

1
2
//或者本地创建后上传到云主机上,路径可以根据自己设定
vim /usr/local/roketmq/conf/broker.conf
1
2
3
4
5
6
7
8
9
brokerIP1 = 填写你的云主机ip
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
enablePropertyFilter=true

4、启动RocketMQ

1
docker run -d -p 10911:10911 -p 10909:10909 --name rmqbroker --link rmqserver:namesrv -e "NAMESRV_ADDR=namesrv:9876" -e "JAVA_OPTS=-Duser.home=/opt" -e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m" -v  /usr/local/rocketmq/conf/broker.conf:/etc/rocketmq/broker.conf foxiswho/rocketmq:broker-4.5.1

5、拉取RocketMQ-dashboard镜像

1
docker pull pangliang/rocketmq-console-ng

6、启动dashboard

1
docker run -d --name rmqconsole -p 8180:8080 --link rmqserver:namesrv -e "JAVA_OPTS=-Drocketmq.namesrv.addr=namesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"  -t pangliang/rocketmq-console-ng

7、dashboard中添加topic

1
http://xxx.xxx.xxx.xxx:8180

8、检查

1
2
//检查服务运行状况
docker ps -a

image-20240412000329429

1
2
//检查服务运行是否成功、依次检查Nameserver、RocketMQ、RocketMQ-dashboard(暂不演示)
docker logs -CONTAINER ID

image-20240412000517073

image-20240412000735422

image-20240412001315222

image-20240412001331680

image-20240412001355627

参考链接


https://www.cnblogs.com/d1012181765/p/15603378.html

https://blog.csdn.net/qq_45297578/article/details/128723168