rockemq linux-集羣搭建

一。修改每臺主機的hosts文件 vi /.etc/hosts

120.77.61.XX nameserv1
120.76.232.XXX nameserv2

120.77.61.XX broker-a
120.76.232.XXX broker-b
120.77.61.XX broker-a-s
120.76.232.XXX broker-b-s

二。配置模板生成

mkdir ../conf/me-2m-2s-async/
sh mqbroker -m >../conf/me-2m-2s-async/broker.p

二。broker配置

拷貝生成的模板內容,打開需要修改的配置文件地址 cd /usr/local/RocketMQ-3.5.8/target/alibaba-rocketmq-broker/alibaba-rocketmq/conf/2m-2s-async


修改該文件夾下配置 vi broker-a.properties


namesrvAddr:爲hosts中配置的nameserv

brokerIP1:爲當前機器ip

brokerName:與host中配置一致

brokerId:0表示爲master,大於0表示爲slave

brokerRole:ASYNC_MASTER爲主,SLAVE爲從


namesrvAddr=nameserv1:9876;nameserv2:9876
brokerIP1=120.77.61.47
brokerName=broker-a
brokerClusterName=DefaultCluster
brokerId=0
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
rejectTransactionMessage=false
fetchNamesrvAddrByAddressServer=false
storePathRootDir=/root/store
storePathCommitLog=/root/store/commitlog
flushIntervalCommitLog=1000
flushCommitLogTimed=false
deleteWhen=04
fileReservedTime=72
maxTransferBytesOnMessageInMemory=262144
maxTransferCountOnMessageInMemory=32
maxTransferBytesOnMessageInDisk=65536
maxTransferCountOnMessageInDisk=8
accessMessageInMemoryMaxRatio=40
messageIndexEnable=true
messageIndexSafe=false
haMasterAddress=
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
cleanFileForciblyEnable=true


三。複製broker-a.properties,broker-a-s.properties,broker-b.properties,broker-b-s.properties 到另外所有主機


注:爲了讓主broker crash時候能正常用,所以一臺服務器放本服務master,而從放在另一臺服務器如

120.77.61.XX 啓動 broker-a 和broker-b-s

120.76.232.XXX 啓動broker-b 和broker-a-s


四。啓動每臺機器nameserv 注:啓動順序namesrv-->broker,關閉順序相反


進入以下目錄:/usr/local/RocketMQ-3.5.8/target/alibaba-rocketmq-broker/alibaba-rocketmq/bin


    啓動nameserv :nohup sh mqnamesrv > /usr/local/RocketMQ-3.5.8/logs/namesrv.log 2>&1 &


日誌輸出以下信息表示成功:The Name Server boot success. serializeType=JSON

五。啓動每臺broker

進入 /usr/local/RocketMQ-3.5.8/target/alibaba-rocketmq-broker/alibaba-rocketmq/bin

nohup sh mqbroker -nlocalhost:9876 autoCreateTopicEnable=true -c /usr/local/RocketMQ-3.5.8/target/alibaba-rocketmq-broker/alibaba-rocketmq/conf/2m-2s-async/broker-a.properties > /usr/local/RocketMQ-3.5.8/logs/broker.log 2>&1 &


發佈了20 篇原創文章 · 獲贊 5 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章