码迷,mamicode.com
首页 > 其他好文 > 详细

RocketMQ集群部署安装

时间:2019-12-24 12:04:42      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:monit   clu   nsf   test   tgt   enable   过程   class   ansi   

RcoketMQ:【

1.低延时:在高压下,1毫秒内超过99.6%的反应延迟。

2.面向金融:具有跟踪和审计功能的高可用性。

3.行业可持续发展:保证了万亿级的消息容量。

4.厂商中立:一个新的开放的分布式消息和流媒体标准自最新的4.1版本。

5.BigData友好:批量转移与多功能集成的洪水吞吐量。

6.大量的积累:只要有足够的磁盘空间,就可以累积消息而不会造成性能损失。

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

server:172.26.141.69(主a从b)

server:172.26.141.75(主b从a)

监控管理平台:172.26.141.85

1.安装jdk1.8 配置环境
wget http://172.26.107.14/newyum/jdk-8-1.el7.x86_64.rpm
sudo yum install local jdk-8-1.el7.x86_64.rpm -y

2.安装MAVEN 配置环境
tar -zxf apache-maven-3.6.2-bin.tar.gz
mv apache-maven-3.6.2 /apprun/
mv apache-maven-3.6.2 maven

环境配置(sudo vi /etc/profile)
MAVEN_HOME=/apprun/maven
PATH=$PATH:$MAVEN_HOME/bin
export JAVA_HOME=/apprun/jdk
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export PATH=$JAVA_HOME/bin:$HOME/bin:$HOME/.local/bin:$PATH

技术图片

 

 

 

