0. 拉取镜像
docker pull apache/rocketmq:5.2.0
docker pull styletang/rocketmq-console-ng
1. 创建容器共享网络
docker network create rocketmq
2. 启动NameServer
# 启动 NameServer
docker run -d --name rmqnamesrv -p 9876:9876 --network rocketmq apache/rocketmq:5.2.0 sh mqnamesrv
# 验证 NameServer 是否启动成功
docker logs -f rmqnamesrv
我们可以看到 ‘The Name Server boot success…’, 表示NameServer 已成功启动。
3. 启动 Broker+Proxy
# 配置 Broker 的IP地址
[root@localhost rocketmq]# cat broker.conf
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
# 启动 Broker 和 Proxy
docker run -d \
--name rmqbroker \
--network rocketmq \
-p 10912:10912 -p 10911:10911 -p 10909:10909 \
-p 8080:8080 -p 8081:8081 \
-e "NAMESRV_ADDR=rmqnamesrv:9876" \
-v ./broker.conf:/home/rocketmq/rocketmq-5.2.0/conf/broker.conf \
apache/rocketmq:5.2.0 sh mqbroker --enable-proxy \
-c /home/rocketmq/rocketmq-5.2.0/conf/broker.conf
# 验证 Broker 是否启动成功
docker exec -it rmqbroker bash -c "tail -n 10 /home/rocketmq/logs/rocketmqlogs/proxy.log"
我们可以看到 ‘The broker boot success…’, 表示 Broker 已成功启动。
4. rocketmq-console可视化界面
[root@localhost rocketmq]# docker run -d \
> --name rmqdashboard \
> --network rocketmq \
> -p 9999:8080 \
> -e "JAVA_OPTS=-Drocketmq.namesrv.addr=rmqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" \
> styletang/rocketmq-console-ng
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[root@localhost rocketmq]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
apache/rocketmq 5.2.0 07de70081c45 3 months ago 755MB
styletang/rocketmq-console-ng latest 7df83bb6e638 6 years ago 702MB
[root@localhost rocketmq]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
77532423d419 styletang/rocketmq-console-ng "sh -c 'java $JAVA_O…" 27 minutes ago Up 27 minutes 0.0.0.0:9999->8080/tcp, :::9999->8080/tcp rmqdashboard
433943f15252 apache/rocketmq:5.2.0 "./docker-entrypoint…" 49 minutes ago Up 17 minutes 0.0.0.0:8080-8081->8080-8081/tcp, :::8080-8081->8080-8081/tcp, 0.0.0.0:10909->10909/tcp, :::10909->10909/tcp, 0.0.0.0:10911-10912->10911-10912/tcp, :::10911-10912->10911-10912/tcp, 9876/tcp rmqbroker
ae6cf4adad4a apache/rocketmq:5.2.0 "./docker-entrypoint…" 54 minutes ago Up 54 minutes 10909/tcp, 0.0.0.0:9876->9876/tcp, :::9876->9876/tcp, 10911-10912/tcp rmqnamesrv