文章标题写的是多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. -bash: nignx: 未找到命令

    nignx -t 如果报错: 因为没有配置环境变量吧,把nginx路径 配置到环境变量里面就可以. 按照配置: 1:进入 vim /etc/profile 文件 在配置文件的最后面添加PATH(PAT ...

  2. @ConditionalOnMissingBean 如何实现覆盖第三方组件中的 Bean

    1. 自定义一个简单 spring-boot 组件 创建 olive-starter 项目 对应的 pom.xml文件如下 <project xmlns="http://maven.a ...

  3. hive SQL 初学者题目,实战题目 字符串函数,日期拼接,开窗函数。。。。

    sql:Hive实现按照指定格式输出每七天的消费平均数输出格式:2018-06-01~2018-06-07 12.29...2018-08-10~2018-08-16 80.67 答案:-- 1.先将 ...

  4. html + css 01: 3d立方体

    html + css实现3d立方体 css代码 /*页面背景色*/ body{ background-color: black; background-repeat:no-repeat; } /*** ...

  5. AtCoder Beginner Contest 248 E - K-colinear Line // 计算几何

    原题链接:E - K-colinear Line (atcoder.jp) 题意: 给出直角坐标系上N个点(N <= 300),求经过这些点中至少K个点的直线数量,若有无穷多条,则输出" ...

  6. 如何在Rust中打印变量的类型?

    #![feature(core_intrinsics)] fn print_type_of<T>(_: T) { println!("{}", unsafe { std ...

  7. std::hash<std::pair<int, int> >

    标题是搞笑的 ! 这个问题只需要 since C++11 问题:怎么让 unordered_map 支持使用 pair 作为 key? 如果你能把两个东西压到一个基本类型里那么就不用解决这个问题了 . ...

  8. Nginx 配置静态资源防盗链

    # 什么是静态资源盗链: # 你服务器上的一张图片,127.0.0.1/images/a.png # 别人的html页面可以直接通过<img src="127.0.0.1/images ...

  9. 完整代码:安卓小软件“CSV联系人导入导出工具”

    完整代码:安卓小软件"CSV联系人导入导出工具" 开发了一个安卓小软件"CSV联系人导入导出工具",欢迎测试.本软件可以帮你快速备份和恢复联系人,不用担心号码遗 ...

  10. iommu分析之---intel irq remap框架实现

    背景介绍: IRQ域层级结构: 在某些架构上,可能有多个中断控制器参与将一个中断从设备传送到目标CPU. 让我们来看看x86平台上典型的中断传递路径吧 Device --> IOAPIC -&g ...