rocketmq-5.0.0的dleger高可用集群部署

1、部署规划-3台服务器

(1)服务器准备

  • 192.168.0.1(主)
  • 192.168.0.2(从)
  • 192.168.0.3(从)

(2)核对空间,内存

  • df -h
  • free -h

(3)确认启动用户及部署路径

  1. 用户:applin【确认有应用路径的写入执行权限,755,或应用路径归属于applin】
  2. 应用路径:/software/
  3. 数据存储路径:/software/rocketmq-all-5.0.0-bin-release/store
  4. 日志存储路径:/software/rocketmq-all-5.0.0-bin-release/logs

2、获取rocketmq-5.0.0版本并上传到服务器

(1)获取文件

rocketmq官方下载链接


(2)通过WinScp或其他上传包文件到指定服务器路径

  • 192.168.0.1:/software/rocketmq-all-5.0.0-bin-release.zip
  • 192.168.0.2:/software/rocketmq-all-5.0.0-bin-release.zip
  • 192.168.0.3:/softwarerocketmq-all-5.0.0-bin-release.zip

3、dleger高可用集群部署

3.1、3台服务器统一操作

(1)新建日志+数据存储路径

bash 复制代码
cd /software
unzip rocketmq-all-5.0.0-bin-release.zip
su - applin
mkdir -p /software/rocketmq-all-5.0.0-bin-release/store
mkdir -p /software/rocketmq-all-5.0.0-bin-release/logs
cd /software/rocketmq-all-5.0.0-bin-release

(2)修改日志路径

bash 复制代码
执行命令1: cd /software/rocketmq-all-5.0.0-bin-release/conf
执行命令2: sed -i 's?${user.home}/logs/rocketmqlogs?/software/rocketmq-all-5.0.0-bin-release/logs?' /software/rocketmq-all-5.0.0-bin-release/conf/logback_broker.xml
执行命令3: sed -i 's?${user.home}/logs/rocketmqlogs?/software/rocketmq-all-5.0.0-bin-release/logs?' /software/rocketmq-all-5.0.0-bin-release/conf/logback_controller.xml
执行命令4: sed -i 's?${user.home}/logs/rocketmqlogs?/software/rocketmq-all-5.0.0-bin-release/logs?' /software/rocketmq-all-5.0.0-bin-release/conf/logback_namesrv.xml
执行命令5: sed -i 's?${user.home}/logs/rocketmqlogs?/software/rocketmq-all-5.0.0-bin-release/logs?' /software/rocketmq-all-5.0.0-bin-release/conf/logback_proxy.xml
执行命令6: sed -i 's?${user.home}/logs/rocketmqlogs?/software/rocketmq-all-5.0.0-bin-release/logs?' /software/rocketmq-all-5.0.0-bin-release/conf/logback_tools.xml

(3)修改启动脚本内存及环境变量

