溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

RocketMQ4.5.1兩主兩從集群部署

發(fā)布時(shí)間:2020-07-14 09:50:19 來(lái)源:網(wǎng)絡(luò) 閱讀:351 作者:清風(fēng)一明月 欄目:系統(tǒng)運(yùn)維

10.40.58.5
10.40.58.6
下載安裝包
https://rocketmq.apache.org/release_notes/release-notes-4.5.1/

unzip rocketmq-all-4.5.1-bin-release.zip –d /data/
rocketmq是java編寫(xiě),所以要配置jdk 和mvn 環(huán)境之后要用
export JAVA_HOME=/usr/java/jdk1.8.0_131
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export M3_HOME=/usr/local/maven3
export PATH=$JAVA_HOME/bin:$M3_HOME/bin:$PATH

分別在5和6兩臺(tái)服務(wù)器上創(chuàng)建持久化存儲(chǔ)目錄(以下的5,6,代表上面的服務(wù)器)
Msater 目錄設(shè)置
mkdir /data/rocketmq-2m2s/store
mkdir /data/rocketmq-2m2s/store/commitlog
mkdir /data/rocketmq-2m2s/store/consumequeue
mkdir /data/rocketmq-2m2s/store/index

Slave目錄設(shè)置
mkdir /data/rocketmq-2m2s/store-s
mkdir /data/rocketmq-2m2s/store-s/commitlog
mkdir /data/rocketmq-2m2s/store-s/consumequeue
mkdir /data/rocketmq-2m2s/store-s/index

RocketMQ配置文件
5服務(wù)器配置
vi /data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-a.properties
vi /data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-b-s.properties

6 服務(wù)器配置
vi /data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-b.properties
vi /data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-a-s.properties

5 服務(wù)器 broker-a.properties配置文件
cat /data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-a.properties
#所屬集群名字
brokerClusterName=rocketmq-cluster
#broker名字,注意此處不同的配置文件填寫(xiě)的不一樣
brokerName=broker-a
#0 表示 Master,>0 表示 Slave
brokerId=0
#nameServer地址,分號(hào)分割
namesrvAddr=10.40.58.5:9876;10.40.58.6:9876
#在發(fā)送消息時(shí),自動(dòng)創(chuàng)建服務(wù)器不存在的topic,默認(rèn)創(chuàng)建的隊(duì)列數(shù)
defaultTopicQueueNums=4
#是否允許 Broker 自動(dòng)創(chuàng)建Topic,建議線(xiàn)下開(kāi)啟,線(xiàn)上關(guān)閉
autoCreateTopicEnable=false
#是否允許 Broker 自動(dòng)創(chuàng)建訂閱組,建議線(xiàn)下開(kāi)啟,線(xiàn)上關(guān)閉
autoCreateSubscriptionGroup=false
#Broker 對(duì)外服務(wù)的監(jiān)聽(tīng)端口
listenPort=10911
haListenPort=10912
#刪除文件時(shí)間點(diǎn),默認(rèn)凌晨 4點(diǎn)
deleteWhen=04
#文件保留時(shí)間,默認(rèn) 48 小時(shí)
fileReservedTime=18
#commitLog每個(gè)文件的大小默認(rèn)1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每個(gè)文件默認(rèn)存30W條,根據(jù)業(yè)務(wù)情況調(diào)整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#檢測(cè)物理文件磁盤(pán)空間
diskMaxUsedSpaceRatio=88
#存儲(chǔ)路徑
storePathRootDir=/data/rocketmq-2m2s/store
#commitLog 存儲(chǔ)路徑
storePathCommitLog=/data/rocketmq-2m2s/store/commitlog
#消費(fèi)隊(duì)列存儲(chǔ)路徑存儲(chǔ)路徑
storePathConsumeQueue=/data/rocketmq-2m2s/store/consumequeue
#消息索引存儲(chǔ)路徑
storePathIndex=/data/rocketmq-2m2s/store/index
#checkpoint 文件存儲(chǔ)路徑
storeCheckpoint=/data/rocketmq-2m2s/store/checkpoint
#abort 文件存儲(chǔ)路徑
abortFile=/data/rocketmq-2m2s/store/abort
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 異步復(fù)制Master
#- SYNC_MASTER 同步雙寫(xiě)Master
#- SLAVE
brokerRole=SYNC_MASTER
#刷盤(pán)方式
#- ASYNC_FLUSH 異步刷盤(pán)
#- SYNC_FLUSH 同步刷盤(pán)
flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false
#發(fā)消息線(xiàn)程池?cái)?shù)量
sendMessageThreadPoolNums=128
#拉消息線(xiàn)程池?cái)?shù)量
pullMessageThreadPoolNums=128
#打開(kāi)鎖
useReentrantLockWhenPutMessage=true
waitTimeMillsInSendQueue=3000
#強(qiáng)制指定本機(jī)IP,需要根據(jù)每臺(tái)機(jī)器進(jìn)行修改。官方介紹可為空,系統(tǒng)默認(rèn)自動(dòng)識(shí)別,但多網(wǎng)卡時(shí)IP地址可能讀取錯(cuò)誤
brokerIP1=10.40.58.5

