RocketMQ SysV方式安装单机版

问题

由于甲方预算有限,需要手动在linux上面安装RocketMQ单机版,(嗯,单机版,你没听错)

步骤

添加用户和用户组

bash 复制代码
sudo useradd --system --home /usr/local/rocketmq --shell /sbin/nologin --comment "rocketmq user" --user-group rocketmq

手动安装RocketMQ二进制包

bash 复制代码
# 下载二进制安装包
wget https://dist.apache.org/repos/dist/release/rocketmq/5.2.0/rocketmq-all-5.2.0-bin-release.zip
# 解压到/usr/local/ 目录下面
sudo unzip -d /usr/local/ rocketmq-all-5.2.0-bin-release.zip
# 修改解压文件夹名称为rocketmq
sudo mv /usr/local/rocketmq-all-5.2.0-bin-release/ /usr/local/rocketmq/
# 修改安装目录文件夹与文件权限
# 授权文件夹拥有者为rocketmq用户
sudo chown -R rocketmq /usr/local/rocketmq
# 授权文件夹用户组为rocketmq
sudo chgrp -R rocketmq /usr/local/rocketmq

SysV 配置文件

新建nameserver配置文件:

bash 复制代码
sudo vim /usr/lib/systemd/system/rocketmq.service

内容:

bash 复制代码
[Unit]
Description=RocketMQ 5.2.0 - nameserver
After=network.target
[Service]
User=rocketmq
Group=rocketmq
Type=simple
ExecStart=/usr/local/rocketmq/bin/mqnamesrv
ExecStop=/usr/local/rocketmq/bin/mqshutdown namesrv

[Install]
WantedBy=multi-user.target

新建Broker+Proxy配置文件:

bash 复制代码
sudo vim /usr/lib/systemd/system/mqbroker.service

内容:

bash 复制代码
[Unit]
Description=RocketMQ 5.2.0 - Broker+Proxy
After=network.target
[Service]
User=rocketmq
Group=rocketmq
Type=simple
ExecStart=/usr/local/rocketmq/bin/mqbroker -n localhost:9876 --enable-proxy
ExecStop=/usr/local/rocketmq/bin/mqshutdown broker

[Install]
WantedBy=multi-user.target

重载SysV配置:

bash 复制代码
sudo systemctl daemon-reload

安装Java

bash 复制代码
sudo dnf install java-17-amazon-corretto

启动nameserver服务

bash 复制代码
sudo systemctl start rocketmq.service

查看启动状态:

bash 复制代码
sudo systemctl status rocketmq.service

启动状态如下:

bash 复制代码
● rocketmq.service - RocketMQ 5.2.0 - nameserver
     Loaded: loaded (/usr/lib/systemd/system/rocketmq.service; disabled; preset: disabled)
     Active: active (running) since Fri 2024-03-29 10:10:58 UTC; 3s ago
   Main PID: 81442 (mqnamesrv)
      Tasks: 39 (limit: 18641)
     Memory: 180.7M
        CPU: 4.906s
     CGroup: /system.slice/rocketmq.service
             ├─81442 /bin/sh /usr/local/rocketmq/bin/mqnamesrv
             ├─81446 sh /usr/local/rocketmq/bin/runserver.sh -Drmq.logback.configurationFile=/usr/local/rocketmq/conf/rmq.namesrv.logback.xml org.apache.rocketmq.namesrv.NamesrvStartup
             └─81475 /bin/java -server -Xms4g -Xmx4g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRef>

Mar 29 10:10:58 ip-172-34-131-187.ec2.internal systemd[1]: Started rocketmq.service - RocketMQ 5.2.0 - nameserver.
Mar 29 10:10:58 ip-172-34-131-187.ec2.internal mqnamesrv[81451]: which: no javac in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)
Mar 29 10:10:58 ip-172-34-131-187.ec2.internal mqnamesrv[81450]: readlink: missing operand
Mar 29 10:10:58 ip-172-34-131-187.ec2.internal mqnamesrv[81450]: Try 'readlink --help' for more information.
Mar 29 10:10:58 ip-172-34-131-187.ec2.internal mqnamesrv[81449]: dirname: missing operand
Mar 29 10:10:58 ip-172-34-131-187.ec2.internal mqnamesrv[81449]: Try 'dirname --help' for more information.
Mar 29 10:10:58 ip-172-34-131-187.ec2.internal mqnamesrv[81448]: dirname: missing operand
Mar 29 10:10:58 ip-172-34-131-187.ec2.internal mqnamesrv[81448]: Try 'dirname --help' for more information.
Mar 29 10:11:00 ip-172-34-131-187.ec2.internal mqnamesrv[81475]: The Name Server boot success. serializeType=JSON, address 0.0.0.0:9876

启动Broker+Proxy服务

bash 复制代码
sudo systemctl start mqbroker.service

总结

生产环境千万别这样玩,这是个单机版。主要是演示SysV的配置。

参考

相关推荐
小白的一叶扁舟4 小时前
Kafka 入门与应用实战:吞吐量优化与与 RabbitMQ、RocketMQ 的对比
java·spring boot·kafka·rabbitmq·rocketmq
weisian1516 小时前
消息队列篇--原理篇--RocketMQ和Kafka对比分析
分布式·kafka·rocketmq
东阳马生架构1 天前
RocketMQ原理—2.源码设计简单分析上
rocketmq
哭哭啼1 天前
rocketmq dashboard 安装
java·rocketmq·java-rocketmq
东阳马生架构3 天前
RocketMQ原理—1.RocketMQ整体运行原理
rocketmq
小虾米 ~4 天前
rocketmq基本架构
rocketmq
web150854159354 天前
从零到一:Spring Boot 与 RocketMQ 的完美集成指南
spring boot·rocketmq·java-rocketmq
续亮~5 天前
RocketMQ 学习笔记01
笔记·学习·rocketmq
简单的东西为什么越来越复杂5 天前
RocketMQ 安装使用
后端·面试·rocketmq
喵王叭8 天前
RocketMQ 知识速览
rocketmq