天天看点

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