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

参考

相关推荐
RemainderTime5 天前
(七)Spring Cloud Alibaba 2023.x:RocketMQ 消息队列配置与实现
后端·spring cloud·微服务·rocketmq
你啊我啊你好6 天前
常用的消息中间件(ActiveMQ、RabbitMQ、RocketMQ、Kafka)面试精华
rabbitmq·rocketmq·activemq
Hello-Brand6 天前
RocketMQ系列3:核心技术介绍
消息队列·rabbitmq·rocketmq·mq·消息中间件·削峰填谷
_BugMan7 天前
【业务场景】订单超时取消的各种方案
redis·java-ee·rocketmq
Ch.yang11 天前
【架构】从 Socket 的角度认识非阻塞模型
tomcat·rocketmq
码农老起11 天前
从RocketMQ到Dubbo:自研中间件技术的崛起
中间件·dubbo·rocketmq
Steven_Mmm13 天前
关于消息队列性能是否能接收 5 万个 MQ
kafka·rocketmq
小范馆13 天前
RocketMQ面试题合集
java·rocketmq·java-rocketmq
菜菜-plus13 天前
Kafka | RabbitMQ | RocketMQ | ActiveMQ 的区别和入门案例
kafka·rabbitmq·rocketmq
Hello-Brand17 天前
RocketMQ系列2:领域模型和技术概念
消息队列·rocketmq·消息中间件