6服務(wù)器 broker-a-s.properties配置文件
cat /data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-a-s.properties
#所屬集群名字
brokerClusterName=rocketmq-cluster
#broker名字,注意此處不同的配置文件填寫(xiě)的不一樣
brokerName=broker-a
#0 表示 Master,>0 表示 Slave
brokerId=1
#nameServer地址,分號(hào)分割
namesrvAddr=10.40.58.5:9876;10.40.58.6:9876
#在發(fā)送消息時(shí),自動(dòng)創(chuàng)建服務(wù)器不存在的topic,默認(rèn)創(chuàng)建的隊(duì)列數(shù)
defaultTopicQueueNums=4
#是否允許 Broker 自動(dòng)創(chuàng)建Topic,建議線(xiàn)下開(kāi)啟,線(xiàn)上關(guān)閉
autoCreateTopicEnable=false
#是否允許 Broker 自動(dòng)創(chuàng)建訂閱組,建議線(xiàn)下開(kāi)啟,線(xiàn)上關(guān)閉
autoCreateSubscriptionGroup=false
#Broker 對(duì)外服務(wù)的監(jiān)聽(tīng)端口
listenPort=10923
haListenPort=10924
#刪除文件時(shí)間點(diǎn),默認(rèn)凌晨 4點(diǎn)
deleteWhen=04
#文件保留時(shí)間,默認(rèn) 48 小時(shí)
fileReservedTime=18
#commitLog每個(gè)文件的大小默認(rèn)1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每個(gè)文件默認(rèn)存30W條,根據(jù)業(yè)務(wù)情況調(diào)整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#檢測(cè)物理文件磁盤(pán)空間
diskMaxUsedSpaceRatio=88
#存儲(chǔ)路徑
storePathRootDir=/data/rocketmq-2m2s/store-s
#commitLog 存儲(chǔ)路徑
storePathCommitLog=/data/rocketmq-2m2s/store-s/commitlog
#消費(fèi)隊(duì)列存儲(chǔ)路徑存儲(chǔ)路徑
storePathConsumeQueue=/data/rocketmq-2m2s/store-s/consumequeue
#消息索引存儲(chǔ)路徑
storePathIndex=/data/rocketmq-2m2s/store-s/index
#checkpoint 文件存儲(chǔ)路徑
storeCheckpoint=/data/rocketmq-2m2s/store-s/checkpoint
#abort 文件存儲(chǔ)路徑
abortFile=/data/rocketmq-2m2s/store-s/abort
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushConsumeQueueLeastPages=2#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 異步復(fù)制Master
#- SYNC_MASTER 同步雙寫(xiě)Master
#- SLAVE
brokerRole=SLAVE
#刷盤(pán)方式
#- ASYNC_FLUSH 異步刷盤(pán)
#- SYNC_FLUSH 同步刷盤(pán)
flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false
#發(fā)消息線(xiàn)程池?cái)?shù)量
sendMessageThreadPoolNums=128
#拉消息線(xiàn)程池?cái)?shù)量
pullMessageThreadPoolNums=128
#打開(kāi)鎖
useReentrantLockWhenPutMessage=true
waitTimeMillsInSendQueue=3000
#強(qiáng)制指定本機(jī)IP,需要根據(jù)每臺(tái)機(jī)器進(jìn)行修改。官方介紹可為空,系統(tǒng)默認(rèn)自動(dòng)識(shí)別,但多網(wǎng)卡時(shí)IP地址可能讀取錯(cuò)誤
brokerIP1=10.40.58.6

