首页 > 其他分享 >单机下RocketMq安装-多Master模式

单机下RocketMq安装-多Master模式

时间:2023-06-11 18:25:45浏览次数:52  
标签:bin 5.1 单机 broker Master RocketMq local rocketmq usr

在指定目录下新建文件夹rocketmq,并下载安装包到目录下

cd /usr/local
mkdir rocketmq
wget https://dist.apache.org/repos/dist/release/rocketmq/5.1.1/rocketmq-all-5.1.1-bin-release.zip

安装unzip,并解压压缩包

yum install -y unzip zip
unzip rocketmq-all-5.1.1-bin-release.zip

 创建存储相关路径

cd /usr/local/rocketmq/rocketmq-all-5.1.1-bin-release
mkdir -p store store/commitlog store/consumequeue

进到bin目录里编辑broker.conf文件,cd /usr/local/rocketmq/rocketmq-all-5.1.1-bin-release/bin

官方broker说明文档:https://github.com/apache/rocketmq/blob/master/docs/cn/best_practice.md

原broker.conf文件内容如下

# 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 = DefaultCluster

#broker名称 brokerName = broker-a

#broekrId #0 表示 Master,>0 表示 Slave brokerId = 0

#删除时间凌晨4点 deleteWhen = 04

#文件保留时间,默认48小时 fileReservedTime = 48

#broker的角色
#ASYNC_MASTER异步复制master
#SYNC_MASTER 同步双写Master brokerRole = ASYNC_MASTER

#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType = ASYNC_FLUSH

追加属性后的broker.conf文件

# 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 = DefaultCluster 

#broker名称
brokerName = broker-a

#broekrId #0 表示 Master,>0 表示 Slave
brokerId = 0

#在每天的什么时间删除已经超过文件保留时间的 commit log
deleteWhen = 04

#文件保留时间,默认48小时
fileReservedTime = 48

#broker的角色
#ASYNC_MASTER异步复制master
#SYNC_MASTER 同步双写Master
brokerRole = ASYNC_MASTER

#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType = ASYNC_FLUSH

#监听端口
listenPort=10911

#nameserver地址,多个地址时用分号(;)分割
namesrvAddr=公网ip:9876

#存储根路径
storePathRootDir=/usr/local/rocketmq/rocketmq-all-5.1.1-bin-release/store

#存储commitlog路径
storePathCommitLog=/usr/local/rocketmq/rocketmq-all-5.1.1-bin-release/store/commitlog

#当前broker监听的ip
brokerIP1=公网ip

#存在主从 broker 时,如果在 broker 主节点上配置了 brokerIP2 属性,#broker 从节点会连接主节点配置的 brokerIP2 进行同步
brokerIP2=公网ip

#是否自动创建topic
autoCreateTopicEnable=true

 

进入到 /usr/local/rocketmq/rocketmq-all-5.1.1-bin-release/bin 目录下,根据内存大小,对JVM参数进行调整,runbroker.sh 文件和 runserver.sh 文件,修改内存大小

修改runbroker.sh文件

 

修改runserver.sh 文件

 

如果内存太小启动失败,查看应用内存情况 ,并清空缓存内存,再次尝试启动

--清除缓存
echo 1 > /proc/sys/vm/drop_caches --清除pagecache
echo 2 > /proc/sys/vm/drop_caches --清除回收slab分配器中的对象(包括目录项缓存和inode缓存)。slab分配器是内核中管理内存的一种机制,其中很多缓存数据实现都是用的pagecache
echo 3 > /proc/sys/vm/drop_caches --清除pagecache和slab分配器中的缓存对象

 

启动和关闭 rocketmq nameserver

#启动,并打印日志到文件
nohup sh /usr/local/rocketmq/rocketmq-all-5.1.1-bin-release/bin/mqnamesrv >/usr/local/rocketmq/mqnamesrv.log 2>&1 & #关闭 sh /usr/local/rocketmq/rocketmq-all-5.1.1-bin-release/bin/mqshutdown namesrv

 

启动broker

#启动broker,并打印日志到相关文件
nohup sh /usr/local/rocketmq/rocketmq-all-5.1.1-bin-release/bin/mqnamesrv >/usr/local/rocketmq/mqnamesrv.log 2>&1 &

 

使用 jps-l 命令 查看是否启动成功

 

================================================================================================================================================================================================

配置Master2

进入bin目录下创建配置文件broke_b.conf,文件内容如下

#集群名称
brokerClusterName = DefaultCluster

#broker名称
brokerName = broker-b

#0表示master > 0表示save
brokerId = 0

#删除commitlog文件时间点,默认凌晨4点
deleteWhen = 04

#文件保留时间,默认48小时
fileReservedTime = 48

#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole = ASYNC_MASTER


#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType = ASYNC_FLUSH


listenPort=11911
namesrvAddr=120.53.239.169:9876
storePathRootDir=/usr/local/rocketmq/rocketmq-all-5.1.1-bin-release/store_a
storePathCommitLog=/usr/local/rocketmq/rocketmq-all-5.1.1-bin-release/store_a/commitlog
storePathConsumerQueue=/usr/local/rocketmq/rocketmq-all-5.1.1-bin-release/store_a/consumequeue
brokerIP1=120.53.239.169
brokerIP2=120.53.239.169
autoCreateTopicEnable=true

