系统相关
首页 > 系统相关> > CentOS系统中使用docker安装RocketMQ中间件

CentOS系统中使用docker安装RocketMQ中间件

作者:互联网

安装步骤:

 首先:安装nameserver和broker:

(1)拉取镜像(下载rocketMQ镜像):

docker pull rocketmqinc/rocketmq

 过程:

(2)新建本机数据存储文件夹

rm -fR /home/rocketmq/data/;
mkdir -p /home/rocketmq/data/namesrv/{logs,store};
mkdir -p /home/rocketmq/data/broker/{logs,store,conf};

过程:

(3)启动nameserver

docker run -d -p 9876:9876 \
-v /home/rocketmq/data/namesrv/logs:/root/logs \
-v /home/rocketmq/data/namesrv/store:/root/store \
--name rmqnamesrv \
-e "MAX_POSSIBLE_HEAP=256000000" \
rocketmqinc/rocketmq  sh mqnamesrv

过程:

 (4)编辑配置文件:

brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
#修改这个ip为你的物理主机ip
brokerIP1=192.168.232.130

 过程:

修改配置信息中的ip时,输入  ipconfig  命令,看到下图红圈中地址,即为你的物理主机ip

(5)开放防火墙端口:

 先查看端口是否开放:

#查看是否开放端口

firewall-cmd --query-port=9876/tcp
firewall-cmd --query-port=10911/tcp
firewall-cmd --query-port=10909/tcp
firewall-cmd --query-port=8999/tcp

 开启端口:

#开启端口
firewall-cmd --zone=public --add-port=9876/tcp --permanent
firewall-cmd --zone=public --add-port=10911/tcp --permanent
firewall-cmd --zone=public --add-port=10909/tcp --permanent
firewall-cmd --zone=public --add-port=8999/tcp --permanent
firewall-cmd --reload

过程:

(6)启动broker

docker run -d -p 10911:10911 -p 10909:10909 \
-v /home/rocketmq/data/broker/logs:/root/logs \
-v /home/rocketmq/data/broker/store:/root/store \
-v /home/rocketmq/data/broker/conf/broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf \
--name rmqbroker --link rmqnamesrv:namesrv \
-e "NAMESRV_ADDR=namesrv:9876" \
-e "MAX_POSSIBLE_HEAP=256000000" \
rocketmqinc/rocketmq sh mqbroker   -c /opt/rocketmq-4.4.0/conf/broker.conf

过程:

 其次:RocketMQ控制台:

(7)拉取镜像

docker pull styletang/rocketmq-console-ng

过程:

(8)创建container,并启动

docker run -d \
-e "JAVA_OPTS=-Drocketmq.namesrv.addr=172.17.0.2:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" \
-p 8999:8080 -t styletang/rocketmq-console-ng

过程:

(9)可以通过以下命令来查看每个container的IP地址

docker inspect --format='{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)

过程:

 可以清楚看到前面各种安装的镜像的地址

成功按照上面步骤安装后,再次启动时需要注意这两点:

(1)必须先启动namesrv,再启动broker,否则报错

(2)创建控制台的container时,-Drocketmq.namesrv.addr必须指定为namesrv所在container的IP

最后:安装后,在本机浏览器中输入以下地址:http://192.168.232.130:8999    端口号一致,其中的ip地址换成自己的就行(上面步骤中有找的方法)

成功显示控制台页面:

随手记

标签:CentOS,--,cmd,中间件,broker,firewall,namesrv,docker,rocketmq
来源: https://blog.csdn.net/Zongzhe520/article/details/116138409