ROCKETMQ集群安裝-多Master多Slave模式,異步復(fù)制(2m-2s-async)

簡介

官方簡介:

  • RocketMQ是一款分布式螃壤、隊(duì)列模型的消息中間件抗果,具有以下特點(diǎn):
    1. 能夠保證嚴(yán)格的消息順序
    2. 提供豐富的消息拉取模式
    3. 高效的訂閱者水平擴(kuò)展能力
    4. 實(shí)時(shí)的消息訂閱機(jī)制
    5. 億級(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 &

image.png

這樣就安裝好啦 下面是關(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)有過,那么是不生效的)
 
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末卒茬,一起剝皮案震驚了整個(gè)濱河市船老,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌圃酵,老刑警劉巖柳畔,帶你破解...
    沈念sama閱讀 217,277評(píng)論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異郭赐,居然都是意外死亡薪韩,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,689評(píng)論 3 393
  • 文/潘曉璐 我一進(jìn)店門捌锭,熙熙樓的掌柜王于貴愁眉苦臉地迎上來俘陷,“玉大人,你說我怎么就攤上這事观谦±埽” “怎么了?”我有些...
    開封第一講書人閱讀 163,624評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵豁状,是天一觀的道長捉偏。 經(jīng)常有香客問我,道長泻红,這世上最難降的妖魔是什么夭禽? 我笑而不...
    開封第一講書人閱讀 58,356評(píng)論 1 293
  • 正文 為了忘掉前任,我火速辦了婚禮谊路,結(jié)果婚禮上讹躯,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好蜀撑,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,402評(píng)論 6 392
  • 文/花漫 我一把揭開白布挤巡。 她就那樣靜靜地躺著,像睡著了一般酷麦。 火紅的嫁衣襯著肌膚如雪矿卑。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,292評(píng)論 1 301
  • 那天沃饶,我揣著相機(jī)與錄音母廷,去河邊找鬼。 笑死糊肤,一個(gè)胖子當(dāng)著我的面吹牛琴昆,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播馆揉,決...
    沈念sama閱讀 40,135評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼业舍,長吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了升酣?” 一聲冷哼從身側(cè)響起舷暮,我...
    開封第一講書人閱讀 38,992評(píng)論 0 275
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎噩茄,沒想到半個(gè)月后下面,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,429評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡绩聘,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,636評(píng)論 3 334
  • 正文 我和宋清朗相戀三年沥割,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片凿菩。...
    茶點(diǎn)故事閱讀 39,785評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡机杜,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出衅谷,到底是詐尸還是另有隱情叉庐,我是刑警寧澤,帶...
    沈念sama閱讀 35,492評(píng)論 5 345
  • 正文 年R本政府宣布会喝,位于F島的核電站,受9級(jí)特大地震影響玩郊,放射性物質(zhì)發(fā)生泄漏肢执。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,092評(píng)論 3 328
  • 文/蒙蒙 一译红、第九天 我趴在偏房一處隱蔽的房頂上張望预茄。 院中可真熱鬧,春花似錦、人聲如沸耻陕。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,723評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽诗宣。三九已至膘怕,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間召庞,已是汗流浹背岛心。 一陣腳步聲響...
    開封第一講書人閱讀 32,858評(píng)論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留篮灼,地道東北人忘古。 一個(gè)月前我還...
    沈念sama閱讀 47,891評(píng)論 2 370
  • 正文 我出身青樓,卻偏偏與公主長得像诅诱,于是被迫代替她去往敵國和親髓堪。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,713評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容