RabbitMq自启动

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

RabbitMq自启动

chester.chen   2022-05-24 我要评论

1.在/etc/init.d 目录下新建一个 rabbitmq

[root@localhost init.d]# vi rabbitmq

文件内容

#!/bin/bash
#chkconfig:2345 61 61

export HOME=/opt/data/rabbitmq/
export PATH=$PATH:/usr/local/erlang/bin
export PATH=$PATH:/usr/local/src/rabbitmq_server-3.6.15/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.对rabbitmq授予可执行权限

[root@localhost init.d]# chmod 777 rabbitmq

3. 添加rabbitmq服务到系统服务中

[root@localhost init.d]# chkconfig --add rabbitmq

4.设置自启动

[root@localhost init.d]# chkconfig rabbitmq on

5.查看自启动项是否设置成功

[root@localhost init.d]# chkconfig --list rabbitmq

6.开启rabbit服务

[root@localhost init.d]# ./rabbitmq start

 7.测试开机重启

[root@localhost init.d]#reboot
[root@localhost ~]# ps -elf|grep rabbitmq

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们