中间件RocketMQ系列(三)

RocketMQ双主双从集群部署

上一篇中间件RocketMQ系列(一)介绍了单master节点模式的部署,所以本文不再赘述下载上传等步骤

一、环境准备

1.配置文件说明

配置文件目录:/yl/app/rocketmq-5.1.4/conf/

  • 2m-2s-async :双主双从-异步模式的 配置文件(本文选择这种模式)
  • 2m-2s-sync :双主双从 -同步模式 配置文件
  • 2m-noslave:双主,没有从节点模式的 配置文件
cd 2m-2s-async
  • broker-a.properties :主节点a
  • broker-a-s.properties :从节点a
  • broker-b.properties :主节点b
  • broker-b-s.properties:从节点b
2.服务器准备

节点总共所需4个Broker节点,2个NameServer节点,本文使用2台虚拟机不同端口进行模拟

分布如下:

机器A(172.16.82.39)部署Broker-a、Broker-b-s、nameserver-a

机器B(172.16.82.97)部署Broker-b、Broker-a-s、nameserver-b

同一个broker的主从,尽量不要放在同一台服务上,免得当此服务宕机时,主从同时挂掉

3.创建存储路径

机器A(172.16.82.39)、机器B(172.16.82.97)都要创建

mkdir /yl/app/rocketmq-5.1.4/data
4.jdk环境配置参考Linux环境系列(一)
5.配置文件编写

机器A(172.16.82.39):

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
# limitations under the License.
#所属集群名字
brokerClusterName=rocketmq-cluster
#broker名字,注意此处不同的配置文件填写的不一样  例如:在a.properties 文件中写 broker-a  在b.properties 文件中写 broker-b
brokerName=broker-a
#0 表示 Master,>0 表示 Slave
brokerId=0
#删除文件时间点,默认凌晨 4点
deleteWhen=04
#文件保留时间,默认 48 小时
fileReservedTime=120
#Broker 的角色,ASYNC_MASTER=异步复制Master,SYNC_MASTER=同步双写Master,SLAVE=slave节点
brokerRole=ASYNC_MASTER
#刷盘方式,ASYNC_FLUSH=异步刷盘,SYNC_FLUSH=同步刷盘 
flushDiskType=ASYNC_FLUSH
#Broker 对外服务的监听端口
listenPort=10911
#nameServer地址,这里nameserver是单台,如果nameserver是多台集群的话,就用分号分割(即namesrvAddr=ip1:port1;ip2:port2;ip3:port3)
namesrvAddr=172.16.82.39:10900;172.16.82.97:10900
#每个topic对应队列的数量,默认为4,实际应参考consumer实例的数量,值过小不利于consumer负载均>衡
defaultTopicQueueNums=8
#是否允许 Broker 自动创建Topic,生产建议关闭
autoCreateTopicEnable=true
#是否允许 Broker 自动创建订阅组,生产建议关闭
autoCreateSubscriptionGroup=true
#设置BrokerIP
brokerIP1=172.16.82.39
#存储路径
storePathRootDir=/yl/app/rocketmq-5.1.4/data/store-a
#commitLog 存储路径
storePathCommitLog=/yl/app/rocketmq-5.1.4/data/store-a/commitlog
#消费队列存储路径存储路径
storePathConsumerQueue=/yl/app/rocketmq-5.1.4/data/store-a/consumequeue
#消息索引存储路径
storePathIndex=/yl/app/rocketmq-5.1.4/data/store-a/index
#checkpoint 文件存储路径
storeCheckpoint=/yl/app/rocketmq-5.1.4/data/store-a/checkpoint
#abort 文件存储路径
abortFile=/yl/app/rocketmq-5.1.4/data/store-a/abort
#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000

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 Apac
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值