rocketMq部署

架构图

在这里插入图片描述
消息中间件和RPC最大区别:
Broker Cluster存储

1、环境
192.168.0.31
192.168.0.32
部署模式:2M-2S-SYNC(两主两从同步写)(机器不够用可以不用部署这么多2M-nosalve)
相关安装包存储路径:/root/svr/rocketmq

注意:部署的时候jdk最好用JDK8。
通过本地打包部署的话,要注意了windows和linux系统的转义符不一样,需要对脚本进行更改。
2、部署

2.1下载
Apache:
https://www.apache.org/dyn/closer.cgi?path=rocketmq/4.2.0/rocketmq-all-4.2.0-bin-release.zip
Github:
https://github.com/apache/rocketmq/

2.2解压:
unzip rocketmq-all-4.2.0-bin-release.zip -d /root/svr/rocketmq

2.3配置host(给nameServer用):
命令:vim /etc/hosts

192.168.0.12 rocketmq1
192.168.0.13 rocketmq2

配置环境变量:vim /etc/profile

export ROCKETMQ_HOME=/root/svr/rocketmq
export PATH=$PATH::$ROCKETMQ_HOME/bin

执行:source /etc/profile
2.4配置集群参数(a服务器):
命令(master):vim /root/svr/rocketmq/conf/2m-2s-sync/broker-a.properties

brokerClusterName=tl-rocketmq-cluster
brokerName=broker-a
brokerId=0
namesrvAddr=192.168.0.128:9876;192.168.0.105: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/svr/rocketmq/data/store
storePathCommitLog=/root/svr/rocketmq/data/store/commitlog
maxMessageSize=65536
flushCommitLogLeastPages=4
flushConsumeQueueLeastPages=2
flushCommitLogThoroughInterval=10000
flushConsumeQueueThoroughInterval=60000
checkTransactionMessageEnable=false
sendMessageThreadPoolNums=128
pullMessageThreadPoolNums=128
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH

命令(slave):vim /root/svr/rocketmq/conf/2m-2s-sync/broker-b-s.properties

 brokerClusterName=tl-rocketmq-cluster
brokerName=broker-b
brokerId=1
namesrvAddr=192.168.0.128:9876;192.168.0.105:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
listenPort=10912
deleteWhen=04
fileReservedTime=120
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
destroyMapedFileIntervalForcibly=120000
redeleteHangedFileInterval=120000
diskMaxUsedSpaceRatio=88
storePathRootDir=/root/svr/rocketmq/data/store
storePathCommitLog=/root/svr/rocketmq/data/store/commitlog
maxMessageSize=65536
flushCommitLogLeastPages=4
flushConsumeQueueLeastPages=2
flushCommitLogThoroughInterval=10000
flushConsumeQueueThoroughInterval=60000
checkTransactionMessageEnable=false
sendMessageThreadPoolNums=128
pullMessageThreadPoolNums=128
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSHlushDiskType=ASYNC_FLUSH

2.5配置集群参数(b服务器):
命令(master):vim /root/svr/rocketmq/conf/2m-2s-sync/broker-a.properties

brokerClusterName=tl-rocketmq-cluster
brokerName=broker-b
brokerId=0
namesrvAddr=192.168.0.128:9876;192.168.0.105: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/svr/rocketmq/data/store
storePathCommitLog=/root/svr/rocketmq/data/store/commitlog
maxMessageSize=65536
flushCommitLogLeastPages=4
flushConsumeQueueLeastPages=2
flushCommitLogThoroughInterval=10000
flushConsumeQueueThoroughInterval=60000
checkTransactionMessageEnable=false
sendMessageThreadPoolNums=128
pullMessageThreadPoolNums=128
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH

命令(slave):vim /root/svr/rocketmq/conf/2m-2s-sync/broker-b-s.properties

 brokerClusterName=tl-rocketmq-cluster
brokerName=broker-a
brokerId=1
namesrvAddr=192.168.0.128:9876;192.168.0.105:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
listenPort=10912
deleteWhen=04
fileReservedTime=120
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
destroyMapedFileIntervalForcibly=120000
redeleteHangedFileInterval=120000
diskMaxUsedSpaceRatio=88
storePathRootDir=/root/svr/rocketmq/data/store
storePathCommitLog=/root/svr/rocketmq/data/store/commitlog
maxMessageSize=65536
flushCommitLogLeastPages=4
flushConsumeQueueLeastPages=2
flushCommitLogThoroughInterval=10000
flushConsumeQueueThoroughInterval=60000
checkTransactionMessageEnable=false
sendMessageThreadPoolNums=128
pullMessageThreadPoolNums=128
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH

2.6 创建存储&日志文件

mkdir /root/svr/rocketmq/data -p;
mkdir /root/svr/rocketmq/data/store/commitlog -p;
mkdir /root/svr/rocketmq/data/store/consumequeue  -p;
mkdir /root/svr/rocketmq/data/store/index -p;

2.7修改日志配置文件

mkdir -p /root/svr/rocketmq/logs
cd /root/svr/rocketmq/conf && sed -i 's#${user.home}#/root/svr/rocketmq#g'
*.xml

2.8改参数
runbroker.sh,runserver.sh启动参数默认对jvm的堆内存设置比较大(不改启动不起来),如果是虚拟机非线上环境需要改下参数,大小可以根据自己机器来决定
默认大小
-Xms8g -Xmx8g -Xmn4g
改为:

JAVA_OPT="${JAVA_OPT} -server -Xms128m -Xmx128m -Xmn64m"

3、启动服务
3.1启动Nameserver服务
在cd /root/svr/rocketmq/bin目录下执行命令:

nohup sh mqnamesrv &

3.2启动BrokerServer
在cd /root/svr/rocketmq/bin目录下执行命令:

nohup sh mqbroker -c /root/svr/rocketmq/conf/2m-2s-sync/broker-a.properties &
nohup sh mqbroker -c /usr/local/rocketmq/conf/2m-2s-sync/broker-b-s.properties &

3.3是否启动成功
输入命令jps或者查看rocketmq/logs下日志是否输出正常
在这里插入图片描述
安装成功。
查看集群监控状态:

sh mqadmin clusterlist -n 192.168.0.12:9876
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值