6服務(wù)器 broker-b.properties配置文件
cat /data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-b.properties
#所屬集群名字
brokerClusterName=rocketmq-cluster
#broker名字,注意此處不同的配置文件填寫(xiě)的不一樣
brokerName=broker-b
#0 表示 Master,>0 表示 Slave
brokerId=0
#nameServer地址,分號(hào)分割
namesrvAddr=10.40.58.6:9876;10.40.58.5:9876
#在發(fā)送消息時(shí),自動(dòng)創(chuàng)建服務(wù)器不存在的topic,默認(rèn)創(chuàng)建的隊(duì)列數(shù)
defaultTopicQueueNums=4
#是否允許 Broker 自動(dòng)創(chuàng)建Topic,建議線(xiàn)下開(kāi)啟,線(xiàn)上關(guān)閉
autoCreateTopicEnable=false
#是否允許 Broker 自動(dòng)創(chuàng)建訂閱組,建議線(xiàn)下開(kāi)啟,線(xiàn)上關(guān)閉
autoCreateSubscriptionGroup=false
#Broker 對(duì)外服務(wù)的監(jiān)聽(tīng)端口
listenPort=10911
haListenPort=10912
#刪除文件時(shí)間點(diǎn),默認(rèn)凌晨 4點(diǎn)
deleteWhen=04
#文件保留時(shí)間,默認(rèn) 48 小時(shí)
fileReservedTime=18
#commitLog每個(gè)文件的大小默認(rèn)1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每個(gè)文件默認(rèn)存30W條,根據(jù)業(yè)務(wù)情況調(diào)整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#檢測(cè)物理文件磁盤(pán)空間
diskMaxUsedSpaceRatio=88
#存儲(chǔ)路徑
storePathRootDir=/data/rocketmq-2m2s/store
#commitLog 存儲(chǔ)路徑
storePathCommitLog=/data/rocketmq-2m2s/store/commitlog
#消費(fèi)隊(duì)列存儲(chǔ)路徑存儲(chǔ)路徑
storePathConsumeQueue=/data/rocketmq-2m2s/store/consumequeue
#消息索引存儲(chǔ)路徑
storePathIndex=/data/rocketmq-2m2s/store/index
#checkpoint 文件存儲(chǔ)路徑
storeCheckpoint=/data/rocketmq-2m2s/store/checkpoint
#abort 文件存儲(chǔ)路徑
abortFile=/data/rocketmq-2m2s/store/abort
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 異步復(fù)制Master
#- SYNC_MASTER 同步雙寫(xiě)Master
#- SLAVE
brokerRole=SYNC_MASTER
#刷盤(pán)方式
#- ASYNC_FLUSH 異步刷盤(pán)
#- SYNC_FLUSH 同步刷盤(pán)
flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false
#發(fā)消息線(xiàn)程池?cái)?shù)量
sendMessageThreadPoolNums=128
#拉消息線(xiàn)程池?cái)?shù)量
pullMessageThreadPoolNums=128
#打開(kāi)鎖
useReentrantLockWhenPutMessage=true
waitTimeMillsInSendQueue=3000
#強(qiáng)制指定本機(jī)IP,需要根據(jù)每臺(tái)機(jī)器進(jìn)行修改。官方介紹可為空,系統(tǒng)默認(rèn)自動(dòng)識(shí)別,但多網(wǎng)卡時(shí)IP地址可能讀取錯(cuò)誤
brokerIP1=10.40.58.6

