rocketmq -双master搭建

1.第一步

需要两台虚拟机,然后其次都要安装rocket mq

wget  https://www.apache.org/dyn/closer.cgi?path=rocketmq/4.4.0/rocketmq-all-4.4.0-bin-release.zip

需要在hosts 去配置

120.27.69.221 rocketmq-nameserver1
47.105.129.23 rocketmq-nameserver2

47.105.129.23 lyc01
120.27.69.221 lyc02(需要修改主机名)

2.第二步

解压后我们建立一个虚的引用(不在源文件上修改)

ln -s rocketmq-4.4.0  rocketmq 建立虚应用

同时在rocketmq 目录下 建2个目录 store(根据个人兴趣),logs

然后在store建三个目录 index ,commitlog,consumequeue

3.第三步

我们修改mq下的conf/2m-noslave目录里的boker-a.properties,还有boker-b.properties

terName=rocketmq-cluster
#broker名字,注意此处不同的配置文件填写的不一样,如果是broker-a.properties 这里就写broker-a,broker-b.properties 这里就写broker-b,以此类推
brokerName=broker-a
#0 表示 Master, >0 表示 Slave
brokerId=0
#nameServer地址,分号分割
namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=true
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true
#Broker 对外服务的监听端口
listenPort=10911
#删除文件时间点,默认凌晨 0点
deleteWhen=00
#文件保留时间,默认 48 小时
fileReservedTime=120
#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/usr/local/soft/rocketmq/store
#commitLog 存储路径
storePathCommitLog=/usr/local/soft/rocketmq/store/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/usr/local/soft/rocketmq/store/consumequeue
#消息索引存储路径
storePathIndex=/usr/local/soft/rocketmq/store/index
#checkpoint 文件存储路径
#storeCheckpoint=/usr/local/rocketmq/data/checkpoint
#abort 文件存储路径
#abortFile=/usr/local/rocketmq/data/abort
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=ASYNC_MASTER
#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false
#发消息线程池数量
#sendMessageThreadPoolNums=128

4.第四步(两台机器)

修改runbroker.sh   runserver.sh  修改对应的的-Xms -Xmx -Xmn文件(根据自己内存来设置)

执行这个命名

cd /usr/local/soft/rocketmq/conf && sed -i 's#${user.home}#/usr/local/soft/rocketmq#g' *.xml

5.第五步(两台机器)

启动 runserver.sh 

nohup sh mqnamesrv &

启动runbroker.sh

 nohup sh mqbroker -c/usr/local/soft/rocketmq/conf/2m-noslave/broker-a.properties >/dev/null 2>&1 &

发布了64 篇原创文章 · 获赞 35 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/weixin_42047790/article/details/98061682