栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

RocketMQ双主双从异步复制部署流程

RocketMQ双主双从异步复制部署流程

文章目录

1、下载2、修改配置文件3、配置环境变量4、启动namesrv5、启动broker6、安装rocketmq-externals

6.1、准备jar包6.2、准备rocketmq-externals6.3、运行rocketmq-externals


这里只用了两台机器,主和备用一台(测试资源有限)

1、下载

下载地址:http://rocketmq.apache.org/dowloading/releases/

拷贝至两台机器,解压下载的安装包

2、修改配置文件

第一台机器修改:

rocketmq-all-4.8.0-bin-release/conf/2m-2s-async目录下的broker-a.properties、broker-b-s.properties

broker-a.properties:

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR ConDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
#集群名
brokerClusterName=Data-Cluster
#broker名字
brokerName=broker-a
#0 表示 Master, >0 表示 Slave
brokerId=0
#nameServer地址,分号分割
namesrvAddr=172.16.10.169:9876;172.16.10.168:9876
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=3
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=true
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true
#Broker 对外服务的监听端口
listenPort=10911
#删除文件时间点,默认凌晨 4点
deleteWhen=04
#文件保留时间,默认 48 小时
#fileReservedTime=3600
#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#文件磁盘最大利用率
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/home/rocketmq/data/store-a
#commitLog 存储路径
storePathCommitLog=/home/rocketmq/data/commitlog-a
#消费队列存储路径存储路径
storePathConsumeQueue=/home/rocketmq/data/consumequeue-a
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
# 开启对 propertyfilter的支持
enablePropertyFilter = true
filterSupportRetry = true

broker-b-s.properties:

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR ConDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#集群名
brokerClusterName=Data-Cluster
#broker名字
brokerName=broker-b
#0 表示 Master, >0 表示 Slave
brokerId=1
#nameServer地址,分号分割
namesrvAddr=172.16.10.169:9876;172.16.10.168:9876
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=3
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=ture
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=ture
#Broker 对外服务的监听端口
listenPort=11911
#删除文件时间点,默认凌晨 4点
deleteWhen=04
#文件保留时间,默认 48 小时
#fileReservedTime=3600
#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#磁盘最大利用率
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/home/rocketmq/data/store-b-s
#commitLog 存储路径
storePathCommitLog=/home/rocketmq/data/commitlog-b-s
#消费队列存储路径存储路径
storePathConsumeQueue=/home/rocketmq/data/consumequeue-b-s
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
# 开启对 propertyfilter的支持
enablePropertyFilter = true
filterSupportRetry = true


第二台机器修改:

rocketmq-all-4.8.0-bin-release/conf/2m-2s-async目录下的broker-b.properties、broker-a-s.properties

broker-b.properties:

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR ConDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#集群名
brokerClusterName=Data-Cluster
#broker名字
brokerName=broker-b
#0 表示 Master, >0 表示 Slave
brokerId=0
#nameServer地址,分号分割
namesrvAddr=172.16.10.169:9876;172.16.10.168:9876
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=3
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=ture
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=ture
#Broker 对外服务的监听端口
listenPort=10911
#删除文件时间点,默认凌晨 4点
deleteWhen=04
#文件保留时间,默认 48 小时
#fileReservedTime=3600
#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#磁盘最大利用率
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/home/rocketmq/data/store-b
#commitLog 存储路径
storePathCommitLog=/home/rocketmq/data/commitlog-b
#消费队列存储路径存储路径
storePathConsumeQueue=/home/rocketmq/data/consumequeue-b
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
# 开启对 propertyfilter的支持
enablePropertyFilter = true
filterSupportRetry = true

broker-a-s.properties:

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR ConDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#集群名
brokerClusterName=Data-Cluster
#broker名字
brokerName=broker-a
#0 表示 Master, >0 表示 Slave
brokerId=1
#nameServer地址,分号分割
namesrvAddr=172.16.10.169:9876;172.16.10.168:9876
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=3
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=true
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true
#Broker 对外服务的监听端口
listenPort=11912
#删除文件时间点,默认凌晨 4点
deleteWhen=04
#文件保留时间,默认 48 小时
#fileReservedTime=3600
#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#文件磁盘最大利用率
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/home/rocketmq/data/store-a-s
#commitLog 存储路径
storePathCommitLog=/home/rocketmq/data/commitlog-a-s
#消费队列存储路径存储路径
storePathConsumeQueue=/home/rocketmq/data/consumequeue-a-s
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
# 开启对 propertyfilter的支持
enablePropertyFilter = true
filterSupportRetry = true
在两台机器上创建/home/rocketmq/data、/home/rocketmq/logs目录
3、配置环境变量