5服務(wù)器 broker-b-s.properties配置文件
cat /data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-b-s.properties
#所屬集群名字
brokerClusterName=rocketmq-cluster
#broker名字,注意此處不同的配置文件填寫(xiě)的不一樣
brokerName=broker-b
#0 表示 Master,>0 表示 Slave
brokerId=1
#nameServer地址,分號(hào)分割
namesrvAddr=10.40.58.6:9876;10.40.58.5:9876
#在發(fā)送消息時(shí),自動(dòng)創(chuàng)建服務(wù)器不存在的topic,默認(rèn)創(chuàng)建的隊(duì)列數(shù)
defaultTopicQueueNums=4
#是否允許 Broker 自動(dòng)創(chuàng)建Topic,建議線(xiàn)下開(kāi)啟,線(xiàn)上關(guān)閉
autoCreateTopicEnable=false
#是否允許 Broker 自動(dòng)創(chuàng)建訂閱組,建議線(xiàn)下開(kāi)啟,線(xiàn)上關(guān)閉
autoCreateSubscriptionGroup=false
#Broker 對(duì)外服務(wù)的監(jiān)聽(tīng)端口
listenPort=10923
haListenPort=10924
#刪除文件時(shí)間點(diǎn),默認(rèn)凌晨 4點(diǎn)
deleteWhen=04
#文件保留時(shí)間,默認(rèn) 48 小時(shí)
fileReservedTime=18
#commitLog每個(gè)文件的大小默認(rèn)1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每個(gè)文件默認(rèn)存30W條,根據(jù)業(yè)務(wù)情況調(diào)整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#檢測(cè)物理文件磁盤(pán)空間
diskMaxUsedSpaceRatio=88
#存儲(chǔ)路徑
storePathRootDir=/data/rocketmq-2m2s/store-s
#commitLog 存儲(chǔ)路徑
storePathCommitLog=/data/rocketmq-2m2s/store-s/commitlog
#消費(fèi)隊(duì)列存儲(chǔ)路徑存儲(chǔ)路徑
storePathConsumeQueue=/data/rocketmq-2m2s/store-s/consumequeue
#消息索引存儲(chǔ)路徑
storePathIndex=/data/rocketmq-2m2s/store-s/index
#checkpoint 文件存儲(chǔ)路徑
storeCheckpoint=/data/rocketmq-2m2s/store-s/checkpoint
#abort 文件存儲(chǔ)路徑
abortFile=/data/rocketmq-2m2s/store-s/abort
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 異步復(fù)制Master
#- SYNC_MASTER 同步雙寫(xiě)Master
#- SLAVE
brokerRole=SLAVE
#刷盤(pán)方式
#- ASYNC_FLUSH 異步刷盤(pán)
#- SYNC_FLUSH 同步刷盤(pán)
flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false
#發(fā)消息線(xiàn)程池?cái)?shù)量
sendMessageThreadPoolNums=128
#拉消息線(xiàn)程池?cái)?shù)量
pullMessageThreadPoolNums=128
#打開(kāi)鎖
useReentrantLockWhenPutMessage=true
waitTimeMillsInSendQueue=3000
#強(qiáng)制指定本機(jī)IP,需要根據(jù)每臺(tái)機(jī)器進(jìn)行修改。官方介紹可為空,系統(tǒng)默認(rèn)自動(dòng)識(shí)別,但多網(wǎng)卡時(shí)IP地址可能讀取錯(cuò)誤
brokerIP1=10.40.58.5

注意: 上面配置文件中 【#是否允許 Broker 自動(dòng)創(chuàng)建Topic,建議線(xiàn)下開(kāi)啟,線(xiàn)上關(guān)閉autoCreateTopicEnable=false
#是否允許 Broker 自動(dòng)創(chuàng)建訂閱組,建議線(xiàn)下開(kāi)啟,線(xiàn)上關(guān)閉autoCreateSubscriptionGroup=false】 將topic和訂閱組全部關(guān)閉自動(dòng)創(chuàng)建了。 所以在使用Java-API調(diào)用之前,一定要手動(dòng)創(chuàng)建Topic和消費(fèi)者訂閱組,不然消費(fèi)者端無(wú)法獲取到消息。

