天天看點

ROCKETMQ——2主2從叢集部署

1.壓縮包準備

兩台伺服器鏡像操作

cd /opt

mkdir soft

cd soft

将兩個壓縮包複制到 soft目錄

unzip apache-maven-3.2.2-bin.zip

unzip rocketmq-all-4.2.0-source-release.zip

2.配置環境變量

配置MAVEN的PATH

vim /etc/profile

MAVEN_HOME=/opt/soft/apache-maven-3.2.2

export MAVEN_HOME

export PATH=${PATH}:${MAVEN_HOME}/bin

配置rocketmq的PATH

export ROCKETMQ_HOME=/opt/soft/rocketmq-all-4.2.0/distribution/target/apache-rocketmq

export PATH=$PATH::$ROCKETMQ_HOME/bin

執行變更

source /etc/profile

3.編譯

cd rocketmq-all-4.2.0/

mvn -Prelease-all -DskipTests clean install -U

cd distribution/target/apache-rocketmq

4.啟動

啟動 NameServer

nohup sh bin/mqnamesrv &

tail -f ~/logs/rocketmqlogs/namesrv.log

啟動 Broker

nohup sh bin/mqbroker -n localhost:9876 autoCreateTopicEnable=true &

tail -f ~/logs/rocketmqlogs/broker.log

5.配置host

vim /etc/hosts

添加内容

172.18.0.174 rocketmq1

172.18.0.175 rocketmq2

6.配置主從

建立目錄/root/store/master/和/root/store/master/commitlog

編輯master的配置檔案

vim /opt/soft/rocketmq-all-4.2.0/distribution/target/apache-rocketmq/conf/2m-2s-sync/broker-a.properties 修改為

brokerClusterName=tl-rocketmq-cluster

brokerName=broker-a

brokerIP1=172.18.0.175

brokerId=1

namesrvAddr=rocketmq1:9876;rocketmq2:9876

defaultTopicQueueNums=4

autoCreateTopicEnable=true

autoCreateSubscriptionGroup=true

listenPort=10911

deleteWhen=04

fileReservedTime=120

mapedFileSizeCommitLog=1073741824

mapedFileSizeConsumeQueue=300000

destroyMapedFileIntervalForcibly=120000

redeleteHangedFileInterval=120000

diskMaxUsedSpaceRatio=88

storePathRootDir=/root/store/master/

storePathCommitLog=/root/store/master/commitlog

maxMessageSize=65536

flushCommitLogLeastPages=4

flushConsumeQueueLeastPages=2

flushCommitLogThoroughInterval=10000

flushConsumeQueueThoroughInterval=60000

checkTransactionMessageEnable=false

sendMessageThreadPoolNums=128

pullMessageThreadPoolNums=128

brokerRole=ASYNC_MASTER

flushDiskType=ASYNC_FLUSH

修改slave的配置檔案

vim /opt/soft/rocketmq-all-4.2.0/distribution/target/apache-rocketmq/conf/2m-2s-sync/broker-b-s.properties修改為

brokerClusterName=tl-rocketmq-cluster

brokerName=broker-b

brokerIP1=172.18.0.175

brokerId=1

namesrvAddr=rocketmq1:9876;rocketmq2:9876

defaultTopicQueueNums=4

autoCreateTopicEnable=true

autoCreateSubscriptionGroup=true

listenPort=10921

deleteWhen=04

fileReservedTime=120

mapedFileSizeCommitLog=1073741824

mapedFileSizeConsumeQueue=300000

destroyMapedFileIntervalForcibly=120000

redeleteHangedFileInterval=120000

diskMaxUsedSpaceRatio=88

storePathRootDir=/root/store/slave/

storePathCommitLog=/root/store/slave/commitlog

maxMessageSize=65536

flushCommitLogLeastPages=4

flushConsumeQueueLeastPages=2

flushCommitLogThoroughInterval=10000

flushConsumeQueueThoroughInterval=60000

checkTransactionMessageEnable=false

sendMessageThreadPoolNums=128

pullMessageThreadPoolNums=128

brokerRole=SLAVE

flushDiskType=ASYNC_FLUSH

7.啟動

cd /opt/soft/rocketmq-all-4.2.0/distribution/target/apache-rocketmq/bin

啟動 命名服務

nohup sh mqnamesrv &

啟動 主

nohup sh mqbroker -c /opt/soft/rocketmq-all-4.2.0/distribution/target/apache-rocketmq/conf/2m-2s-sync/broker-a.properties&

啟動 從

nohup sh mqbroker -c /opt/soft/rocketmq-all-4.2.0/distribution/target/apache-rocketmq/conf/2m-2s-sync/broker-b-s.properties&

停止

sh mqshutdown broker

sh mqshutdown namesrv

8.背景控制rocketmq-console的安裝

将rocketmq-console-ng-1.0.0.jar上傳到175

啟動rocketmq-console

nohup java -jar rocketmq-console-ng-1.0.0.jar --server.port=8080 >log.txt &

通路http://172.18.0.175:8080

轉載于:https://www.cnblogs.com/laowang-tester/p/9550020.html