1,编号启动脚本
vi /etc/rc.d/init.d/rabbitmq
内容如下
#!/bin/bash
#chkconfig:2345 61 61
export HOME=/home/rabbitmq/data/
export PATH=$PATH:/usr/local/erlang/bin
export PATH=$PATH:/usr/local/rabbitmq_server-3.8.5/sbin
case "$1" in
start)
echo "Starting RabbitMQ ..."
rabbitmq-server -detached
;;
stop)
echo "Stopping RabbitMQ ..."
rabbitmqctl stop
;;
status)
echo "Status RabbitMQ ..."
rabbitmqctl status
;;
restart)
echo "Restarting RabbitMQ ..."
rabbitmqctl stop
rabbitmq-server restart
;;
*)
echo "Usage: $prog {start|stop|status|restart}"
;;
esac
exit 0
2,配置权限
chmod +x /etc/rc.d/init.d/rabbitmq
3,注册启动项
chkconfig --add rabbitmq chkconfig rabbitmq on chkconfig --list rabbitmq #查看注册是否生效
4,启动服务
service rabbitmq start
|