修改日志配置文件
cd /data/rocketmq-all-4.5.1-bin-release/conf
vi logback_namesrv.xml
vi logback_namesrv.xml
mkdir /data/logs

RocketMQ4.5.1兩主兩從集群部署

修改rocketmq啟動(dòng)腳本
適當(dāng)修改jvm內(nèi)存大小
vi /data/rocketmq-all-4.5.1-bin-release/bin/runbroker.sh
vi /data/rocketmq-all-4.5.1-bin-release/bin/runserver.sh
vi /data/rocketmq-all-4.5.1-bin-release/bin/tools.sh

RocketMQ4.5.1兩主兩從集群部署

啟動(dòng)參數(shù)設(shè)置
RocketMQ啟動(dòng)文件位于/data/rocketmq-all-4.5.1-bin-release/bin/目錄下,Linux中nameserver啟動(dòng)文件為:mqnamesrv,broker啟動(dòng)文件為:mqbroker,mqnamesrv和mqbroker啟動(dòng)文件分別調(diào)用了runserver.sh和runbroker.sh.
文件,這兩個(gè)文件分別設(shè)置了nameserver和broker的啟動(dòng)內(nèi)存,目前內(nèi)存啟動(dòng)參數(shù)分別為nameserver啟動(dòng)內(nèi)存4G,最大內(nèi)存4G,新生代2G,broker啟動(dòng)內(nèi)存8G,最大內(nèi)存8G,新生代4G。(根據(jù)自己的需要修改)

啟動(dòng)Nameserver
分別啟動(dòng)5、6的Nameserver
cd /data/rocketmq-all-4.5.1-bin-release/bin/
nohup sh mqnamesrv &

啟動(dòng)Broker: cd /data/rocketmq-all-4.5.1-bin-release/bin/
5上Master啟動(dòng):
nohup sh mqbroker -c /data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-a.properties &
6上Master啟動(dòng):
nohup sh mqbroker -c /data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-b.properties &
5上Slave啟動(dòng):
nohup sh mqbroker -c /data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-b-s.properties &
6上Slave啟動(dòng):
nohup sh mqbroker -c /data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-a-s.properties &

RocketMQ4.5.1兩主兩從集群部署

至此,Nameserver、Broker啟動(dòng)完成,可以用jobs命令查看當(dāng)前運(yùn)行進(jìn)程,如下是服務(wù)端相關(guān)shutdown,即在bin目錄下:
sh mqshutdown namesrv
sh mqshutdown broke

RocketMQ監(jiān)控平臺(tái)部署

下載:
Git地址:https://github.com/apache/rocketmq-externals/tree/release-rocketmq-console-1.0.0
或者h(yuǎn)ttps://pan.baidu.com/s/1Y4fzVc2r30jtIVpvYZocWA 密碼: vj2y
unzip rocketmq-externals-release-rocketmq-console-1.0.0.zip
cd rocketmq-externals-release-rocketmq-console-1.0.0/rocketmq-console/src/main/resources/
vi application.properties
RocketMQ4.5.1兩主兩從集群部署

編譯源代碼(需要maven環(huán)境)
cd /root/rocketmq-externals-release-rocketmq-console-1.0.0/rocketmq-console/
mvn clean package -Dmaven.test.skip=true (如果有卡住的自己可以下載相應(yīng)的jar放到這個(gè)目錄里面就好了再繼續(xù)編譯)

啟動(dòng)服務(wù)
cd /root/rocketmq-externals-release-rocketmq-console-1.0.0/rocketmq-console/target
java -jar rocketmq-console-ng-1.0.0.jar &

訪(fǎng)問(wèn)管理界面
瀏覽器輸入: 10.40.58.5:8080/回車(chē)顯示監(jiān)控界面
RocketMQ4.5.1兩主兩從集群部署

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI