1:/etc/init.d/下建立rabbitmq文件
vim rabbitmq(代码如下)
#!/bin/bash # # chkconfig: 2345 80 05 # description: rabbitmq # processname: rabbitmq #RabbitMQ安装目录 RABBITMQ_HOME=/usr/lib/rabbitmq export RABBITMQ_HOME case "$1" in start) echo "Starting RabbitMQ ..." cd $RABBIT_HOME/sbin rabbitmq-server ;; stop) echo "Stopping RabbitMQ ..." cd $RABBIT_HOME/sbin rabbitmqctl stop ;; status) echo "Status RabbitMQ ..." cd $RABBIT_HOME/sbin rabbitmqctl status ;; restart) echo "Restarting RabbitMQ ..." cd $RABBIT_HOME/sbin rabbitmq-server ;; *) echo "Usage: $prog {start|stop|status|restart}" ;; esac exit 0
2:对rabbitmq授予可执行权限
chmod 777 rabbitmq
3:添加rabbitmq服务到系统服务中
chkconfig --add rabbitmq
4:设置开机启动
chkconfig rabbitmq on