本文主要是介绍RocketMQ SysV方式安装单机版,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题
由于甲方预算有限,需要手动在linux上面安装RocketMQ单机版,(嗯,单机版,你没听错)
步骤
添加用户和用户组
sudo useradd --system --home /usr/local/rocketmq --shell /sbin/nologin --comment "rocketmq user" --user-group rocketmq
手动安装RocketMQ二进制包
# 下载二进制安装包
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配置文件:
sudo vim /usr/lib/systemd/system/rocketmq.service
内容:
[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配置文件:
sudo vim /usr/lib/systemd/system/mqbroker.service
内容:
[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配置:
sudo systemctl daemon-reload
安装Java
sudo dnf install java-17-amazon-corretto
启动nameserver服务
sudo systemctl start rocketmq.service
查看启动状态:
sudo systemctl status rocketmq.service
启动状态如下:
● rocketmq.service - RocketMQ 5.2.0 - nameserverLoaded: loaded (/usr/lib/systemd/system/rocketmq.service; disabled; preset: disabled)Active: active (running) since Fri 2024-03-29 10:10:58 UTC; 3s agoMain PID: 81442 (mqnamesrv)Tasks: 39 (limit: 18641)Memory: 180.7MCPU: 4.906sCGroup: /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服务
sudo systemctl start mqbroker.service
总结
生产环境千万别这样玩,这是个单机版。主要是演示SysV的配置。
参考
- unzip:unzip解压文件到指定目录
- Amazon Linux 2 AMI安装Nginx
- 快速开始
- jahio/stop.sh
这篇关于RocketMQ SysV方式安装单机版的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!