3.rocketmq安装:(http://rocketmq.apache.org/

http://rocketmq.apache.org/release_notes/release-notes-4.4.0/

技术图片

 

 

 


unzip -d ./ ./rocketmq-all-4.4.0-source-release.zip
cd rocketmq-all-4.4.0
mvn -Prelease-all -DskipTests clean install -U
时间比较久
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:24 h
[INFO] Finished at: 2019-11-25T16:58:53+08:00
[INFO] ------------------------------------------------------------------------
[apprun@rocketmq01 rocketmq-all-4.4.0]$

cd distribution/target/
mv apache-rocketmq /apprun/
接下来先建好目录,进入 rocketmq-4.4.0目录(apache-rocketmq),把logs 目录、data/store/........如下所示的文件夹建好
cd /apprun/apache-rocketmq/
mkdir -pv {logs,data/store/{commitlog,consumequeue,index},data2/store/{commitlog,consumequeue,index}}

启动脚本的参数改下(虚拟机)
1.vim runbroker.sh (因为默认的值适合在生产上使用) -server -Xms512m -Xmx512m -Xmn256m
2. vim runserver.sh (同样的道理) -server -Xms512m -Xmx512m -Xmn126m -XX:PermSize=128m -XX:MaxPermSize=320m
3. vim tools.sh -server -Xms256m -Xmx256m -Xmn128m -XX:PermSize=128m -XX:MaxPermSize=128m

修改配置文件(/apprun/apache-rocketmq/conf/2m-2s-async/)[俩台机器互为主从]
172.26.141.69机器上主要 broker-a.properties broker-b-s.properties两个文件 内容分别如下:
vim broker-a.properties
#========================================================================================================
brokerClusterName=JiaTingYunRocketMQCluster
brokerName=broker-a
brokerId=0
#deleteWhen=04
#fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH


listenPort=10911
#nameserver地址,分号分割
namesrvAddr=172.26.141.69:9876;172.26.141.75:9876
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=false
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=false
brokerIP1=172.26.141.69
storePathRootDir=/apprun/apache-rocketmq/data/store
storePathCommitLog=/apprun/apache-rocketmq/data/store/commitlog
# 消费队列存储路径存储路径
storePathConsumerQueue=/apprun/apache-rocketmq/data/store/consumequeue
#消息索引存储路径
storePathIndex=/apprun/apache-rocketmq/data/store/index
#checkpoint 文件存储路径
storeCheckpoint=/apprun/apache-rocketmq/data/store/checkpoint
#abort 文件存储路径
abortFile=/apprun/apache-rocketmq/data/store/abort
#删除文件时间点,默认凌晨 4点
deleteWhen=04
#文件保留时间,默认 48 小时
fileReservedTime=120
# commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
#diskMaxUsedSpaceRatio=88
#========================================================================================================


vim broker-b-s.properties
#========================================================================================================
brokerClusterName=JiaTingYunRocketMQCluster
brokerName=broker-b
brokerId=1
#deleteWhen=04
#fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH


listenPort=10921
#nameserver地址,分号分割
namesrvAddr=172.26.141.69:9876;172.26.141.75:9876
brokerIP1=172.26.141.69
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=false
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=false


storePathRootDir=/apprun/apache-rocketmq/data2/store
storePathCommitLog=/apprun/apache-rocketmq/data2/store/commitlog
# 消费队列存储路径存储路径
storePathConsumerQueue=/apprun/apache-rocketmq/data2/store/consumequeue
#消息索引存储路径
storePathIndex=/apprun/apache-rocketmq/data2/store/index
#checkpoint 文件存储路径
storeCheckpoint=/apprun/apache-rocketmq/data2/store/checkpoint
#abort 文件存储路径
abortFile=/apprun/apache-rocketmq/data2/store/abort
#删除文件时间点,默认凌晨 4点
deleteWhen=04
#文件保留时间,默认 48 小时
fileReservedTime=120
# commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
#diskMaxUsedSpaceRatio=88
#========================================================================================================

 

172.26.141.75机器上主要 broker-b.properties broker-a-s.properties两个文件 内容分别如下:
vim broker-b.properties
#========================================================================================================
brokerClusterName=JiaTingYunRocketMQCluster
brokerName=broker-b
brokerId=0
#deleteWhen=04
#fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH


listenPort=10911
#nameserver地址,分号分割
namesrvAddr=172.26.141.69:9876;172.26.141.75:9876
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=false
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=false
brokerIP1=172.26.141.75
storePathRootDir=/apprun/apache-rocketmq/data/store
storePathCommitLog=/apprun/apache-rocketmq/data/store/commitlog
# 消费队列存储路径存储路径
storePathConsumerQueue=/apprun/apache-rocketmq/data/store/consumequeue
#消息索引存储路径
storePathIndex=/apprun/apache-rocketmq/data/store/index
#checkpoint 文件存储路径
storeCheckpoint=/apprun/apache-rocketmq/data/store/checkpoint
#abort 文件存储路径
abortFile=/apprun/apache-rocketmq/data/store/abort
#删除文件时间点,默认凌晨 4点
deleteWhen=04
#文件保留时间,默认 48 小时
fileReservedTime=120
# commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
#diskMaxUsedSpaceRatio=88
#========================================================================================================


vim broker-a-s.properties
#========================================================================================================
brokerClusterName=JiaTingYunRocketMQCluster
brokerName=broker-a
brokerId=1
#deleteWhen=04
#fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH


listenPort=10921
#nameserver地址,分号分割
namesrvAddr=172.26.141.69:9876;172.26.141.75:9876
brokerIP1=172.26.141.75
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=false
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=false


storePathRootDir=/apprun/apache-rocketmq/data2/store
storePathCommitLog=/apprun/apache-rocketmq/data2/store/commitlog
# 消费队列存储路径存储路径
storePathConsumerQueue=/apprun/apache-rocketmq/data2/store/consumequeue
#消息索引存储路径
storePathIndex=/apprun/apache-rocketmq/data2/store/index
#checkpoint 文件存储路径
storeCheckpoint=/apprun/apache-rocketmq/data2/store/checkpoint
#abort 文件存储路径
abortFile=/apprun/apache-rocketmq/data2/store/abort
#删除文件时间点,默认凌晨 4点
deleteWhen=04
#文件保留时间,默认 48 小时
fileReservedTime=120
# commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
#diskMaxUsedSpaceRatio=88
#=======================================================================================================

 


添加启停脚步(1.nameServer.sh 2.master.sh 3.slave.sh)
启动:1。先启动俩台的nameServer.sh
cd /apprun/apache-rocketmq

技术图片

 

 

 

添加nameServer.sh脚本
bash nameServer.sh
2.再启动俩台的master.sh

技术图片

 

 

 添加master.sh脚本


bash master.sh
3.最后启动俩台的从

技术图片

 

 

 添加slave.sh脚本


bash slave.sh

查看

[apprun@rocketmq02 apache-rocketmq]$ jps
8849 NamesrvStartup
9041 BrokerStartup
8917 BrokerStartup
14934 Jps
[apprun@rocketmq02 apache-rocketmq]$

[apprun@rocketmq01 ~]$ /apprun/apache-rocketmq/bin/mqadmin clusterList -n 172.26.141.69:9876
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
#Cluster Name #Broker Name #BID #Addr #Version #InTPS(LOAD) #OutTPS(LOAD) #PCWait(ms) #Hour #SPACE
JiaTingYunRocketMQCluster broker-a 0 172.26.141.69:10911 V4_4_0 0.00(0,0ms) 0.00(0,0ms) 0 437426.29 0.0108
JiaTingYunRocketMQCluster broker-a 1 172.26.141.75:10921 V4_4_0 0.00(0,0ms) 0.00(0,0ms) 0 437426.29 0.0108
JiaTingYunRocketMQCluster broker-b 0 172.26.141.75:10911 V4_4_0 0.00(0,0ms) 0.00(0,0ms) 0 437426.29 0.0108
JiaTingYunRocketMQCluster broker-b 1 172.26.141.69:10921 V4_4_0 0.00(0,0ms) 0.00(0,0ms) 0 437426.29 0.0108
[apprun@rocketmq01 ~]$

 技术图片

 

 

 

4。安装配置监控管理(172.26.141.85)
cd /apprun/soft/wangbocheng
git clone https://github.com/apache/rocketmq-externals.git
ln -s /apprun/soft/wangbocheng/rocketmq-externals /apprun/

修改配置文件
vim /apprun/rocketmq-externals/rocketmq-console/src/main/resources/application.properties
#=======================================================================================================
server.contextPath=
server.port=8080

### SSL setting
#server.ssl.key-store=classpath:rmqcngkeystore.jks
#server.ssl.key-store-password=rocketmq
#server.ssl.keyStoreType=PKCS12
#server.ssl.keyAlias=rmqcngkey

#spring.application.index=true
spring.application.name=rocketmq-console
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
logging.config=classpath:logback.xml
#if this value is empty,use env value rocketmq.config.namesrvAddr NAMESRV_ADDR | now, you can set it in ops page.default localhost:9876
rocketmq.config.namesrvAddr=172.26.141.69:9876;172.26.141.75:9876
#if you use rocketmq version < 3.5.8, rocketmq.config.isVIPChannel should be false.default true
rocketmq.config.isVIPChannel=
#rocketmq-console‘s data path:dashboard/monitor
rocketmq.config.dataPath=/tmp/rocketmq-console/data
#set it false if you don‘t want use dashboard.default true
rocketmq.config.enableDashBoardCollect=true
#set the message track trace topic if you don‘t want use the default one
rocketmq.config.msgTrackTopicName=
rocketmq.config.ticketKey=ticket

#Must create userInfo file: ${rocketmq.config.dataPath}/users.properties if the login is required
rocketmq.config.loginRequired=false

#=======================================================================================================


接着对rocketmq-console进行编译打包运行(mvn的编辑过程需要等待一段时间)
cd /apprun/rocketmq-externals/rocketmq-console/
mvn clean package -Dmaven.test.skip=true

[INFO] Building jar: /apprun/soft/wangbocheng/rocketmq-externals/rocketmq-console/target/rocketmq-console-ng-1.0.1-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17:23 min
[INFO] Finished at: 2019-11-26T09:55:23+08:00
[INFO] ------------------------------------------------------------------------

编译成功后在target下找到文件:rocketmq-console-ng-1.0.1.jar


创建启动脚本
cd /apprun/
vim MQ_jiankong.sh
#=======================================================================================================
#!/bin/sh
base_dir=$(cd "$(dirname "$0")"; pwd)

nohup java -jar /apprun/rocketmq-externals/rocketmq-console/target/rocketmq-console-ng-1.0.1.jar --server.port=8080 --rocketmq.config.namesrvAddr="172.26.141.69:9876;172.26.141.75:9876" &
#=======================================================================================================


启动
bash MQ_jiankong.sh
查看
ps aux |grep rocketmq-console-ng

netstat -ntlp | grep 8080

 技术图片

 

 

 


#==========空跑俩天,发现内存消耗过大==========
RocketMQ性能调优
1.开启异步刷盘
flushDiskType=ASYNC_FLUSH
同步刷盘TPS过低,较难满足业务发展需求
2.开启堆外内存设置
transientStorePoolEnable=true
消息写入到堆外内存,消费时从pageCache消费,读写分离,提升集群性能
3.开启文件预热
warmMapedFileEnable=true
开启文件预热,避免日志文件在分配内存时缺页中断
4.开启Slave读权限
slaveReadEnable=true
消息占用物理内存的大小通过accessMessageInMemoryMaxRatio来配置默认为40%;
如果消费的消息不在内存中,开启slaveReadEnable时会从slave节点读取;提高Master内存利用率
5.关闭堆内存据传输
transferMsgByHeap默认true设置为false
Broker响应消费请求时,不必将数据重新读到堆内存再发送给客户端;
直接从PageCache将数据发送给客户端

RocketMQ集群部署安装

标签:monit   clu   nsf   test   tgt   enable   过程   class   ansi   

原文地址:https://www.cnblogs.com/NGames/p/12090317.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!