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_FLUSHjava

修改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:8080apache

相關文章
相關標籤/搜索