吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1356|回复: 1
收起左侧

[Java 转载] RocketMq集群部署

[复制链接]
Ceanie 发表于 2021-6-21 19:45
本帖最后由 Ceanie 于 2021-7-1 00:01 编辑

本人在安装RocketMq集群,并整合进入springboot 的时候 ,一直度娘搜索了不知多少条安装教程,他们的教程总是零零散散的,太乱了,这里整合成一片文章,方便大家查看!

部署集群多Master模式(无Slave节点)安装教程(同比,可以多master,slave)提示,注意端口防火墙(放开9876端口)
部署步骤:[多台服务器步骤相同]环境准备jdk1.8
maven
docker一、(安装rocketmq)
  • 下载: rocketmq-all-4.7.0-source-release.zip
  • 创建文件夹: mkdir -p /usr/local/rocketmq/
  • 解压: unzip rocketmq-all-4.7.0-source-release.zip
  • 移动文件 mv rocketmq-all-4.7.0-source-release  /usr/local/rocketmq/
  • 安装(这里需要安装maven): mvn -Prelease-all -DskipTests clean install -U

二、修改环境变量(在”/etc/profile”末尾添加):
  • vim /etc/profile
  • export ROCKETMQ_HOME=/usr/local/rocketmq/rocketmq-all-4.7.0-source-release/distribution/target/rocketmq-4.7.0/rocketmq-4.7.0
  • export PATH=$ROCKETMQ_HOME/bin:$PATH
  • :wq!
  • source /etc/profile

三、修改 conf/2m-noslave 文件中配置文件内容如下{ip填写内网的}
#文件组brokerClusterName=DefaultCluster
# 集群名,主从rocketmq的名称是一致的brokerName={broker-a,broker-b}
# 0表示master, 非0表示slavebrokerId=0
#集群的地址namesrvAddr={ip1}:9876;{ip2}:9876
#强制指定本机IP,需要根据每台机器进行修改。官方介绍可为空,系统默认自动识别,但多网卡时IP地址可能读取错误brokerIP1={本机IP不需要端口}
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数defaultTopicQueueNums=4
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭autoCreateTopicEnable=true
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭autoCreateSubscriptionGroup=true
#Broker 对外服务的监听端口listenPort=10911
#删除文件时间点,默认凌晨 4点deleteWhen=04
#文件保留时间,默认 48 小时fileReservedTime=18
#commitLog每个文件的大小默认1GmapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间diskMaxUsedSpaceRatio=88
#存储路径storePathRootDir=/usr/local/rocketmq/store
#commitLog 存储路径storePathCommitLog=/usr/local/rocketmq/store/commitlog
#消费队列存储路径存储路径storePathConsumeQueue=/usr/local/rocketmq/store/consumequeue
#消息索引存储路径storePathIndex=/usr/local/rocketmq/store/index
#checkpoint 文件存储路径storeCheckpoint=/usr/local/rocketmq/store/checkpoint
#abort 文件存储路径abortFile=/usr/local/rocketmq/store/abort
#限制的消息大小maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVEbrokerRole=SYNC_MASTER
#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false
#发消息线程池数量sendMessageThreadPoolNums=128
#拉消息线程池数量pullMessageThreadPoolNums=128
#打开锁
#useReentrantLockWhenPutMessage=truewaitTimeMillsInSendQueue=3000
#从节点是否可读
# slaveReadEnable=true
四、修改默认的启动文件1、修改runserver.sh
  • vim /usr/local/rocketmq/rocketmq-all-4.7.0-source-release/distribution/target/rocketmq-4.7.0/rocketmq-4.7.0/bin/runserver.sh
  • 修改内存大小
  • JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
  • 这里是重点,需要删除这两句,不然无法启动
  • export CLASSPATH=.:${BASE_DIR}/conf:${CLASSPATH}
  • JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
  • :wq!
2、修改runbroker.sh
  • vim /usr/local/rocketmq/rocketmq-all-4.7.0-source-release/distribution/target/rocketmq-4.7.0/rocketmq-4.7.0/bin/runbroker.sh
  • 修改内存大小
  • JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m"
  • :wq!
3、修改tool.sh
  • vim /usr/local/rocketmq/rocketmq-all-4.7.0-source-release/distribution/target/rocketmq-4.7.0/rocketmq-4.7.0/bin/tool.sh
  • 修改内存大小
  • JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m -XX:PermSize=128m -XX:MaxPermSize=128m"

五、启动命令服务器a启动命令
  • 启动mqnamesrv
  • nohup sh /usr/local/rocketmq/rocketmq-all-4.7.0-source-release/distribution/target/rocketmq-4.7.0/rocketmq-4.7.0/bin/mqnamesrv &
  • 启动broker
  • nohup sh /usr/local/rocketmq/rocketmq-all-4.7.0-source-release/distribution/target/rocketmq-4.7.0/rocketmq-4.7.0/bin/mqbroker -c /usr/local/rocketmq/rocketmq-all-4.7.0-source-release/distribution/target/rocketmq-4.7.0/rocketmq-4.7.0/conf/2m-noslave/broker-a.properties &
服务器b启动命令
  • 启动mqnamesrv
  • nohup sh /usr/local/rocketmq/rocketmq-all-4.7.0-source-release/distribution/target/rocketmq-4.7.0/rocketmq-4.7.0/bin/mqnamesrv &
  • 启动broker
  • nohup sh /usr/local/rocketmq/rocketmq-all-4.7.0-source-release/distribution/target/rocketmq-4.7.0/rocketmq-4.7.0/bin/mqbroker -c /usr/local/rocketmq/rocketmq-all-4.7.0-source-release/distribution/target/rocketmq-4.7.0/rocketmq-4.7.0/conf/2m-noslave/broker-b.properties &

六、发送测试消息
  • 发消息
  • sh /usr/local/rocketmq/rocketmq-all-4.7.0-source-release/distribution/target/rocketmq-4.7.0/rocketmq-4.7.0/bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
  • 收消息
  • sh /usr/local/rocketmq/rocketmq-all-4.7.0-source-release/distribution/target/rocketmq-4.7.0/rocketmq-4.7.0/bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer

七、控制台查看
  • docker run -dit --name rocketmq-console-ng -e "JAVA_OPTS=-Drocketmq.namesrv.addr=ip1:9876;ip2:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 9875:8080 styletang/rocketmq-console-ng


免费评分

参与人数 1吾爱币 +1 热心值 +1 收起 理由
Quincy379 + 1 + 1 谢谢@Thanks!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

yzyd110 发表于 2021-6-22 00:34
谢谢分享,收藏一下备用
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-25 16:18

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表