当前位置: 代码迷 >> 综合 >> rocketmq linux注册服务开机启动
  详细解决方案

rocketmq linux注册服务开机启动

热度:89   发布时间:2023-10-17 16:15:30.0

 

cd /lib/systemd/system/

增加文件

vim nameserver.service

内容如下

[Unit]
Description=nameserver
After=network.target[Service]
Environment="JAVA_HOME=/root/java/jdk8-j9"
Type=forking
#alone
ExecStart=sh /root/java/rocketmq-all-4.8.0-bin-release/bin/mqnamesrv &ExecReload=sh /root/java/rocketmq-all-4.8.0-bin-release/bin/mqshutdown namesrv
ExecStop=sh /root/java/rocketmq-all-4.8.0-bin-release/bin/mqshutdown namesrv
PrivateTmp=true[Install]  
WantedBy=multi-user.target

 

重载
systemctl daemon-reload注册服务
systemctl enable nameserver.service启动
systemctl start nameserver.service或者
service nameserver start
service nameserver stop

vim broker.service

[Unit]
Description=broker
After=network.target[Service]
Environment="JAVA_HOME=/root/java/jdk8-j9"
Type=forking
#alone
ExecStart=sh /root/java/rocketmq-all-4.8.0-bin-release/bin/mqbroker -n localhost:9876 &ExecReload=sh /root/java/rocketmq-all-4.8.0-bin-release/bin/mqshutdown broker
ExecStop=sh /root/java/rocketmq-all-4.8.0-bin-release/bin/mqshutdown broker
PrivateTmp=true[Install]  
WantedBy=multi-user.target

 

重载
systemctl daemon-reload
 注册服务
systemctl enable broker.service
 启动
systemctl start broker.service或者
service broker start