• -------------------------------------------------------------
  • ====================================

CentOS 7.9下RocketMQ 4.9安装和配置手册

技能 dewbay 2年前 (2022-11-01) 2669次浏览 已收录 0个评论 扫描二维码

1. 安装前的准备
1.1 安装环境
1.1.1 操作系统内核版本
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

1.1.2 操作系统发行版本
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

1.2 安装文件
1.2.1 安装文件下载
官网地址: http://rocketmq.apache.org/
下载地址: http://rocketmq.apache.org/dowloading/releases/
1.2.2 安装文件列表
rocketmq-all-4.9.1-bin-release.zip
2. 安装和配置
2.1 软件安装
2.1.1 安装前的检测
检测软件是否已安装
[root@localhost ~]# rpm -qa | grep rocketmq

查看运行进程
[root@localhost ~]# ps -ef | grep rocketmq
root 47876 46534 0 07:57 pts/1 00:00:00 grep rocketmq

卸载软件文件
[root@localhost ~]# rpm -e mongodb-database-tools-100.5.0-1.x86_64 –nodeps

2.1.2 安装RocketMQ
切换至软件目录;
[root@localhost ~]# cd /home/Software/RocketMQ
[root@localhost RocketMQ]# ls
rocketmq-all-4.9.1-bin-release.zip

解压缩“rocketmq-all-4.9.1-bin-release.zip”;
[root@localhost RocketMQ]# unzip rocketmq-all-4.9.1-bin-release.zip
Archive: rocketmq-all-4.9.1-bin-release.zip
creating: rocketmq-all-4.9.1-bin-release/
creating: rocketmq-all-4.9.1-bin-release/benchmark/

inflating: rocketmq-all-4.9.1-bin-release/conf/plain_acl.yml
inflating: rocketmq-all-4.9.1-bin-release/conf/logback_namesrv.xml
[root@localhost RocketMQ]# ls
rocketmq-all-4.9.1-bin-release rocketmq-all-4.9.1-bin-release.zip
[root@localhost RocketMQ]# mv rocketmq-all-4.9.1-bin-release /opt/
[root@localhost RocketMQ]# cd /opt/
[root@localhost opt]# ls
rocketmq-all-4.9.1-bin-release

启动数据库服务
由于 RocketMQ 初始化部分参数并不适用于实际项目,故先完成部分初始化配置。

2.2 软件配置
2.2.1 修改 Name Server 默认内存
[root@localhost ~]# cd /opt/rocketmq-all-4.9.1-bin-release/
[root@localhost rocketmq-all-4.9.1-bin-release]# vim ./bin/runserver.sh