备注:复制原broker.conf文件后修改相应存储文件路径、broker监听的端口,broker名称即可

启动broker-b

nohup sh /usr/local/rocketmq/rocketmq-all-5.1.1-bin-release/bin/mqbroker -c /usr/local/rocketmq/rocketmq-all-5.1.1-bin-release/conf/broker_b.conf  >/usr/local/rocketmq/broker_b.log 2>&1 & 

 

查看集群 

 

标签:bin,5.1,单机,broker,Master,RocketMq,local,rocketmq,usr
From: https://www.cnblogs.com/-xyl/p/17473212.html

相关文章

  • zookeeper单机伪集群安装配置(已验证)
    1.下载解压zookeeper(1)下载地址:略(2)解压:略要注意的是,你打算在你的单机上建立几个ZooKeeper服务器,你就建立几个目录,然后在每个目录里都解压zookeeper。2.部署规模为3的单机伪机群(1)server0新建目录data:/home/michael/opt/zookeeper/server0/zookeeper/data新建目录logs:/home/michael/......
  • docker 安装并配置nacos2.2.2 单机
    docker拉取文件找镜像参考mysql安装找镜像步骤:https://www.cnblogs.com/CodeLuckly/p/15710643.html拉取命令:dockerpullnacos/nacos-server:v2.2.2挂载目录:就是为了让nacos的容器中文件映射到宿主机上mkdir-p/mydata/nacos/logs/#新建logs目录......
  • The rocketMQTemplate does not exist TransactionListener
    rocketmq-starter版本:2.2.1发送的代码:@Testpublicvoidtest1()throwsException{ //事务id StringtransactionId=UUID.randomUUID().toString(); info(">>>发送半消息!transactionId:{}",transactionId); //发送事务消息 TransactionSendResultsendResu......
  • 基于 AIGC,RocketMQ 学习社区探索开源软件学习新范式
    作者:寒斜AIGC持续火爆全球,越来越多的场景开始接入并体现非凡的价值。其中应用广泛的场景之一就是智能知识问答,它改变了人们学习的方式,从阅读式到问答式,让知识的获取更加精准有效。开源软件拥有着广泛的求知群体,AIGC+社区的结合是学习型社区未来演进方向上的一个新颖的尝试,今天我......
  • demosaicnet-master的包代码阅读笔记
    init.py我在学init用法时候的笔记该文件里面都是导入模块,其中从dataset.py是导入所有模块,因为模糊导入的__all__没有定义。from.modulesimportBayerDemosaickfrom.modulesimportXTransDemosaickfrom.mosaicimportxtransfrom.mosaicimportbayerfrom.mosaicim......
  • RocketMQ消费暂停问题分析
    一、背景客经使用rocketMq批量推送数据到pcr执行次贷策略引擎和互斥决策引擎,pcr将决策结果推送到前置路由。二、问题现象描述在客经推数据时,pcr-updateBorrowState消息积压越来越多,从日志上看,pcr不拉取消息,重启服务器后可以消费消息,过一会又消费变慢,不断重启才让所有消息消费......
  • git pull和git pull origin master (拉取远程分支合并到其他本地分支)
    gitpull用法:gitpull命令的作用是:取回远程主机某个分支的更新,再与本地的指定分支合并。一句话总结gitpull和gitfetch的区别:gitpull=gitfetch+gitmergegitfetch不会进行合并执行后需要手动执行gitmerge合并分支,而gitpull拉取远程分之后直接与本地分支进行合并。更准......
  • RocketMQ 学习社区重磅上线!AI 互动,一秒了解 RocketMQ 功能源码
    作者:RocketMQ学习社区RocketMQ背景ApacheRocketMQ诞生至今,一直服务于100%阿里集团内部业务、阿里云以及开源社区数以万计的企业客户。历经十多年双十一严苛流量验证的RocketMQ,承载了超过万亿级消息规模的洪峰压力。2021年ApacheRocketMQ更是进入全新5.0时代。立足于企......
  • RocketMQ 学习社区重磅上线!AI 互动,一秒了解 RocketMQ 功能源码
    作者:RocketMQ学习社区RocketMQ背景ApacheRocketMQ诞生至今,一直服务于100%阿里集团内部业务、阿里云以及开源社区数以万计的企业客户。历经十多年双十一严苛流量验证的RocketMQ,承载了超过万亿级消息规模的洪峰压力。2021年ApacheRocketMQ更是进入全新5.0时代。立足......
  • k8s实战案例之部署redis单机和redis cluster
    1、在k8s上部署redis单机1.1、redis简介redis是一款基于BSD协议,开源的非关系型数据库(nosql数据库),作者是意大利开发者SalvatoreSanfilippo在2009年发布,使用C语言编写;redis是基于内存存储,而且是目前比较流行的键值数据库(key-valuedatabase),它提供将内存通过网络远程共享的一种服......