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的配置。

参考

相关推荐
懒洋洋大魔王9 小时前
RocketMQ的使⽤
java·rocketmq·java-rocketmq
chudaxiakkk1 天前
记录spring-boot 3.X版本整合RocketMq
java·spring boot·rocketmq
dvlinker4 天前
大数据技术Kafka详解 ① | 消息队列(Messages Queue)
大数据·kafka·rabbitmq·rocketmq·activemq·分布式发布订阅消息系统·messages queue
Jeff-Jiang9 天前
Kafka、RabbitMQ、RocketMQ对比
kafka·rabbitmq·rocketmq
Yweir11 天前
SpringCloud 微服务消息队列灰度方案 (RocketMQ 4.x)
spring cloud·微服务·rocketmq
晓琴儿12 天前
C++使用开源ConcurrentQueue库处理自定义业务数据类
c++·rocketmq·信息与通信·concurrentqueue
不想睡觉的橘子君16 天前
【MQ】RabbitMQ、RocketMQ、kafka特性对比
kafka·rabbitmq·rocketmq
厌世小晨宇yu.17 天前
RocketMQ学习笔记
笔记·学习·rocketmq
洛卡卡了18 天前
如何选择最适合的消息队列?详解 Kafka、RocketMQ、RabbitMQ 的使用场景
kafka·rabbitmq·rocketmq
菜鸟起航ing19 天前
Spring Cloud Alibaba
spring cloud·java-ee·rocketmq