vi ~/.bashrc
添加rocketmq环境变量

export ROCKETMQ_HOME=/home/rocketmq/rocketmq-all-4.8.0-bin-release
export PATH=$PATH:$ROCKETMQ_HOME/bin

source ~/.bashrc

4、启动namesrv

确保安装jdk1.8的环境,并配置PATH与JAVA_HOME
两台机器都执行:
进入bin目录:

nohup sh mqnamesrv > /home/rocketmq/logs/mqnamesrv.log 2>&1 &
5、启动broker

进入bin目录
修改runbroker.sh,找到下面两行JVM参数,可以调大或调小内存

JAVA_OPT=" J A V A O P T − s e r v e r − X m s 2 g − X m x 2 g − X m n 1 g " . . . J A V A O P T = " {JAVA_OPT} -server -Xms2g -Xmx2g -Xmn1g" ... JAVA_OPT=" JAVAO​PT−server−Xms2g−Xmx2g−Xmn1g"...JAVAO​PT="{JAVA_OPT} -XX:MaxDirectMemorySize=2g"

修改runserver.sh,找到下免一行JVM参数,可以调大或调小内存

JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m -XX:metaspaceSize=64m -XX:MaxmetaspaceSize=160m"

第一台机器启动:
broker-a:

nohup sh mqbroker -c /home/rocketmq/rocketmq-all-4.8.0-bin-release/conf/2m-2s-async/broker-a.properties > /home/rocketmq/logs/mqbroker-a.log 2>&1 &
第二台机器启动:
broker-b:

nohup sh mqbroker -c /home/rocketmq/rocketmq-all-4.8.0-bin-release/conf/2m-2s-async/broker-b.properties > /home/rocketmq/logs/mqbroker-b.log 2>&1 &

第二台机器启动:
broker-a-s:

nohup sh mqbroker -c /home/rocketmq/rocketmq-all-4.8.0-bin-release/conf/2m-2s-async/broker-a-s.properties > /home/rocketmq/logs/mqbroker-a-s.log 2>&1 &
第一台机器启动:
broker-b-s:

nohup sh mqbroker -c /home/rocketmq/rocketmq-all-4.8.0-bin-release/conf/2m-2s-async/broker-b-s.properties > /home/rocketmq/logs/mqbroker-b-s.log 2>&1 &

关闭命令

sh mqshutdown namesrv
sh mqshutdown broker
6、安装rocketmq-externals 6.1、准备jar包

安装maven(如果已安装请忽略)
从http://maven.apache.org/download.cgi下载
解压apache-maven-3.8.1-bin.zip
配置环境变量

配置阿里云仓库
在C:Usersadmin.m2settings.xml中添加:


   	……
     
            nexus-aliyun
            central
            Nexus aliyun
            http://maven.aliyun.com/nexus/content/groups/public/
    
	……
  
6.2、准备rocketmq-externals
从[https://github.com/apache/rocketmq-externals](https://github.com/apache/rocketmq-externals)下载源码

解压rocketmq-externals-master.zip
进入目录:rocketmq-externals-masterrocketmq-console
修改配置文件srcmainresourcesapplication.properties(也可以不改,后面直接修改Jar包内的)
将rocketmq.config.namesrvAddr和server.port修改

返回rocketmq-externals-masterrocketmq-console目录
运行:

mvn clean package -Dmaven.test.skip=true

从target中拷贝出rocketmq-console-ng-2.0.0.jar就是打好的jar了

6.3、运行rocketmq-externals

将rocketmq-console-ng-2.0.0.jar拷贝至服务器:
启动命令:
nohup java -jar rocketmq-console-ng-2.0.0.jar > /home/rocketmq/logs/rocketmq-externals.log &
访问172.16.10.168:18080

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/710239.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号