文章标题写的是多M多S同步双写集群安装,但是看具体参数配置,写的是异步复制Master

brokerRole=ASYNC_MASTER

flushDiskType=SYNC_FLUSH

#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
brokerId      #0 表示 Master,>0 表示 Slave
brokerRole #Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerIP1 #本机提供服务的IP地址
补充一个配置: slaveReadEnable=true #建议开启,默认关闭 #Broker 对外服务的监听端口
listenPort=10911 brokerRole=SYNC_MASTER #刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=SYNC_FLUSH

改进的地方:

brokerRole=SYNC_MASTER(使用同步双写)

flushDiskType=SYNC_FLUSH(同步刷盘)

listenPort=10911(#Broker对外服务的监听端口)

Name Server使用端口:9876

broker使用端口:10911

采用的主机:

192.168.2.163 rocketmq-nameserver1

192.168.2.165 rocketmq-nameserver2

192.168.2.163 rocketmq-master1

192.168.2.164 rocketmq-master2

192.168.2.162 rocketmq-slave1

192.168.2.165 rocketmq-slave2

vim /etc/hosts

192.168.2.163  rocketmq-nameserver1
192.168.2.165 rocketmq-nameserver2
192.168.2.163 rocketmq-master1
192.168.2.164 rocketmq-master2
192.168.2.162 rocketmq-slave1
192.168.2.165 rocketmq-slave2
# 所有角色上安装
# 上传jdk-8u231-linux-x64.tar.gz
# mkdir /opt/server -p
# tar zvxf jdk-8u231-linux-x64.tar.gz -C /opt/server # vim /etc/profile.d/java.sh #!/bin/bash export JAVA_HOME=/opt/server/jdk1.8.0_231
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH # source /etc/profile.d/java.sh
# unzip rocketmq-all-4.7.1-bin-release.zip
# mv rocketmq-all-4.7.1-bin-release /opt/server/rocketmq
#安装包bin下文件没有执行权限
# chmod +x /opt/server/rocketmq/bin/* # 创建数据存储目录
# mkdir -p /opt/data/rocketmq/data/store/commitlog
# 创建日志目录
# mkdir -p /opt/var/logs/rocketmq/
# 修改日志目录
# cd /opt/server/rocketmq/conf
# sed -i 's#${user.home}/logs#/opt/var/logs/rocketmq#g' *.xml
# 查看修改
# grep logs *.xml
# 主机内存大的话这个可以不用修改

# 所有节点修改JVM(JVM调优,内存不够时设置小点)
# vim /opt/server/rocketmq/bin/runserver.sh
,默认是4g
JAVA_OPT=”JAVAOPT−server−Xms128m−Xmx256m−Xmn256m−XX:PermSize=128m−XX:MaxPermSize=320m”runbroker.sh
这个文件原来是这样的
JAVAOPT=”JAVAOPT−server−Xms128m−Xmx256m−Xmn256m−XX:PermSize=128m−XX:MaxPermSize=320m”runbroker.sh
这个文件原来是这样的JAVAOPT=”{JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g” 根据实际情况修改:
JAVA_OPT=”${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m”
# vim /opt/server/rocketmq/conf/plain_acl.yml
globalWhiteRemoteAddresses: accounts:
- accessKey: RocketMQ
secretKey: 12345678
whiteRemoteAddress:
admin: false
defaultTopicPerm: PUB|SUB
defaultGroupPerm: PUB|SUB
topicPerms:
- test-topicA=PUB|SUB
groupPerms:
# the group should convert to retry topic
- test-groupA=PUB|SUB
# 两台主机先做Name Server

# nohup /opt/server/rocketmq/bin/mqnamesrv &
# 验证
# cat nohup.out
The Name Server boot success.
# netstat -anlp |grep 9876
tcp 0 0 :::9876 :::* LISTEN 23750/java # 开机启动 echo "nohup /opt/server/rocketmq/bin/mqnamesrv &" >> /etc/rc.local # cat /etc/rc.local
# RocketMQ nameserver
nohup /opt/server/rocketmq/bin/mqnamesrv &

163主机操作

# vim /opt/server/rocketmq/conf/2m-2s-async/broker-a.properties
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=0
brokerIP1=192.168.2.163
namesrvAddr=192.168.2.163:9876;192.168.2.165:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
listenPort=10911
deleteWhen=04
fileReservedTime=120
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=50000000
destroyMapedFileIntervalForcibly=120000
redeleteHangedFileInterval=120000
diskMaxUsedSpaceRatio=88 storePathRootDir=/opt/data/rocketmq/data/store
storePathCommitLog=/opt/data/rocketmq/data/store/commitlog
maxMessageSize=65536
flushCommitLogLeastPages=4
flushConsumeQueueLeastPages=2
flushCommitLogThoroughInterval=10000
flushConsumeQueueThoroughInterval=60000 checkTransactionMessageEnable=false
sendMessageThreadPoolNums=128
pullMessageThreadPoolNums=128 brokerRole=ASYNC_MASTER
flushDiskType=SYNC_FLUSH aclEnable=true
# 启动master1
# nohup /opt/server/rocketmq/bin/mqbroker -c /opt/server/rocketmq/conf/2m-2s-async/broker-a.properties &
# netstat -anlp|grep java
tcp 0 0 :::10911 :::* LISTEN 24220/java
tcp 0 0 :::10912 :::* LISTEN 24220/java # 开机启动(nameserver必须为启动状态,建议手动启动) echo "nohup /opt/server/rocketmq/bin/mqbroker -c /opt/server/rocketmq/conf/2m-2s-async/broker-a.properties &" >> /etc/rc.local # cat /etc/rc.local
# RocketMQ master
nohup /opt/server/rocketmq/bin/mqbroker -c /opt/server/rocketmq/conf/2m-2s-async/broker-a.properties &

162主机操作

Broker-a Master Acl需要增加slave的白名单,重启Master (在192.168.2.163主机上操作)
# vim /opt/server/rocketmq/conf/plain_acl.yml
globalWhiteRemoteAddresses:
- 192.168.2.162 # 修改slave1(192.168.2.162)配置
# vim /opt/server/rocketmq/conf/2m-2s-async/broker-a.properties
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=1
brokerIP1=192.168.2.162
namesrvAddr=192.168.2.163:9876;192.168.2.165:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
listenPort=10911
deleteWhen=04
fileReservedTime=120
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=50000000
destroyMapedFileIntervalForcibly=120000
redeleteHangedFileInterval=120000
diskMaxUsedSpaceRatio=88 storePathRootDir=/opt/data/rocketmq/data/store
storePathCommitLog=/opt/data/rocketmq/data/store/commitlog
maxMessageSize=65536
flushCommitLogLeastPages=4
flushConsumeQueueLeastPages=2
flushCommitLogThoroughInterval=10000
flushConsumeQueueThoroughInterval=60000 checkTransactionMessageEnable=false
sendMessageThreadPoolNums=128
pullMessageThreadPoolNums=128 brokerRole=SLAVE
flushDiskType=SYNC_FLUSH aclEnable=true # 启动salve1
# nohup /opt/server/rocketmq/bin/mqbroker -c /opt/server/rocketmq/conf/2m-2s-async/broker-a.properties & # netstat -anlp|grep java
tcp 0 0 :::10911 :::* LISTEN 23774/java
tcp 0 0 :::10912 :::* LISTEN 23774/java # 开机启动(nameserver必须为启动状态,建议手动启动) echo "nohup /opt/server/rocketmq/bin/mqbroker -c /opt/server/rocketmq/conf/2m-2s-async/broker-a.properties &" >> /etc/rc.local # cat /etc/rc.local
nohup /opt/server/rocketmq/bin/mqbroker -c /opt/server/rocketmq/conf/2m-2s-async/broker-a.properties &

165主机操作

# 修改master2(192.168.2.165)配置
# vim /opt/server/rocketmq/conf/2m-2s-async/broker-b.properties
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=0
brokerIP1=192.168.2.165
namesrvAddr=192.168.2.163:9876;192.168.2.165:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
listenPort=10911
deleteWhen=04
fileReservedTime=120
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=50000000
destroyMapedFileIntervalForcibly=120000
redeleteHangedFileInterval=120000
diskMaxUsedSpaceRatio=88 storePathRootDir=/opt/data/rocketmq/data/store
storePathCommitLog=/opt/data/rocketmq/data/store/commitlog
maxMessageSize=65536
flushCommitLogLeastPages=4
flushConsumeQueueLeastPages=2
flushCommitLogThoroughInterval=10000
flushConsumeQueueThoroughInterval=60000 checkTransactionMessageEnable=false
sendMessageThreadPoolNums=128
pullMessageThreadPoolNums=128 brokerRole=ASYNC_MASTER
flushDiskType=SYNC_FLUSH aclEnable=true # 启动master2
# nohup /opt/server/rocketmq/bin/mqbroker -c /opt/server/rocketmq/conf/2m-2s-async/broker-b.properties & # 验证
# cat nohup.out
The Name Server boot success.
load config properties file OK, /opt/server/rocketmq/conf/2m-2s-async/broker-a.properties
The broker[broker-a, 172.25.2.102:10911] boot success.
# netstat -anlp|grep java
tcp 0 0 :::10911 :::* LISTEN 24220/java
tcp 0 0 :::10912 :::* LISTEN 24220/java # 开机启动(nameserver必须为启动状态,建议手动启动)
echo "nohup /opt/server/rocketmq/bin/mqbroker -c /opt/server/rocketmq/conf/2m-2s-async/broker-b.properties &" >> /etc/rc.local # cat /etc/rc.local
nohup /opt/server/rocketmq/bin/mqbroker -c /opt/server/rocketmq/conf/2m-2s-async/broker-b.properties &

164主机操作

Brocker-b Master Acl需要增加slave的白名单,重启Master  (在192.168.2.165主机上操作)
# vim /opt/server/rocketmq/conf/plain_acl.yml
globalWhiteRemoteAddresses:
- 192.168.2.164 # 修改slave2(192.168.2.164)配置
# vim /opt/server/rocketmq/conf/2m-2s-async/broker-b.properties
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=1
brokerIP1=192.168.2.164
namesrvAddr=192.168.2.163:9876;192.168.2.165:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
listenPort=10911
deleteWhen=04
fileReservedTime=120
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=50000000
destroyMapedFileIntervalForcibly=120000
redeleteHangedFileInterval=120000
diskMaxUsedSpaceRatio=88 storePathRootDir=/opt/data/rocketmq/data/store
storePathCommitLog=/opt/data/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 aclEnable=true # 启动salve2
# nohup /opt/server/rocketmq/bin/mqbroker -c /opt/server/rocketmq/conf/2m-2s-async/broker-b.properties & # 验证
# cat nohup.out
load config properties file OK, /opt/server/rocketmq/conf/2m-2s-async/broker-b.properties
The broker[broker-b, 192.168.2.164:10911] boot success. and name server is 192.168.2.163:9876;192.168.2.165:9876
# netstat -anlp|grep java
tcp 0 0 :::10911 :::* LISTEN 23774/java
tcp 0 0 :::10912 :::* LISTEN 23774/java # 开机启动(nameserver必须为启动状态,建议手动启动) echo "nohup /opt/server/rocketmq/bin/mqbroker -c /opt/server/rocketmq/conf/2m-2s-async/broker-b.properties &" >> /etc/rc.local # cat /etc/rc.local
nohup /opt/server/rocketmq/bin/mqbroker -c /opt/server/rocketmq/conf/2m-2s-async/broker-b.properties & 注:服务停止直接采用kill java 进程的方法

RocketMQ Console部署

从github上克隆源码后,找到rocketmq-console,修改application.properties配置文件,具体修改内容如下:

1.

server.address=0.0.0.0

server.port=9999

2.

rocketmq.config.namesrvAddr=172.25.2.101:9876;172.25.2.102:987

3.

rocketmq.config.accessKey=RocketMQ

rocketmq.config.secretKey=12345678

修改logback.xml文件,

和/opt/var/logs/consolelogs/

然后再编译打包(运行在163主机上)

nohup java -jar /opt/server/rocketmq-console/rocketmq-console-ng-2.0.0.jar >/dev/null &

访问地址:

http://192.168.2.163:9999

rocketmq 4.x 双主双从同步读写的更多相关文章

  1. RocketMQ学习笔记(16)----RocketMQ搭建双主双从(异步复制)集群

    1. 修改RocketMQ默认启动端口 由于只有两台机器,部署双主双从需要四个节点,所以只能修改rocketmq的默认启动端口,从官网下载rocketmq的source文件,解压后使用idea打开,全 ...

  2. Docker 部署 RocketMQ 双主双从模式( 版本v4.7.0)

    文章转载自:http://www.mydlq.club/article/96/ 系统环境: 系统版本:CentOS 7.8 RocketMQ 版本:4.7.0 Docker 版本:19.03.13 一 ...

  3. RocketMQ4.7.1双主双从集群搭建

    导读 上一集我们已经学会了SpringBoot整合RocketMQ点我直达,今天我们来搭建双主双从高性能MQ服务集群. 简介 主从架构 Broker角色,Master提供读写,Slave只支持读,Co ...

  4. Centos6.9下RocketMQ3.4.6高可用集群部署记录(双主双从+Nameserver+Console)

    之前的文章已对RocketMQ做了详细介绍,这里就不再赘述了,下面是本人在测试和生产环境下RocketMQ3.4.6高可用集群的部署手册,在此分享下: 1) 基础环境 ip地址 主机名 角色 192. ...

  5. 高可用Mysql架构_Mysql主从复制、Mysql双主热备、Mysql双主双从、Mysql读写分离(Mycat中间件)、Mysql分库分表架构(Mycat中间件)的演变

    [Mysql主从复制]解决的问题数据分布:比如一共150台机器,分别往电信.网通.移动各放50台,这样无论在哪个网络访问都很快.其次按照地域,比如国内国外,北方南方,这样地域性访问解决了.负载均衡:M ...

  6. Linux安装Mysql8.0.20并配置主从复制(一主一从,双主双从)

    1. 主从复制解释   将主数据库的增删改查等操作记录到二进制日志文件中,从库接收主库日志文件,根据最后一次更新的起始位置,同步复制到从数据库中,使得主从数据库保持一致. 2. 主从复制的作用 高可用 ...

  7. 在Docker下进行MyCAT管理双主双从MySQL集群

    前言 在Docker下双主双从MySQL集群模拟 https://www.cnblogs.com/yumq/p/14259964.html 本文实验配置文件 Docker拉取MyCAT镜像 如果没启动 ...

  8. Mysql双主双从高可用集群的搭建且与MyCat进行整合

    1.概述 老话说的好:瞻前顾后.患得患失只会让我们失败,下定决心,干就完了. 言归正传,之前我们聊了Mysql的一主一从读写分离集群的搭建,虽然一主一从或一主多从集群解决了并发读的问题,但由于主节点只 ...

  9. MySQL双主双从配置

    双主双从结构图 Master1配置 server-id=1 #开启binlog日志 log-bin=mysql-bin #忽略的库 binlog-ignore-db=mysql #复制的库 binlo ...

  10. 高可用Mysql架构_Mycat集群部署(HAProxy + 两台Mycat+Mysql双主双从)

    既然大家都知道了Mysql分布式在大型网站架构中的作用,在这里就不再阐述.本片博客文章是基于我曾经搭建过的一个Mysql集群基础上实现的,实现过双主热备.读写分离.分库分表. 博客链接:http:// ...

随机推荐

  1. error: cannot open .git/FETCH_HEAD: Permission denied

    可能原因:该操作的执行者对该目录没有写权限 解决:1.类Unix平台,使用chown将目录改为自己: 2.Windows平台,取消只读选项,给everyone用户所有权限:

  2. mvc 捕获404和500 等

    之前一直以为HandleErrorAttribute 可以捕获到后面自己尝试了不行,又自己想自定义页面,发现不行,然后设置了<customErrors/>节点 又不符合SEO 返回stat ...

  3. 004 SpringSecurity验证规则

    SpringSecurity验证规则 SpringSecurity框架登录后,==在userDetails对象中,一定会有一个权限列表 == 登录用户对象的值可能是: {"authoriti ...

  4. ASP.NET Core 6框架揭秘实例演示[29]:搭建文件服务器

    通过HTTP请求获取的Web资源很多都来源于存储在服务器磁盘上的静态文件.对于ASP.NET应用来说,如果将静态文件存储到约定的目录下,绝大部分文件类型都是可以通过Web的形式对外发布的." ...

  5. 秋季招聘季如何制作一款“秀色可餐”的简历?由ShareLatex和Python3打造

    原文转载自「刘悦的技术博客」https://v3u.cn/a_id_161 秋招季还有两个月就到了,即所谓的"金九银十".疫情因素导致市场环境不太理想,所以我们更应该未焚而徙薪,未 ...

  6. Javascript 构造函数、原型对象、实例之间的关系

    # Javascript 构造函数.原型对象.实例之间的关系 # 创建对象的方式 # 1.new object() 缺点:创建多个对象困难 var hero = new Object(); // 空对 ...

  7. [spring]spring详细总结

    spring 1.spring简介 Spring框架是一个开源的应用程序框架,是针对bean的生命周期进行管理的轻量级容器. Spring解决了开发者在J2EE开发中遇到的许多常见的问题,提供了功能强 ...

  8. How to code like a pro in 2022 and avoid If-Else

    在浏览文章的时候发现了一篇叙述有关if-else语句的文章,这篇文章作者是Thai Tran,他原文是用英语写的,然后看着文章浅显易懂,便尝试翻译成汉语.如有不妥还望指出. 原文链接:https:// ...

  9. 巨细靡遗流程控制,Go lang1.18入门精炼教程,由白丁入鸿儒,Go lang流程结构详解EP09

    流程结构就是指程序逻辑到底怎么执行,进而言之,程序执行逻辑的顺序.众所周知,程序整体都是自上由下执行的,但有的时候,又不仅仅是从上往下执行那么简单,大体上,Go lang程序的流程控制结构一共有三种: ...

  10. Windows下ESP32 环境搭建(基于esp-idf FreeRTOS)

    1. 之前的尝试(失败的尝试) 咸鱼买了3块ESP32开发板.背面写了NODEMCU v1.1,好像这玩意可以直接写lua,也可以刷Micropython写python,还可以用Arduino IDE ...