# 修改前
JAVA_OPT=”${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m”

# 修改后
JAVA_OPT=”${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m”

2.2.2 修改 Broker 默认内存
[root@localhost ~]# cd /opt/rocketmq-all-4.9.1-bin-release/
[root@localhost rocketmq-all-4.9.1-bin-release]# vim ./bin/runbroker.sh

# 修改前
JAVA_OPT=”${JAVA_OPT} -server -Xms8g -Xmx8g”

# 修改后
JAVA_OPT=”${JAVA_OPT} -server -Xms512m -Xmx512m”

3. 启动和验证
3.1 软件启动
3.1.1 启动 Name Server
启动 Name Server;
[root@localhost ~]# cd /opt/rocketmq-all-4.9.1-bin-release/
[root@localhost rocketmq-all-4.9.1-bin-release]# nohup sh bin/mqnamesrv &
[1] 16182
[root@localhost rocketmq-all-4.9.1-bin-release]# nohup: ignoring input and appending output to ‘nohup.out’

按下“Enter”键;

打印日志。

[root@SHIEP rocketmq-all-4.9.1-bin-release]# tail -f ~/logs/rocketmqlogs/namesrv.log
2021-09-26 16:41:00 INFO main – tls.client.keyPassword = null
2021-09-26 16:41:00 INFO main – tls.client.certPath = null
2021-09-26 16:41:00 INFO main – tls.client.authServer = false
2021-09-26 16:41:00 INFO main – tls.client.trustCertPath = null
2021-09-26 16:41:00 INFO main – Using JDK SSL provider
2021-09-26 16:41:01 INFO main – SSLContext created for server
2021-09-26 16:41:01 INFO main – Try to start service thread:FileWatchService started:false lastThread:null
2021-09-26 16:41:01 INFO NettyEventExecutor – NettyEventExecutor service started
2021-09-26 16:41:01 INFO FileWatchService – FileWatchService service started
2021-09-26 16:41:01 INFO main – The Name Server boot success. serializeType=JSON

3.1.2 启动 Broker
启动 Broker;
[root@localhost rocketmq-all-4.9.1-bin-release]# nohup sh bin/mqbroker -n localhost:9876 autoCreateTopicEnable=true &
[2] 16571
[root@localhost rocketmq-all-4.9.1-bin-release]# nohup: ignoring input and appending output to ‘nohup.out’

按下“Enter”键;

打印日志。

[root@localhost rocketmq-all-4.9.1-bin-release]# tail -f ~/logs/rocketmqlogs/broker.log
2021-09-26 16:43:37 INFO BrokerControllerScheduledThread1 – Slave fall behind master: 0 bytes
2021-09-26 16:43:37 INFO brokerOutApi_thread_2 – register broker[0]to name server localhost:9876 OK
2021-09-26 16:43:38 ERROR DiskCheckScheduledThread1 – Error when measuring disk space usage, file doesn’t exist on this path: /root/store/commitlog
2021-09-26 16:43:48 ERROR DiskCheckScheduledThread1 – Error when measuring disk space usage, file doesn’t exist on this path: /root/store/commitlog
2021-09-26 16:43:58 ERROR DiskCheckScheduledThread1 – Error when measuring disk space usage, file doesn’t exist on this path: /root/store/commitlog
2021-09-26 16:44:07 INFO brokerOutApi_thread_3 – register broker[0]to name server localhost:9876 OK
2021-09-26 16:44:08 ERROR DiskCheckScheduledThread1 – Error when measuring disk space usage, file doesn’t exist on this path: /root/store/commitlog
2021-09-26 16:44:18 ERROR DiskCheckScheduledThread1 – Error when measuring disk space usage, file doesn’t exist on this path: /root/store/commitlog
2021-09-26 16:44:27 ERROR StoreScheduledThread1 – Error when measuring disk space usage, file doesn’t exist on this path: /root/store/commitlog
2021-09-26 16:44:28 ERROR DiskCheckScheduledThread1 – Error when measuring disk space usage, file doesn’t exist on this path: /root/store/commitlog

3.2 软件验证
3.2.1 查看软件版本
3.2.2 查看运行状态
[root@localhost ~]# cd /opt/rocketmq-all-4.9.1-bin-release/
[root@localhost rocketmq-all-4.9.1-bin-release]# ss -antulp |grep 9876
tcp LISTEN 0 128 [::]:9876 [::]:* users:((“java”,pid=16242,fd=81))

3.2.3 发送测试消息
[root@localhost ~]# cd /opt/rocketmq-all-4.9.1-bin-release/
[root@localhost rocketmq-all-4.9.1-bin-release]# export NAMESRV_ADDR=localhost:9876
[root@localhost rocketmq-all-4.9.1-bin-release]# sh bin/tools.sh
org.apache.rocketmq.example.quickstart.Producer
SendResult [sendStatus=SEND_OK, msgId= …

3.2.4 接收测试消息
[root@localhost ~]# cd /opt/rocketmq-all-4.9.1-bin-release/
[root@localhost rocketmq-all-4.9.1-bin-release]# export NAMESRV_ADDR=localhost:9876
[root@localhost rocketmq-all-4.9.1-bin-release]# sh bin/tools.sh
org.apache.rocketmq.example.quickstart.Consumer
ConsumeMessageThread_%d Receive New Messages: [MessageExt

4. 停止和卸载
4.1 软件停止
4.1.1 停止 Broker
[root@localhost ~]# cd /opt/rocketmq-all-4.9.1-bin-release/
[root@localhost rocketmq-all-4.9.1-bin-release]# sh bin/mqshutdown broker
No mqbroker running.

4.1.2 停止 Name Server
[root@localhost rocketmq-all-4.9.1-bin-release]# sh bin/mqshutdown namesrv
The mqnamesrv(51043) is running…
Send shutdown request to mqnamesrv(51043) OK

4.2 软件卸载
停止 Broker、Name Server(略)

直接删除文件夹即可。

5. 安装目录和核心文件
5.1 安装目录
[root@localhost ~]# cd /opt/rocketmq-all-4.9.1-bin-release/
[root@localhost rocketmq-all-4.9.1-bin-release]# ls
benchmark bin conf lib LICENSE nohup.out NOTICE README.md

5.2 执行文件
[root@localhost ~]# cd /opt/rocketmq-all-4.9.1-bin-release/bin/
[root@localhost bin]# ls
cachedog.sh cleancache.v1.sh mqadmin mqbroker mqbroker.numanode0 mqbroker.numanode2 mqnamesrv mqshutdown os.sh play.sh runbroker.cmd runserver.cmd setcache.sh tools.cmd
cleancache.sh dledger mqadmin.cmd mqbroker.cmd mqbroker.numanode1 mqbroker.numanode3 mqnamesrv.cmd mqshutdown.cmd play.cmd README.md runbroker.sh runserver.sh startfsrv.sh tools.sh

5.3 配置文件
[root@localhost ~]# cd /opt/rocketmq-all-4.9.1-bin-release/conf/
[root@localhost conf]# ls
2m-2s-async 2m-2s-sync 2m-noslave broker.conf dledger logback_broker.xml logback_namesrv.xml logback_tools.xml plain_acl.yml tools.yml

5.4 日志文件
错误日志文件
[root@localhost ~]# cd /opt/rocketmq-all-4.9.1-bin-release/
[root@localhost rocketmq-all-4.9.1-bin-release]# vim ./bin/nohup.out

Name Server 日志文件
[root@localhost ~]# tail -f ~/logs/rocketmqlogs/namesrv.log

Broker 日志文件
[root@localhost ~]# tail -f ~/logs/rocketmqlogs/broker.log

6. 常见问题
6.1 启动 Broker 时,打印日志提示“cannot open `/root/logs/rocketmqlogs/broker.log’ for reading: No such file or directory”
问题原因:启动 Broker 服务时,由于默认内存设置过大,造成 Broker 服务无法正常 启动,查看/%ROCKERMQ%/nohup.out 查看具体错误日志:

Java HotSpot(TM) 64-Bit Server VM warning: INFO:
os::commit_memory(0x00000005c0000000, 8589934592, 0) failed; error=’Cannot allocate
memory’ (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 8589934592 bytes for committing
reserved memory.
# An error report file with more information is saved as:
# /home/Hehuang/SHIOT-1/SERVICE-1/rocketmq-all-4.9.1-binrelease/hs_err_pid51750.log

解决方案:修改 Broker 默认内存,具体参考 2.2.1【修改 Broker 默认内存】。

6.2 启动 Name Server 或 Broker 时,提示“[1]+ Exit 1 nohup sh bin/…”
问题原因:说明 Name Server 或 Broker 服务未正常启动。

解决方案:查看/%ROCKERMQ%/nohup.out 查看具体错误日志。


露水湾 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:CentOS 7.9下RocketMQ 4.9安装和配置手册
喜欢 (2)
[]
分享 (0)
关于作者:
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址