生產環境高可用centos7 安裝配置RocketMQ-雙主雙從-同步雙寫(2m-2s-sync)


添加hosts信息【四台機器】

vim /etc/hosts 192.168.119.130 rocketmq-nameserver1 192.168.119.130 rocketmq-master1 192.168.119.131 rocketmq-nameserver2 192.168.119.131 rocketmq-master2 192.168.119.132 rocketmq-nameserver3 192.168.119.132 rocketmq-master1-slave 192.168.119.133 rocketmq-nameserver4 192.168.119.133 rocketmq-master2-slave

解壓/usr/local/software 下的 rocketmq-all-4.4.0-bin-release.zip

unzip rocketmq-all-4.4.0-bin-release.zip
mv rocketmq-all-4.4.0-bin-release ../rocketmq

創建存儲路徑【四台機器】

mkdir /usr/local/rocketmq/store mkdir /usr/local/rocketmq/store/commitlog mkdir /usr/local/rocketmq/store/consumequeue mkdir /usr/local/rocketmq/store/index mkdir /usr/local/rocketmq/logs

當然我這里偷懶了,直接放一起執行,用英文逗號隔開

 

mkdir /usr/local/rocketmq/store;mkdir /usr/local/rocketmq/store/commitlog;mkdir /usr/local/rocketmq/store/consumequeue;mkdir /usr/local/rocketmq/store/index;mkdir /usr/local/rocketmq/logs

 

broker-a.properties、broker-b.properties 配置如下:

#所屬集群名字 brokerClusterName=rocketmq-cluster #broker 名字,注意此處不同的配置文件填寫的不一樣 brokerName=broker-a  #brokerName=broker-b #0 表示 Master,>0 表示 Slave brokerId=0 #nameServer 地址,分號分割 namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876;rocketmq-nameserver3:9876;rocketmq-nameserver4:9876 #在發送消息時,自動創建服務器不存在的 topic,默認創建的隊列數 defaultTopicQueueNums=4 #是否允許 Broker 自動創建 Topic,建議線下開啟,線上關閉 autoCreateTopicEnable=false #是否允許 Broker 自動創建訂閱組,建議線下開啟,線上關閉 autoCreateSubscriptionGroup=true #Broker 對外服務的監聽端口 listenPort=10911 #刪除文件時間點,默認凌晨 4 點 deleteWhen=04 #文件保留時間,默認 48 小時 fileReservedTime=120 #commitLog 每個文件的大小默認 1G mapedFileSizeCommitLog=1073741824 #ConsumeQueue 每個文件默認存 30W 條,根據業務情況調整 mapedFileSizeConsumeQueue=300000 #destroyMapedFileIntervalForcibly=120000 #redeleteHangedFileInterval=120000 #檢測物理文件磁盤空間 diskMaxUsedSpaceRatio=88 #存儲路徑 storePathRootDir=/usr/local/rocketmq/store #commitLog 存儲路徑 storePathCommitLog=/usr/local/rocketmq/store/commitlog #消費隊列存儲路徑存儲路徑 storePathConsumeQueue=/usr/local/rocketmq/store/consumequeue #消息索引存儲路徑 storePathIndex=/usr/local/rocketmq/store/index #checkpoint 文件存儲路徑 storeCheckpoint=/usr/local/rocketmq/store/checkpoint #abort 文件存儲路徑 abortFile=/usr/local/rocketmq/store/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 #拉消息線程池數量 #pullMessageThreadPoolNums=128

broker-a-s.properties、broker-b-s.properties 配置如下:

#所屬集群名字 brokerClusterName=rocketmq-cluster #broker 名字,注意此處不同的配置文件填寫的不一樣,與 Master 通過 brokerName 來配對 brokerName=broker-a # brokerName=broker-b #0 表示 Master,>0 表示 Slave brokerId=1 #nameServer 地址,分號分割 namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876;rocketmq-nameserver3:9876;rocketmq-nameserver4:9876 #在發送消息時,自動創建服務器不存在的 topic,默認創建的隊列數 defaultTopicQueueNums=4 #是否允許 Broker 自動創建 Topic,建議線下開啟,線上關閉 autoCreateTopicEnable=true #是否允許 Broker 自動創建訂閱組,建議線下開啟,線上關閉 autoCreateSubscriptionGroup=true #Broker 對外服務的監聽端口 listenPort=10911 #刪除文件時間點,默認凌晨 4 點 deleteWhen=04 #文件保留時間,默認 48 小時 fileReservedTime=120 #commitLog 每個文件的大小默認 1G mapedFileSizeCommitLog=1073741824 #ConsumeQueue 每個文件默認存 30W 條,根據業務情況調整 mapedFileSizeConsumeQueue=300000 #destroyMapedFileIntervalForcibly=120000 #redeleteHangedFileInterval=120000 #檢測物理文件磁盤空間 diskMaxUsedSpaceRatio=88 #存儲路徑 storePathRootDir=/usr/local/rocketmq/store #commitLog 存儲路徑 storePathCommitLog=/usr/local/rocketmq/store/commitlog #消費隊列存儲路徑存儲路徑 storePathConsumeQueue=/usr/local/rocketmq/store/consumequeue #消息索引存儲路徑 storePathIndex=/usr/local/rocketmq/store/index #checkpoint 文件存儲路徑 storeCheckpoint=/usr/local/rocketmq/store/checkpoint #abort 文件存儲路徑 abortFile=/usr/local/rocketmq/store/abort #限制的消息大小 maxMessageSize=65536 #flushCommitLogLeastPages=4 #flushConsumeQueueLeastPages=2 #flushCommitLogThoroughInterval=10000 #flushConsumeQueueThoroughInterval=60000 #Broker 的角色 #- ASYNC_MASTER 異步復制 Master #- SYNC_MASTER 同步雙寫 Master #- SLAVE brokerRole=SLAVE #刷盤方式 #- ASYNC_FLUSH 異步刷盤 #- SYNC_FLUSH 同步刷盤 flushDiskType=ASYNC_FLUSH #checkTransactionMessageEnable=false #發消息線程池數量 #sendMessageThreadPoolNums=128 #拉消息線程池數量 #pullMessageThreadPoolNums=128

將配置好的四個配置文件復制到其他的3台服務器並覆蓋

scp broker-a.properties broker-a-s.properties broker-b.properties broker-b-s.properties 192.168.119.131:/usr/local/rocketmq/conf/2m-2s-sync/

如圖所示

修改bin下面的runserve.sh和runbroker.sh的jvm內存大小。建議1g或2g

分別啟動四台機器的Nameserver

nohup sh bin/mqnamesrv &

分別啟動四台機器的broker

192.168.119.130 rocketmq-nameserver1 192.168.119.131 rocketmq-nameserver2 192.168.119.132 rocketmq-master1-slave 192.168.119.133 rocketmq-master2-slave nohup sh bin/mqbroker -c /usr/local/rocketmq/conf/2m-2s-sync/broker-a.properties >/dev/null 2>&1 & nohup sh bin/mqbroker -c /usr/local/rocketmq/conf/2m-2s-sync/broker-b.properties >/dev/null 2>&1 & nohup sh bin/mqbroker -c /usr/local/rocketmq/conf/2m-2s-sync/broker-a-s.properties >/dev/null 2>&1 & nohup sh bin/mqbroker -c /usr/local/rocketmq/conf/2m-2s-sync/broker-b-s.properties >/dev/null 2>&1 &

至此,環境搭建ok


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM