1.准备工作
1.1.防火墙开通端口 9876 10911 9800
firewall-cmd --zone=public --add-port=9876/tcp --permanent
firewall-cmd --zone=public --add-port=10911/tcp --permanent
firewall-cmd --zone=public --add-port=9800/tcp --permanent
firewall-cmd --reload
1.2.创建存储文件夹
mkdir -p /root/rocketmq/data/namesrv/logs /root/rocketmq/data/namesrv/store /root/rocketmq/conf /root/rocketmq/data/broker/logs /root/rocketmq/data/broker/store
1.3.进入到 /root/rocketmq/conf 文件夹下 创建文件 broker.conf
cd /root/rocketmq/conf
touch broker.conf
1.4.编辑 broker.conf 文件
vi broker.conf
1.5.加入以下配置 {}括号内需要换成自己服务器的外网IP
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
brokerIP1 = {本地外网 IP}
6.拉取镜像
docker pull rocketmqinc/rocketmq:4.4.0
docker pull styletang/rocketmq-console-ng
2.创建 Namesrv 容器
2.1运行创建容器命令
docker run -d -p 9876:9876 -v /root/rocketmq/data/namesrv/logs:/root/logs -v /root/rocketmq/data/namesrv/store:/root/store --name rmqnamesrv -e "MAX_POSSIBLE_HEAP=100000000" rocketmqinc/rocketmq:4.4.0 sh mqnamesrv
2.2启动容器
docker start rmqnamesrv
2.3查看容器时候启动
docker ps
可以看到 Namesrv 已经启动了
3.创建 broker 容器
3.1运行创建容器命令
docker run -d -p 10911:10911 -p 10909:10909 -v /root/rocketmq/data/broker/logs:/root/logs -v /root/rocketmq/data/broker/store:/root/store -v /root/rocketmq/conf/broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf --name rmqbroker -e "NAMESRV_ADDR=namesrv:9876" -e "MAX_POSSIBLE_HEAP=200000000" rocketmqinc/rocketmq:4.4.0 sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker.conf
3.2启动容器
docker start rmqbroke
3.3查看容器时候启动
docker ps
3.4.创建 console控制台 容器
运行创建容器命令
docker run -d --name rmqconsole -p 9800:8080 -e "JAVA_OPTS=-Drocketmq.namesrv.addr=namesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -t styletang/rocketmq-console-ng
3.5等下载完毕启动容器
docker start rmqbroker
3.6查看容器时候启动
docker ps
访问 外网IP:9800 进入控制台
进入之后 未弹出报错说明 namesrv 连接成功
点击集群 查看broker是否连接成功