ROCKETMQ——2主2从集群部署

本文详细介绍了RocketMQ的安装与配置过程。包括压缩包准备、环境变量配置、编译、启动等步骤,还涉及host配置、主从配置,以及后台控制rocketmq - console的安装与启动,同时给出了启动和停止命令,适用于Java开发场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值