簡介
官方簡介:
- RocketMQ是一款分布式螃壤、隊(duì)列模型的消息中間件抗果,具有以下特點(diǎn):
- 能夠保證嚴(yán)格的消息順序
- 提供豐富的消息拉取模式
- 高效的訂閱者水平擴(kuò)展能力
- 實(shí)時(shí)的消息訂閱機(jī)制
- 億級(jí)消息堆積能力
1.還是先理解一些重要概念及說明
- Disk Flush(磁盤刷新/同步操作):就是將內(nèi)存的數(shù)據(jù)落地,存儲(chǔ)在磁盤中奸晴。RocketMQ提供了以下兩種模式:
- SYNC_FLUSH(同步刷盤):生產(chǎn)者發(fā)送的每一條消息都在保存到磁盤成功后才返回告訴生產(chǎn)者成功冤馏。這種方式不會(huì)存在消息丟失的問
題,但是有很大的磁盤IO開銷寄啼,性能有一定影響逮光。- ASYNC_FLUSH(異步刷盤):生產(chǎn)者發(fā)送的每一條消息并不是立即保存到磁盤代箭,而是暫時(shí)緩存起來,然后就返回生產(chǎn)者成功涕刚。隨后再異步>的將緩存數(shù)據(jù)保存到磁盤嗡综,有兩種情況:1是定期將緩存中更新的數(shù)據(jù)進(jìn)行刷盤,2是當(dāng)緩存中更新的數(shù)據(jù)條數(shù)達(dá)到某一設(shè)定值后進(jìn)行刷盤杜漠。這種>方式會(huì)存在消息丟失(在還未來得及同步到磁盤的時(shí)候宕機(jī))极景,但是性能很好。默認(rèn)是這種模式驾茴。
- Broker Replication(Broker間數(shù)據(jù)同步/復(fù)制):集群環(huán)境下需要部署多個(gè)Broker盼樟,Broker分為兩種角色:一種是master,即可以寫也可以>
讀锈至,其brokerId=0晨缴,只能有一個(gè);另外一種是slave裹赴,只允許讀喜庞,其brokerId為非0。一個(gè)master與多個(gè)slave通過指定相同的brokerName被歸為一>個(gè)broker set(broker集)棋返。通常生產(chǎn)環(huán)境中,我們至少需要2個(gè)broker set雷猪。Broker Replication只的就是slave獲取或者是復(fù)制master的數(shù)據(jù)。
- Sync Broker:生產(chǎn)者發(fā)送的每一條消息都至少同步復(fù)制到一個(gè)slave后才返回告訴生產(chǎn)者成功,即“同步雙寫”拉庵。
- Async Broker:生產(chǎn)者發(fā)送的每一條消息只要寫入master就返回告訴生產(chǎn)者成功辉巡。然后再“異步復(fù)制”到slave。
- 推薦的幾種Broker集群方式:(官網(wǎng)提供了下面幾種集群方式的配置文件供參考与境,在$ROCKETMQ_HOME/target/apache-rocketmq-all/conf目>錄下)
- 2m-2s-sync:兩主兩從同步雙寫(兩個(gè)master验夯,兩個(gè)slave,數(shù)據(jù)同步雙寫到master和slave)
- 2m-2s-async:兩主兩從異步復(fù)制(兩個(gè)master摔刁,兩個(gè)slave挥转,master數(shù)據(jù)通過異步復(fù)制到slave)
- 2m-noslave:兩主(只有兩個(gè)master,沒有slave)
注意:
1共屈、上述“2”只是說作為一個(gè)集群的最低配置數(shù)量绑谣,可以根據(jù)實(shí)際情況擴(kuò)展。
2拗引、所有的刷盤(Dish Flush)操作全部默認(rèn)為:ASYNC_FLUSH(異步刷盤)借宵。- Name Server集群:Name Server集群比較簡單,只要部署多個(gè)實(shí)例就行了矾削,多個(gè)實(shí)例間不需要進(jìn)行數(shù)據(jù)共享壤玫,只要保證一個(gè)實(shí)例存活就可>以正常運(yùn)轉(zhuǎn)豁护。
2、三種Broker集群方式優(yōu)缺點(diǎn)
上面三種集群方式的優(yōu)缺點(diǎn)(主要區(qū)別在于主從復(fù)制方式):
多Master模式(2m-noslave)
一個(gè)集群無Slave欲间,全是Master择镇,例如2個(gè)Master或者3個(gè)Master
優(yōu)點(diǎn):配置簡單,單個(gè)Master宕機(jī)或重啟維護(hù)對(duì)應(yīng)用無影響括改,在磁盤配置為RAID10時(shí)腻豌,即使機(jī)器宕機(jī)不可恢復(fù)情況下,由于RAID10磁盤非持瞿埽可靠吝梅,消息也不會(huì)丟(異步刷盤丟失少量消息,同步刷盤一條不丟)惹骂。性能最高苏携。
缺點(diǎn):單臺(tái)機(jī)器宕機(jī)期間,這臺(tái)機(jī)器上未被消費(fèi)的消息在機(jī)器恢復(fù)之前不可訂閱对粪,消息實(shí)時(shí)性會(huì)受到受到影響右冻。多Master多Slave模式,異步復(fù)制(2m-2s-async)
每個(gè)Master配置一個(gè)Slave著拭,有多對(duì)Master-Slave纱扭,HA采用異步復(fù)制方式,主備有短暫消息延遲儡遮,毫秒級(jí)乳蛾。
優(yōu)點(diǎn):即使磁盤損壞,消息丟失的非常少鄙币,且消息實(shí)時(shí)性不會(huì)受影響肃叶,因?yàn)镸aster宕機(jī)后,消費(fèi)者仍然可以從Slave消費(fèi)十嘿,此過程對(duì)應(yīng)用透明因惭。不需要人工干預(yù)。性能同多Master模式幾乎一樣绩衷。
缺點(diǎn):Master宕機(jī)蹦魔,磁盤損壞情況,會(huì)丟失少量消息唇聘。多Master多Slave模式版姑,同步雙寫(2m-noslave)
每個(gè)Master配置一個(gè)Slave,有多對(duì)Master-Slave迟郎,HA采用同步雙寫方式剥险,主備都寫成功,向應(yīng)用返回成功宪肖。
優(yōu)點(diǎn):數(shù)據(jù)與服務(wù)都無單點(diǎn)表制,Master宕機(jī)情況下健爬,消息無延遲,服務(wù)可用性與數(shù)據(jù)可用性都非常高
缺點(diǎn):性能比異步復(fù)制模式略低么介,大約低10%左右娜遵,發(fā)送單個(gè)消息的RT會(huì)略高。目前主宕機(jī)后壤短,備機(jī)不能自動(dòng)切換為主機(jī)设拟,后續(xù)會(huì)支持自動(dòng)切換功能。
3久脯、安裝集群 (broker-a)(ip :99.48.66.80)
- 為了避免亂七八糟的錯(cuò)誤建議先關(guān)閉防火墻
- 目錄 /usr/local/src
1.這是一個(gè)master的配置
cd /usr/local/src
unzip rocketmq-all-4.2.0-bin-release.zip -d rocketmq-all-4.2.0-bin-release
#創(chuàng)建文件夾
mkdir /usr/local/src/rocketmq-all-4.2.0-bin-release/store
mkdir /usr/local/src/rocketmq-all-4.2.0-bin-release/store/commitlog
mkdir /usr/local/src/rocketmq-all-4.2.0-bin-release/store/consumequeue
mkdir /usr/local/src/rocketmq-all-4.2.0-bin-release/store/index
vi /usr/local/src/rocketmq-all-4.2.0-bin-release/conf/2m-2s-async/broker-a.properties
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
brokerClusterName=DefaultCluster
#broker名字纳胧,注意此處不同的配置文件填寫的不一樣
brokerName=broker-a
#0 表示 Master,>0 表示 Slave
waitTimeMillsInSendQueue=300
brokerId=0
#nameServer地址帘撰,分號(hào)分割
namesrvAddr=99.48.66.80:9876;99.48.66.82:9876
#是否允許 Broker 自動(dòng)創(chuàng)建Topic跑慕,建議線下開啟,線上關(guān)閉
autoCreateTopicEnable=true
#是否允許 Broker 自動(dòng)創(chuàng)建訂閱組摧找,建議線下開啟核行,線上關(guān)閉
autoCreateSubscriptionGroup=false
#Broker 對(duì)外服務(wù)的監(jiān)聽端口
listenPort=11911
#刪除文件時(shí)間點(diǎn),默認(rèn)凌晨 4點(diǎn)
deleteWhen=04
#文件保留時(shí)間蹬耘,默認(rèn) 48 小時(shí)
fileReservedTime=48
#commitLog每個(gè)文件的大小默認(rèn)1G
#mapedFileSizeCommitLog=1073741824
#ConsumeQueue每個(gè)文件默認(rèn)存30W條芝雪,根據(jù)業(yè)務(wù)情況調(diào)整
#mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#檢測(cè)物理文件磁盤空間
diskMaxUsedSpaceRatio=80
#存儲(chǔ)路徑
storePathRootDir=/usr/local/src/rocketmq-all-4.2.0-bin-release/store
#commitLog 存儲(chǔ)路徑
storePathCommitLog=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/commitlog
#消費(fèi)隊(duì)列存儲(chǔ)路徑存儲(chǔ)路徑
storePathConsumeQueue=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/consumequeue
#消息索引存儲(chǔ)路徑
storePathIndex=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/index
#checkpoint 文件存儲(chǔ)路徑
storeCheckpoint=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/checkpoint
#abort 文件存儲(chǔ)路徑
abortFile=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/abort
#限制的消息大小 默認(rèn)4M
#maxMessageSize=4194304
#Broker 的角色
#- ASYNC_MASTER 異步復(fù)制Master
#- SYNC_MASTER 同步雙寫Master
#- SLAVE
brokerRole=ASYNC_MASTER
#刷盤方式
#- ASYNC_FLUSH 異步刷盤
#- SYNC_FLUSH 同步刷盤
flushDiskType=ASYNC_FLUSH
sendMessageThreadPoolNums=128
useReentrantLockWhenPutMessage=true
********************這里是公共可選配置 (maste ,slave)********************************
crunserver.sh 配置( /usr/local/src/rocketmq-all-4.2.0-bin-release/bin) 此處根據(jù)自己的硬件配置來調(diào)整
-server -Xms512m -Xmx512m -Xmn256m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=160m
runbroker.sh( /usr/local/src/rocketmq-all-4.2.0-bin-release/bin) 此處根據(jù)自己的硬件配置來調(diào)整
-server -Xms512m -Xmx512m -Xmn256m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=160m
**********************這里是公共配置 (maste ,slave)********************************
啟動(dòng)命令如下:
#啟動(dòng)master:
nohup sh /usr/local/src/rocketmq-all-4.2.0-bin-release/bin/mqbroker -c /usr/local/src/rocketmq-all-4.2.0-bin-release/conf/2m-2s-async/broker-a.properties >/dev/null 2>&1 &
1.這是一個(gè)slave的配置
cd /usr/local/src
unzip rocketmq-all-4.2.0-bin-release.zip -d rocketmq-all-4.2.0-bin-release
#創(chuàng)建文件夾
mkdir /usr/local/src/rocketmq-all-4.2.0-bin-release/store
mkdir /usr/local/src/rocketmq-all-4.2.0-bin-release/store/commitlog
mkdir /usr/local/src/rocketmq-all-4.2.0-bin-release/store/consumequeue
mkdir /usr/local/src/rocketmq-all-4.2.0-bin-release/store/index
vi /usr/local/src/rocketmq-all-4.2.0-bin-release/conf/2m-2s-async/broker-a-s.properties
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
brokerClusterName=DefaultCluster
#broker名字,注意此處不同的配置文件填寫的不一樣
brokerName=broker-a
#0 表示 Master婆赠,>0 表示 Slave
waitTimeMillsInSendQueue=300
brokerId=1
#nameServer地址绵脯,分號(hào)分割
namesrvAddr=99.48.66.80:9876;99.48.66.82:9876
#是否允許 Broker 自動(dòng)創(chuàng)建Topic,建議線下開啟休里,線上關(guān)閉
autoCreateTopicEnable=true
#是否允許 Broker 自動(dòng)創(chuàng)建訂閱組,建議線下開啟赃承,線上關(guān)閉
autoCreateSubscriptionGroup=false
#Broker 對(duì)外服務(wù)的監(jiān)聽端口
listenPort=11911
#刪除文件時(shí)間點(diǎn)妙黍,默認(rèn)凌晨 4點(diǎn)
deleteWhen=04
#文件保留時(shí)間,默認(rèn) 48 小時(shí)
fileReservedTime=48
#commitLog每個(gè)文件的大小默認(rèn)1G
#mapedFileSizeCommitLog=1073741824
#ConsumeQueue每個(gè)文件默認(rèn)存30W條瞧剖,根據(jù)業(yè)務(wù)情況調(diào)整
#mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#檢測(cè)物理文件磁盤空間
diskMaxUsedSpaceRatio=80
#存儲(chǔ)路徑
storePathRootDir=/usr/local/src/rocketmq-all-4.2.0-bin-release/store
#commitLog 存儲(chǔ)路徑
storePathCommitLog=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/commitlog
#消費(fèi)隊(duì)列存儲(chǔ)路徑存儲(chǔ)路徑
storePathConsumeQueue=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/consumequeue
#消息索引存儲(chǔ)路徑
storePathIndex=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/index
#checkpoint 文件存儲(chǔ)路徑
storeCheckpoint=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/checkpoint
#abort 文件存儲(chǔ)路徑
abortFile=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/abort
#限制的消息大小 默認(rèn)4M
#maxMessageSize=4194304
#Broker 的角色
#- ASYNC_MASTER 異步復(fù)制Master
#- SYNC_MASTER 同步雙寫Master
#- SLAVE
brokerRole=SLAVE
#刷盤方式
#- ASYNC_FLUSH 異步刷盤
#- SYNC_FLUSH 同步刷盤
flushDiskType=ASYNC_FLUSH
sendMessageThreadPoolNums=128
useReentrantLockWhenPutMessage=true
#啟動(dòng)name server:
nohup sh /usr/local/src/rocketmq-all-4.2.0-bin-release/bin/mqnamesrv &
#啟動(dòng)slave:
nohup sh /usr/local/src/rocketmq-all-4.2.0-bin-release/bin/mqbroker -c /usr/local/src/rocketmq-all-4.2.0-bin-release/conf/2m-2s-async/broker-a-s.properties >/dev/null 2>&1 &
4拭嫁、安裝集群 (broker-b)(ip :99.48.66.82)
- 為了避免亂七八糟的錯(cuò)誤建議先關(guān)閉防火墻
- 目錄 /usr/local/src
1.這是一個(gè)master的配置
cd /usr/local/src
unzip rocketmq-all-4.2.0-bin-release.zip -d rocketmq-all-4.2.0-bin-release
#創(chuàng)建文件夾
mkdir /usr/local/src/rocketmq-all-4.2.0-bin-release/store
mkdir /usr/local/src/rocketmq-all-4.2.0-bin-release/store/commitlog
mkdir /usr/local/src/rocketmq-all-4.2.0-bin-release/store/consumequeue
mkdir /usr/local/src/rocketmq-all-4.2.0-bin-release/store/index
vi /usr/local/src/rocketmq-all-4.2.0-bin-release/conf/2m-2s-async/broker-b.properties
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
brokerClusterName=DefaultCluster
#broker名字,注意此處不同的配置文件填寫的不一樣
brokerName=broker-b
#0 表示 Master抓于,>0 表示 Slave
waitTimeMillsInSendQueue=300
brokerId=0
#nameServer地址做粤,分號(hào)分割
namesrvAddr=99.48.66.80:9876;99.48.66.82:9876
#是否允許 Broker 自動(dòng)創(chuàng)建Topic,建議線下開啟捉撮,線上關(guān)閉
autoCreateTopicEnable=true
#是否允許 Broker 自動(dòng)創(chuàng)建訂閱組怕品,建議線下開啟,線上關(guān)閉
autoCreateSubscriptionGroup=false
#Broker 對(duì)外服務(wù)的監(jiān)聽端口
listenPort=11911
#刪除文件時(shí)間點(diǎn)巾遭,默認(rèn)凌晨 4點(diǎn)
deleteWhen=04
#文件保留時(shí)間肉康,默認(rèn) 48 小時(shí)
fileReservedTime=48
#commitLog每個(gè)文件的大小默認(rèn)1G
#mapedFileSizeCommitLog=1073741824
#ConsumeQueue每個(gè)文件默認(rèn)存30W條闯估,根據(jù)業(yè)務(wù)情況調(diào)整
#mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#檢測(cè)物理文件磁盤空間
diskMaxUsedSpaceRatio=80
#存儲(chǔ)路徑
storePathRootDir=/usr/local/src/rocketmq-all-4.2.0-bin-release/store
#commitLog 存儲(chǔ)路徑
storePathCommitLog=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/commitlog
#消費(fèi)隊(duì)列存儲(chǔ)路徑存儲(chǔ)路徑
storePathConsumeQueue=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/consumequeue
#消息索引存儲(chǔ)路徑
storePathIndex=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/index
#checkpoint 文件存儲(chǔ)路徑
storeCheckpoint=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/checkpoint
#abort 文件存儲(chǔ)路徑
abortFile=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/abort
#限制的消息大小 默認(rèn)4M
#maxMessageSize=4194304
#Broker 的角色
#- ASYNC_MASTER 異步復(fù)制Master
#- SYNC_MASTER 同步雙寫Master
#- SLAVE
brokerRole=ASYNC_MASTER
#刷盤方式
#- ASYNC_FLUSH 異步刷盤
#- SYNC_FLUSH 同步刷盤
flushDiskType=ASYNC_FLUSH
sendMessageThreadPoolNums=128
useReentrantLockWhenPutMessage=true
#啟動(dòng)master:
nohup sh /usr/local/src/rocketmq-all-4.2.0-bin-release/bin/mqbroker -c /usr/local/src/rocketmq-all-4.2.0-bin-release/conf/2m-2s-async/broker-b.properties >/dev/null 2>&1 &
1.這是一個(gè)slave的配置
cd /usr/local/src
unzip rocketmq-all-4.2.0-bin-release.zip -d rocketmq-all-4.2.0-bin-release
#創(chuàng)建文件夾
mkdir /usr/local/src/rocketmq-all-4.2.0-bin-release/store
mkdir /usr/local/src/rocketmq-all-4.2.0-bin-release/store/commitlog
mkdir /usr/local/src/rocketmq-all-4.2.0-bin-release/store/consumequeue
mkdir /usr/local/src/rocketmq-all-4.2.0-bin-release/store/index
vi /usr/local/src/rocketmq-all-4.2.0-bin-release/conf/2m-2s-async/broker-b-s.properties
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
brokerClusterName=DefaultCluster
#broker名字,注意此處不同的配置文件填寫的不一樣
brokerName=broker-b
#0 表示 Master吼和,>0 表示 Slave
waitTimeMillsInSendQueue=300
brokerId=1
#nameServer地址涨薪,分號(hào)分割
namesrvAddr=99.48.66.80:9876;99.48.66.82:9876
#是否允許 Broker 自動(dòng)創(chuàng)建Topic,建議線下開啟炫乓,線上關(guān)閉
autoCreateTopicEnable=true
#是否允許 Broker 自動(dòng)創(chuàng)建訂閱組刚夺,建議線下開啟,線上關(guān)閉
autoCreateSubscriptionGroup=false
#Broker 對(duì)外服務(wù)的監(jiān)聽端口
listenPort=11911
#刪除文件時(shí)間點(diǎn)末捣,默認(rèn)凌晨 4點(diǎn)
deleteWhen=04
#文件保留時(shí)間侠姑,默認(rèn) 48 小時(shí)
fileReservedTime=48
#commitLog每個(gè)文件的大小默認(rèn)1G
#mapedFileSizeCommitLog=1073741824
#ConsumeQueue每個(gè)文件默認(rèn)存30W條,根據(jù)業(yè)務(wù)情況調(diào)整
#mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#檢測(cè)物理文件磁盤空間
diskMaxUsedSpaceRatio=80
#存儲(chǔ)路徑
storePathRootDir=/usr/local/src/rocketmq-all-4.2.0-bin-release/store
#commitLog 存儲(chǔ)路徑
storePathCommitLog=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/commitlog
#消費(fèi)隊(duì)列存儲(chǔ)路徑存儲(chǔ)路徑
storePathConsumeQueue=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/consumequeue
#消息索引存儲(chǔ)路徑
storePathIndex=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/index
#checkpoint 文件存儲(chǔ)路徑
storeCheckpoint=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/checkpoint
#abort 文件存儲(chǔ)路徑
abortFile=/usr/local/src/rocketmq-all-4.2.0-bin-release/store/abort
#限制的消息大小 默認(rèn)4M
#maxMessageSize=4194304
#Broker 的角色
#- ASYNC_MASTER 異步復(fù)制Master
#- SYNC_MASTER 同步雙寫Master
#- SLAVE
brokerRole=SLAVE
#刷盤方式
#- ASYNC_FLUSH 異步刷盤
#- SYNC_FLUSH 同步刷盤
flushDiskType=ASYNC_FLUSH
sendMessageThreadPoolNums=128
useReentrantLockWhenPutMessage=true
#啟動(dòng)name server:
nohup sh /usr/local/src/rocketmq-all-4.2.0-bin-release/bin/mqnamesrv &
#啟動(dòng)slave:
nohup sh /usr/local/src/rocketmq-all-4.2.0-bin-release/bin/mqbroker -c /usr/local/src/rocketmq-all-4.2.0-bin-release/conf/2m-2s-async/broker-b-s.properties >/dev/null 2>&1 &
這樣就安裝好啦 下面是關(guān)閉服務(wù)的命令
#關(guān)閉服務(wù) namesrv 和broker
sh /usr/local/src/rocketmq-all-4.2.0-bin-release/bin/mqshutdown broker
sh /usr/local/src/rocketmq-all-4.2.0-bin-release/bin/mqshutdown namesrv
測(cè)試是否成功 最后關(guān)閉防火墻 開通 9876,11911,11912,11909端口
*******特別注意以下幾段英文說明*****************
Consumer Group and Subscriptions
The first thing you should be aware of is that different Consumer Group can consume the same topic independently, and each of them will have their own consuming offsets.
Please make sure each Consumer within the same Group to subscribe the same topics.
MessageListener
Orderly
The Consumer will lock each MessageQueue to make sure it is consumed one by one in order. This will cause a performance loss,
but it is useful when you care about the order of the messages. It is not recommended to throw exceptions, you can return ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT instead.
Concurrently
As the name tells, the Consumer will consume the messages concurrently. It is recommended to use this for good performance.
It is not recommended to throw exceptions, you can return ConsumeConcurrentlyStatus.RECONSUME_LATER instead.
Consume Status
For MessageListenerConcurrently, you can return RECONSUME_LATER to tell the consumer that you can not consume it right now and want to reconsume it later.
Then you can continue to consume other messages. For MessageListenerOrderly, because you care about the order, you can not jump over the message,
but you can return SUSPEND_CURRENT_QUEUE_A_MOMENT to tell the consumer to wait for a moment.
ConsumeFromWhere
When a new Consumer Group is established, it will need to decide whether it needs to consume the historical messages which had already existed in the Broker.
CONSUME_FROM_LAST_OFFSET will ignore the historical messages, and consume anything produced after that.
CONSUME_FROM_FIRST_OFFSET will consume every message existed in the Broker. You can also use CONSUME_FROM_TIMESTAMP to consume messages produced after the specified timestamp.
(注意塔粒,這個(gè)CONSUME_FROM_LAST_OFFSET 是對(duì)一個(gè)新的Consumer Group 生效结借,如果這個(gè)Consumer Group 原來就已經(jīng)有過,那么是不生效的)