Rockmq 2m-noslave模式centos 7.9环境搭建

Rockmq 2m-noslave模式centos 7.9环境搭建

源码版本需要自己编码,因此需要安装maven.

关闭防火墙

输入 systemctl status firewalld.service ,若,防火墙处于running状态,则执行一下操作
输入 systemctl stop firewalld.service ,关闭防火墙
输入 systemctl disable firewalld.service ,禁用防火墙

下载rocketmq源码

https://www.apache.org/dyn/closer.cgi?path=rocketmq/4.9.2/rocketmq-all-4.9.2-source-release.zip

maven下载

https://maven.apache.org/download.cgi

下载jdk1.8:https://www.oracle.com/java/technologies/downloads/#java8
https://download.oracle.com/otn/java/jdk/8u311-b11/4d5417147a92418ea8b615e228bb6935/jdk-8u311-linux-x64.tar.gz

jdk安装及环境变量配置

cd /usr/local
把下载好的jdk通过xftp放入到/usr/local下,通过解压"tar -zxvf jdk-8u311-linux-x64.tar.gz"
环境变量

export JAVA_HOME=/usr/local/jdk1.8.0_311
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

执行source /etc/profile,使环境变量生效,运行java命令,看jdk安装是否成功

maven安装及环境变量配置

cd /usr/local
把下载好的maven通过xftp放入到/usr/local/soft下,通过解压"tar zxvf apache-maven-3.8.4-bin.tar.gz"
vim /etc/profile文件,追加如下内容

#maven环境变量配置
export MAVEN_HOME=/usr/local/apache-maven-3.8.4
export PATH=$MAVEN_HOME/bin:$PATH

执行source /etc/profile,使环境变量生效,执行"mvn -v",看maven安装是否成功

编译rocketmq源码
cd /usr/local
把下载好的源码包通过xftp放入到/usr/local/soft下,通过解压"unzip rocketmq-all-4.9.2-source-release.zip"
cd rocketmq-all-4.9.2
mvn -Prelease-all -DskipTests clean install -U
编译成功会有“building success”
编译好的文件在“/usr/local/rocketmq-all-4.9.2/distribution/target”目录下,有apache-rocketmq,有tar.gz,zip的编译好文件

mkdir /usr/local/rocketmq-all-4.9.2/store
mkdir /usr/local/rocketmq-all-4.9.2/store/commitlog
mkdir /usr/local/rocketmq-all-4.9.2/store/consumequeue
mkdir /usr/local/rocketmq-all-4.9.2/store/index
cd /usr/local/rocketmq-all-4.9.2/distribution/conf/2m-noslave/
vim broker-a.properties

brokerClusterName=rocketmq-cluster
#broker名字,注意此处不同的配置文件填写的不一样
#0 表示 Master,>0 表示 Slave 
brokerName=broker-a  
brokerId=0
#nameServer地址,分号分割
namesrvAddr=192.168.206.141:9876;192.168.206.142:9876
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭 
autoCreateTopicEnable=true
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭 
autoCreateSubscriptionGroup=true
#Broker 对外服务的监听端口
listenPort=10911
#删除文件时间点,默认凌晨 4点
deleteWhen=04
#文件保留时间,默认 48 小时
fileReservedTime=120
#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000 #destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/usr/local/rocketmq-all-4.9.2/store
#commitLog 存储路径
storePathCommitLog=/usr/local/rocketmq-all-4.9.2/store/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/usr/local/rocketmq-all-4.9.2/store/consumequeue
#消息索引存储路径
storePathIndex=/usr/local/rocketmq-all-4.9.2/store/index
#checkpoint 文件存储路径
storeCheckpoint=/usr/local/rocketmq-all-4.9.2/store/checkpoint
#abort 文件存储路径
abortFile=/usr/local/rocketmq-all-4.9.2/store/abort
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER  异步复制Master
#- SYNC_MASTER  同步双写Master
#- SLAVE
brokerRole=ASYNC_MASTER
#刷盘方式
#- ASYNC_FLUSH  异步刷盘 #- SYNC_FLUSH  同步刷盘 flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false

cd /usr/local/rocketmq-all-4.9.2/distribution/conf/2m-noslave/
vim broker-b.properties

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#所属集群名字
brokerClusterName=rocketmq-cluster
#broker名字,注意此处不同的配置文件填写的不一样
#0 表示 Master,>0 表示 Slave 
brokerName=broker-b  
brokerId=0
#nameServer地址,分号分割
namesrvAddr=192.168.206.141:9876;192.168.206.142:9876
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭 
autoCreateTopicEnable=true
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭 
autoCreateSubscriptionGroup=true
#Broker 对外服务的监听端口
listenPort=10911
#删除文件时间点,默认凌晨 4点
deleteWhen=04
#文件保留时间,默认 48 小时
fileReservedTime=120
#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000 #destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/usr/local/rocketmq-all-4.9.2/store
#commitLog 存储路径
storePathCommitLog=/usr/local/rocketmq-all-4.9.2/store/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/usr/local/rocketmq-all-4.9.2/store/consumequeue
#消息索引存储路径
storePathIndex=/usr/local/rocketmq-all-4.9.2/store/index
#checkpoint 文件存储路径
storeCheckpoint=/usr/local/rocketmq-all-4.9.2/store/checkpoint
#abort 文件存储路径
abortFile=/usr/local/rocketmq-all-4.9.2/store/abort
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER  异步复制Master
#- SYNC_MASTER  同步双写Master
#- SLAVE
brokerRole=ASYNC_MASTER
#刷盘方式
#- ASYNC_FLUSH  异步刷盘 #- SYNC_FLUSH  同步刷盘 flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false

vim /usr/local/rocketmq-all-4.9.2/distribution/target/rocketmq-4.9.2/rocketmq-4.9.2/bin/runserver.sh

JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"

增加环境变量
export ROCKET_HOME=/usr/local/rocketmq-all-4.9.2/distribution/target/rocketmq-4.9.2/rocketmq-4.9.2
export PATH=$ROCKETMQ_HOME/bin:$PATH

启动

cd /usr/local/rocketmq-all-4.9.2/distribution/target/rocketmq-4.9.2/rocketmq-4.9.2/bin
nohup sh mqnamesrv &

修改配置:
vim /usr/local/rocketmq-all-4.9.2/distribution/target/rocketmq-4.9.2/rocketmq-4.9.2/bin/runbroker.sh

JAVA_OPT="${JAVA_OPT} -server -Xms215m -Xmx1g"

启动broker服务:nohup sh mqbroker &

关闭namesrv服务:sh mqshutdown namesrv
关闭broker服务 :sh mqshutdown broker

================================================================================================================
不用编码直接配置部署版。
直接下载bin 编译完成的包,无需maven编译

https://dlcdn.apache.org/rocketmq/4.9.2/rocketmq-all-4.9.2-bin-release.zip

posted @ 2021-12-09 10:39  倔强的老铁  阅读(180)  评论(0编辑  收藏  举报