RocketMQ集群部署

一、集群架构

搭建一个双主双从异步复制的Broker集群,用两台主机来完成集群的搭建。

二、RocketMQ安装

两台服务器均需安装rocketmq,之前已写rocketmq单机部署的文章,此处不再赘述。

2.1、配置/etc/hosts解析

两台服务器均需执行。
cat >>/etc/hosts<<EOF
192.168.0.99 rocketmq01
192.168.0.100 rocketmq02
EOF

2.2、修改rocketmq01配置文件

192.168.0.99服务器操作
cd /web/rocketmq-5.1.0/conf/2m-2s-async
rm -f broker-b.properties broker-a-s.properties
vim broker-a.properties

vim broker-b-s.properties

brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
namesrvAddr=192.168.0.99:9876;192.168.0.100:9876
listenPort=11911
storePathRootDir=~/store-s
storePathCommitLog=~/store-s/commitlog
storePathConsumeQueue=~/store-s/consumequeue
storePathIndex=~/store-s/checkpoint
abortFile=~/store-s/abort

2.3、修改rocketmq02配置文件

192.168.0.100服务器操作
cd /web/rocketmq-5.1.0/conf/2m-2s-async
rm -f broker-a.properties broker-b-s.properties
vim broker-a-s.properties

brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
namesrvAddr=192.168.0.99:9876;192.168.0.100:9876
listenPort=11911
storePathRootDir=~/store-s
storePathCommitLog=~/store-s/commitlog
storePathConsumeQueue=~/store-s/consumequeue
storePathIndex=~/store-s/checkpoint
abortFile=~/store-s/abort

vim broker-b.properties

brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
namesrvAddr=192.168.0.99:9876;192.168.0.100:9876

2.4、启动NameServer集群

分别启动rocketmq01与rocketmq02两台主机中的Name Server,启动命令完全相同。
cd /web/rocketmq-5.1.0/bin
nohup ./mqnamesrv &
查看日志
tailf nohup.out

2.5、启动两个master

192.168.0.99服务器操作
nohup ./mqbroker -c ../conf/2m-2s-async/broker-a.properties &
查看日志
tailf ~/logs/rocketmqlogs/broker.log
192.168.0.100服务器操作
nohup ./mqbroker -c ../conf/2m-2s-async/broker-b.properties &
查看日志
tailf ~/logs/rocketmqlogs/broker.log

2.6、启动两个slave

192.168.0.99服务器操作
nohup ./mqbroker -c ../conf/2m-2s-async/broker-b-s.properties &
查看日志
tailf ~/logs/rocketmqlogs/broker.log

192.168.0.100服务器操作
nohup ./mqbroker -c ../conf/2m-2s-async/broker-a-s.properties &
查看日志
tailf ~/logs/rocketmqlogs/broker.log

jps查看服务状态

至此,RocketMQ集群安装完成。

posted @ 2024-02-28 13:48  霸都运维  阅读(4)  评论(0编辑  收藏  举报