RocketMq集群搭建

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ab7253957/article/details/85045486

地址下载https://www.apache.org/dyn/closer.cgi?path=rocketmq/4.2.0/rocketmq-all-4.2.0-bin-release.zip

        今天使用两台虚拟机搭建rocketmq集群,IP地址为192.168.21.128和192.168.21.129,

遇到一个坑耗费了比较长的时间,防火墙的问题

关闭防火墙systemctl stop firewalld

1.配置环境变量  vim / etc / profile

export ROCKETMQ_HOME = / root / svr / rocketmq

export PATH = $ PATH :: $ ROCKETMQ_HOME / bin

使配置生效源/ etc / profile

2.配置宿主,给域名服务器使用

vim / etc / hosts

192.168.214.128 rocketmq1

192.168.124.129 rocketmq2

3.配置集群参数

vim /root/svr/rocketmq/conf/2m-nosalve/broker-a.properties

brokerClusterName = TL-rocketmq群集

#brokerName不能相同

brokerName =经纪人一个

#0表示Master,> 0表示Slave

brokerId = 0

#此处使用步骤2配置额主机

namesrvAddr = rocketmq1:9876; rocketmq2:9876

defaultTopicQueueNums = 4

autoCreateTopicEnable =真

autoCreateSubscriptionGroup =真

的listenPort = 10911

deleteWhen = 04

fileReservedTime = 120

mapedFileSizeCommitLog = 1073741824

mapedFileSizeConsumeQueue = 300000

destroyMapedFileIntervalForcibly = 120000

redeleteHangedFileInterval = 120000

diskMaxUsedSpaceRatio = 88

storePathRootDir = /根/ SVR / rocketmq /数据/存储

storePathCommitLog = /根/ SVR / rocketmq /数据/存储/ commitlog

maxMessageSize = 65536

flushCommitLogLeastPages = 4

flushConsumeQueueLeastPages = 2

flushCommitLogThoroughInterval = 10000

flushConsumeQueueThoroughInterval = 60000

checkTransactionMessageEnable = FALSE

sendMessageThreadPoolNums = 128

pullMessageThreadPoolNums = 128

#角色SYNC_MASTER / ASYNC_MASTER / SALVE

brokerRole = SYNC_MASTER

flushDiskType = ASYNC_FLUSH

4.创建存储日志文件

mkdir / root / svr / rocketmq / data(也要创建store文件夹)

mkdir / root / svr / rocketmq / data / store / commitlog

mkdir / root / svr / rocketmq / data / store / consumequeue

mkdir / root / svr / rocketmq / data / store / index

5.修改日志配置文件

mkdir -p / root / svr / rocketmq / logs

cd / root / svr / rocketmq / conf && sed -i的#$ {user.home}#/ root / svr / rocketmq #g'

* .XML

注意的logback。*。xml的配置文件中$ {}的user.home需要替换自己指定的目录

6.修改runbroker.sh,runserver.sh堆内存参数

7.启动服务

sh mqnamesrv&

sh mqbroker -c /root/svr/rocketmq/conf/2m-nosalve/broker-a.properties&

8.查看集群状态

sh mqadmin clusterlist -n 192.168.214.128:9876

如果只显示当前机器的集群信息,请关闭防火墙

9.测试集群

export NAMESRV_ADDR = rocketmq1:9876

测试发送端

 > sh bin / tools.sh org.apache.rocketmq.example.quickstart.Producer

测试消费端

 > sh bin / tools.sh org.apache.rocketmq.example.quickstart.Consumer

10.服务停止

在cd / root / svr / rocketmq / bin目录下执行命令或者jps查看进程号kill -9 pid

sh mqshutdown broker

sh mqshutdown namesrv

猜你喜欢

转载自blog.csdn.net/ab7253957/article/details/85045486

相关文章