Put the script in/etc/init. d/and grant the executable permission.
Note that you need to change the Java and MQ installation directory to your own
Manage mqbroker
#/Bin/bash # Author: firxiao # data: 20140917 # usage manage rocketmq mqbroker # chkconfig:-99 90pid = 'ps ax | grep-I 'COM. alibaba. rocketmq. broker. brokerstartup '| grep Java | grep-V grep | awk' {print $1} ''# MQ installation location # mq_home =/opt/Alibaba-rocketmq/bin # Java directory # export java_home =/opt/JDK # log location # log_dir =/var/logfunction 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 instart) Start; stop) Stop; Status) Status
Add boot start
#chkconfig --add /etc/init.d/mqbroker#chkconfig mqbroker on
Rockermq service management script (centos)