将此脚本放到/etc/init.d/ 并赋予可执行权限即可
注意 需要将java 及 mq安装目录改成你自己的
管理mqbroker
#/bin/bash #author:firxiao #data:20140917 #usage manage RocketMQ mqbroker # chkconfig: - 99 90 pid=`ps ax | grep -i ‘com.alibaba.rocketmq.broker.BrokerStartup‘ |grep java | grep -v grep | awk ‘{print $1}‘` ##mq安装位置## MQ_HOME=/opt/alibaba-rocketmq/bin ##java目录## export JAVA_HOME=/opt/jdk ##log位置## LOG_DIR=/var/log function start() { if [ -n "$pid" ]; then { echo "The mqbroker(${pid}) is running..." } else { cd $MQ_HOME ; nohup sh mqbroker > $LOG_DIR/mqbroker.log 2>&1 & echo $" mqbroker started logfile=$LOG_DIR/mqbroker.log" } fi } function stop() { if [ -z "$pid" ] ; then echo "No mqbroker running." exit -1; fi echo "The mqbroker(${pid}) is running..." kill ${pid} echo "Send shutdown request to mqbroker(${pid}) OK" } function status() { if [ -z "$pid" ] ; then echo "No mqbroker running." exit -1; fi echo "The mqbroker(${pid}) is running..." } case $1 in start) start ;; stop) stop ;; status) status
添加开机启动
#chkconfig --add /etc/init.d/mqbroker #chkconfig mqbroker on
时间: 2024-12-14 22:05:11