bash 复制代码
执行命令1: cd /software/rocketmq-all-5.0.0-bin-release/bin
执行命令2: sed -i 's#${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m#${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m#' /software/rocketmq-all-5.0.0-bin-release/bin/runserver.sh
执行命令3:vim runserver.sh查看上述是否修改成功,同时更改环境变量如下,2个方法选其一
(1)[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/software/jdk/jdk_linux
#[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=$HOME/jdk/java
#[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java
#[ ! -e "$JAVA_HOME/bin/java" ] && error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)!"
(2)[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/software/jdk_linux
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/software/jdk_linux
[ ! -e "$JAVA_HOME/bin/java" ] && error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)!"
bash 复制代码
执行命令1: cd /software/rocketmq-all-5.0.0-bin-release/bin
执行命令2: sed -i 's#JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g"#JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g"#' /software/rocketmq-all-5.0.0-bin-release/bin/runbroker.sh
执行命令3:vim runbroker.sh查看上述是否修改成功,同时更改环境变量如下,2个方法选其一
(1)[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/software/jdk/jdk_linux
#[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=$HOME/jdk/java
#[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java
#[ ! -e "$JAVA_HOME/bin/java" ] && error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)!"
(2)[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/software/jdk_linux
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/software/jdk_linux
[ ! -e "$JAVA_HOME/bin/java" ] && error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)!"

3.2、3台服务器分别操作

目前看这三项有区别:

listenPort
dLegerSelfId与dLegerPeers保持对应。
brokerIP1

(1) IP1 - 192.168.0.1(主)

bash 复制代码
执行命令1: cd /software/rocketmq-all-5.0.0-bin-release/conf/dledger
执行命令2: vim broker-n0.conf
## 集群名
brokerClusterName = RaftCluster
## broker组名,同一个RaftClusterGroup内,brokerName名要一样
brokerName=RaftNode00
## 监听的端口
listenPort=30911
## 你设置的NameServer地址和端口
namesrvAddr=192.168.0.1:9876;192.168.0.2:9876;192.168.0.3:9876
storePathRootDir=/software/rocketmq-all-5.0.0-bin-release/store/node00
storePathCommitLog=/software/rocketmq-all-5.0.0-bin-release/store/node00/commitlog
enableDLegerCommitLog=true
dLegerGroup=RaftNode00
## n0 n1 n2 分别是broker1,broker2,broker3 的 dLegerSelfId
## 例如:dLegerPeers=n0-服务器1的IP:40911;n1-服务器2的IP:40912;n2-服务器3的IP:40913
dLegerPeers=n0-192.168.0.1:40911;n1-192.168.0.2:40912;n2-192.168.0.3:40913
## must be unique
## 这个值必须是在同一个RaftClusterGroup内唯一的
dLegerSelfId=n0
sendMessageThreadPoolNums=16
brokerIP1=192.168.0.1
执行命令3: nohup sh /software/rocketmq-all-5.0.0-bin-release/bin/mqnamesrv  &
执行命令4: nohup sh /software/rocketmq-all-5.0.0-bin-release/bin/mqbroker -c /software/rocketmq-all-5.0.0-bin-release/conf/dledger/broker-n0.conf &

(2) IP2 - 192.168.0.2(从)

bash 复制代码
执行命令1: cd /software/rocketmq-all-5.0.0-bin-release/conf/dledger
执行命令2: vim broker-n1.conf
执行命令1: cd /software/rocketmq-all-5.0.0-bin-release/conf/dledger
执行命令2: vim broker-n1.conf
## 集群名
brokerClusterName = RaftCluster
## broker组名,同一个RaftClusterGroup内,brokerName名要一样
brokerName=RaftNode00
## 监听的端口
listenPort=30921
## 你设置的NameServer地址和端口
namesrvAddr=192.168.0.1:9876;192.168.0.2:9876;192.168.0.3:9876
storePathRootDir=/software/rocketmq-all-5.0.0-bin-release/store/node00
storePathCommitLog=/software/rocketmq-all-5.0.0-bin-release/store/node00/commitlog
enableDLegerCommitLog=true
dLegerGroup=RaftNode00
## n0 n1 n2 分别是broker1,broker2,broker3 的 dLegerSelfId
## 例如:dLegerPeers=n0-服务器1的IP:40911;n1-服务器2的IP:40912;n2-服务器3的IP:40913
dLegerPeers=n0-192.168.0.1:40911;n1-192.168.0.2:40912;n2-192.168.0.3:40913
## must be unique
## 这个值必须是在同一个RaftClusterGroup内唯一的
dLegerSelfId=n1
sendMessageThreadPoolNums=16
brokerIP1=192.168.0.2
执行命令3: nohup sh /software/rocketmq-all-5.0.0-bin-release/bin/mqnamesrv  &
执行命令4: nohup sh /software/rocketmq-all-5.0.0-bin-release/bin/mqbroker -c /software/rocketmq-all-5.0.0-bin-release/conf/dledger/broker-n1.conf &

(3) IP3 - 192.168.0.3(从)

bash 复制代码
执行命令1: cd /software/rocketmq-all-5.0.0-bin-release/conf/dledger
执行命令2: vim broker-n2.conf
## 集群名
brokerClusterName = RaftCluster
## broker组名,同一个RaftClusterGroup内,brokerName名要一样
brokerName=RaftNode00
## 监听的端口
listenPort=30931
## 你设置的NameServer地址和端口
namesrvAddr=192.168.0.1:9876;192.168.0.2:9876;192.168.0.3:9876
storePathRootDir=/software/rocketmq-all-5.0.0-bin-release/store/node00
storePathCommitLog=/software/rocketmq-all-5.0.0-bin-release/store/node00/commitlog
enableDLegerCommitLog=true
dLegerGroup=RaftNode00
## n0 n1 n2 分别是broker1,broker2,broker3 的 dLegerSelfId
## 例如:dLegerPeers=n0-服务器1的IP:40911;n1-服务器2的IP:40912;n2-服务器3的IP:40913
dLegerPeers=n0-192.168.0.1:40911;n1-192.168.0.2:40912;n2-192.168.0.3:40913
## must be unique
## 这个值必须是在同一个RaftClusterGroup内唯一的
dLegerSelfId=n2
sendMessageThreadPoolNums=16
brokerIP1=192.168.0.3
执行命令3: nohup sh /software/rocketmq-all-5.0.0-bin-release/bin/mqnamesrv  &
执行命令4: nohup sh /software/rocketmq-all-5.0.0-bin-release/bin/mqbroker -c /software/rocketmq-all-5.0.0-bin-release/conf/dledger/broker-n2.conf &

​​​​​​​4******、验证******

(1)查看集群服务是否启动成功:jps

命令执行后,可查看到两个进程,NamesrvStartup和BrokerStartup
(2)在集群中任意一个节点的bin目录下执行如下命令:

bash 复制代码
执行命令1: cd /software/rocketmq-all-5.0.0-bin-release/bin
执行命令2: sh mqadmin clusterList -n 127.0.0.1:9876

结果中addr中有broker信息。

#BID显示3个,0+1+2,ACTIVATED显示3个,1个true+2个false。

(2)kill主broker并在此查看集群情况,master切换是否成功。重新启动后原master服务器变为从。【BID的0表示主】

5、日志

(1)Dleger高可用集群,3台中至少2台启动才不会报错
(2)核对配置项是否有错误
(3)空间不足、内存不足,清理后重启应用

相关推荐
不想睡觉的橘子君2 天前
【MQ】RabbitMQ、RocketMQ、kafka特性对比
kafka·rabbitmq·rocketmq
厌世小晨宇yu.3 天前
RocketMQ学习笔记
笔记·学习·rocketmq
洛卡卡了4 天前
如何选择最适合的消息队列?详解 Kafka、RocketMQ、RabbitMQ 的使用场景
kafka·rabbitmq·rocketmq
菜鸟起航ing4 天前
Spring Cloud Alibaba
spring cloud·java-ee·rocketmq
乄bluefox5 天前
学习RocketMQ(记录了个人艰难学习RocketMQ的笔记)
java·spring boot·中间件·rocketmq
虽千万人 吾往矣7 天前
golang rocketmq开发
开发语言·golang·rocketmq
HippoSystem7 天前
[RocketMQ 5.3.1] Win11 + Docker Desktop 本地部署全流程 + 踩坑记录
rocketmq
幸运小锦李先生12 天前
基于RabbitMQ,Redis,Redisson,RocketMQ四种技术实现订单延时关闭功能及其相关优缺点介绍(以12306为主题)
redis·rabbitmq·rocketmq·redisson·1024程序员节
₁ ₀ ₂ ₄13 天前
一篇文章了解RocketMQ基础知识。
分布式·中间件·rocketmq·1024程序员节
炭烤玛卡巴卡15 天前
【MacOS】RocketMQ 搭建Java客户端
macos·rocketmq·java-rocketmq