上一集咱們已經學會了SpringBoot整合RocketMQ點我直達,今天咱們來搭建雙主雙從高性能MQ服務集羣。html
Broker角色,Master提供讀寫,Slave只支持讀,Consumer不用配置,當Master不可用或者繁忙的時候,Consumer會自動切換到Slave節點進行讀取。雙主雙從,同步複製,異步刷盤。java
cd /opt/soft/rocketmq-all-4.7.1-source-release
mvn -Prelease-all -DskipTests clean install -U
由於是本地搭建的4臺虛擬機,只分配的1G,不把啓動內存設置小點,服務跑不起來~git
修改,1十、130spring
切換
cd /opt/soft/rocketmq-all-4.7.1-source-release/distribution/target/rocketmq-4.7.1/rocketmq-4.7.1/bin
編輯
vim runserver.sh
修改參數
原始:
JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
修改成:
JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
修改,1十、120、130、140vim
切換
cd /opt/soft/rocketmq-all-4.7.1-source-release/distribution/target/rocketmq-4.7.1/rocketmq-4.7.1/bin
編輯
vim runbroker.sh
修改
原始值:
JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g"
修改成:
JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m"
啓動,110,130架構
切換
cd /opt/soft/rocketmq-all-4.7.1-source-release/distribution/target/rocketmq-4.7.1/rocketmq-4.7.1
守護進程啓動
nohup sh bin/mqnamesrv &
使用:jps,查看是否啓動成功
切換
cd /opt/soft/rocketmq-all-4.7.1-source-release/distribution/target/rocketmq-4.7.1/rocketmq-4.7.1/conf/2m-2s-sync
編輯
vim broker-a.properties
修改成以下配置
namesrvAddr=192.168.199.110:9876;192.168.199.130:9876
brokerClusterName=ybchenCluster
brokerName=broker-a
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH
切換
cd /opt/soft/rocketmq-all-4.7.1-source-release/distribution/target/rocketmq-4.7.1/rocketmq-4.7.1
守護進程啓動
nohup sh bin/mqbroker -c conf/2m-2s-sync/broker-a.properties &
切換
cd /opt/soft/rocketmq-all-4.7.1-source-release/distribution/target/rocketmq-4.7.1/rocketmq-4.7.1/conf/2m-2s-sync
編輯
vim broker-b.properties
修改成以下配置
namesrvAddr=192.168.199.110:9876;192.168.199.130:9876
brokerClusterName=ybchenCluster
brokerName=broker-b
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH
切換
cd /opt/soft/rocketmq-all-4.7.1-source-release/distribution/target/rocketmq-4.7.1/rocketmq-4.7.1
守護進程啓動
nohup sh bin/mqbroker -c conf/2m-2s-sync/broker-b.properties &
切換
cd /opt/soft/rocketmq-all-4.7.1-source-release/distribution/target/rocketmq-4.7.1/rocketmq-4.7.1/conf/2m-2s-sync
編輯
vim broker-a-s.properties
修改成以下配置
namesrvAddr=192.168.199.110:9876;192.168.199.130:9876
brokerClusterName=ybchenCluster
brokerName=broker-a
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
切換
cd /opt/soft/rocketmq-all-4.7.1-source-release/distribution/target/rocketmq-4.7.1/rocketmq-4.7.1
守護進程啓動
nohup sh bin/mqbroker -c conf/2m-2s-sync/broker-a-s.properties &
切換
cd /opt/soft/rocketmq-all-4.7.1-source-release/distribution/target/rocketmq-4.7.1/rocketmq-4.7.1/conf/2m-2s-sync
編輯
vim broker-b-s.properties
修改成以下配置namesrvAddr=192.168.199.110:9876;192.168.199.130:9876
brokerClusterName=ybchenCluster
brokerName=broker-b
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
切換
cd /opt/soft/rocketmq-all-4.7.1-source-release/distribution/target/rocketmq-4.7.1/rocketmq-4.7.1
守護進程啓動
nohup sh bin/mqbroker -c conf/2m-2s-sync/broker-b-s.properties &
作這幾張圖太難了,製做成gif,花了半小時~~如下內容都是連續滴app
在這臺機器上操做,修改配置文件,並啓動異步
切換 cd /opt/soft/rocketmq-externals-master/rocketmq-console/src/main/resources 編輯 vim application.properties 修改成以下配置,指定:rocketmq.config.namesrvAddr ------------------分隔符開始---------------------------------- server.address=0.0.0.0 server.port=8080 ### SSL setting #server.ssl.key-store=classpath:rmqcngkeystore.jks #server.ssl.key-store-password=rocketmq #server.ssl.keyStoreType=PKCS12 #server.ssl.keyAlias=rmqcngkey #spring.application.index=true spring.application.name=rocketmq-console spring.http.encoding.charset=UTF-8 spring.http.encoding.enabled=true spring.http.encoding.force=true logging.level.root=INFO logging.config=classpath:logback.xml #if this value is empty,use env value rocketmq.config.namesrvAddr NAMESRV_ADDR | now, you can set it in ops page.default localhost:9876 rocketmq.config.namesrvAddr=192.168.199.110:9876;192.168.199.130:9876 #if you use rocketmq version < 3.5.8, rocketmq.config.isVIPChannel should be false.default true rocketmq.config.isVIPChannel= #rocketmq-console's data path:dashboard/monitor rocketmq.config.dataPath=/tmp/rocketmq-console/data #set it false if you don't want use dashboard.default true rocketmq.config.enableDashBoardCollect=true #set the message track trace topic if you don't want use the default one rocketmq.config.msgTrackTopicName= rocketmq.config.ticketKey=ticket #Must create userInfo file: ${rocketmq.config.dataPath}/users.properties if the login is required rocketmq.config.loginRequired=false -----------------分隔符結束----------------------------------- 切換 cd /opt/soft/rocketmq-externals-master/rocketmq-console maven構建項目 mvn install -Dmaven.test.skip=true 切換 cd /opt/soft/rocketmq-externals-master/rocketmq-console/target 守護進程啓動 nohup java -jar rocketmq-console-ng-2.0.0.jar &
連接: https://pan.baidu.com/s/1s--VdU-jZvCbS9jHvpHoIA 密碼: eq11