目 录CONTENT

文章目录

CentOS7-安装RocketMQ

javalx
2023-03-03 / 0 评论 / 0 点赞 / 116 阅读 / 0 字

下载

下载二进制包

https://rocketmq.apache.org/zh/download

![](https://javalx-1304327366.cos.ap-beijing.myqcloud.com/typora_img/scrnli_2023_4_20 16-39-24.png)

[root@localhost home]# wget https://archive.apache.org/dist/rocketmq/4.9.4/rocketmq-all-4.9.4-bin-release.zip

解压&改名

[root@localhost home]# unzip rocketmq-all-4.9.4-bin-release.zip 
[root@localhost home]# mv rocketmq-all-4.9.4-bin-release rocketmq

修改配置

修改conf/broker.conf

[root@localhost home]# cd rocketmq
[root@localhost rocketmq]# cd conf
[root@localhost conf]# vim broker.conf
#追加内容如下
brokerIP1=192.168.18.100
listenPort=10911
namesrvAddr=localhost:9876
storePathRootDir=/home/rocketmq/store
storePathCommitLog=/home/rocketmq/store/commitlog
storePathConsumerQueue=/home/rocketmq/store/consumequeue
# 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 = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH

brokerIP1=192.168.18.100
listenPort=10911
namesrvAddr=localhost:9876
storePathRootDir=/home/rocketmq/store
storePathCommitLog=/home/rocketmq/store/commitlog
storePathConsumerQueue=/home/rocketmq/store/consumequeue

修改bin/runserver.sh

[root@localhost home]# cd rocketmq
[root@localhost rocketmq]# cd bin
[root@localhost bin]# vim runserver.sh

![](https://javalx-1304327366.cos.ap-beijing.myqcloud.com/typora_img/scrnli_2023_4_20 16-58-55.png)

修改bin/runbroker.sh

[root@localhost home]# cd rocketmq
[root@localhost rocketmq]# cd bin
[root@localhost bin]# vim runbroker.sh

![](https://javalx-1304327366.cos.ap-beijing.myqcloud.com/typora_img/scrnli_2023_4_20 17-06-39.png)

打开端口

# nameserver端口
firewall-cmd --zone=public --add-port=9876/tcp --permanent
# broker端口
firewall-cmd --zone=public --add-port=10911/tcp --permanent
# 更新防火墙规则
firewall-cmd --reload
# 查看防火墙所有开放的端口
firewall-cmd --list-port

启动服务

启动nameserver

[root@localhost rocketmq]# cd bin
[root@localhost bin]# nohup sh mqnamesrv &
[1] 50225
[root@localhost bin]# nohup: 忽略输入并把输出追加到"nohup.out"
# 查看日志
[root@localhost bin]# cat /root/logs/rocketmqlogs/namesrv.log

![](https://javalx-1304327366.cos.ap-beijing.myqcloud.com/typora_img/scrnli_2023_4_20 17-26-28.png)

启动broker

[root@localhost rocketmq]# cd bin
[root@localhost bin]# nohup sh mqbroker -c /home/rocketmq/conf/broker.conf &
[2] 55313
[root@localhost bin]# nohup: 忽略输入并把输出追加到"nohup.out"  
# 查看日志
[root@localhost bin]# cat /root/logs/rocketmqlogs/broker.log 

![](https://javalx-1304327366.cos.ap-beijing.myqcloud.com/typora_img/scrnli_2023_4_20 17-22-06.png)

关闭服务

关闭broker

[root@localhost rocketmq]# cd bin
[root@localhost bin]# sh mqshutdown broker

关闭nameserver

[root@localhost rocketmq]# cd bin
[root@localhost bin]# sh mqshutdown namesrv
0

评论区