rabbitmq添加自启动 centos7环境

rabbitmq添加自启动 centos7环境
强烈推介IDEA2021.1.3破解激活,IntelliJ IDEA 注册码,2021.1.3IDEA 激活码  

大家好,我是架构君,一个会写代码吟诗的架构师。今天说一说rabbitmq添加自启动 centos7环境,希望能够帮助大家进步!!!

1.编辑一个启动脚本

1

[root@xxx ~]# vim /usr/local/rabbitmq/sbin/start_rabbitmq.sh

 内容如下(根据自己的实际位置做替换即可)

1

2

3

4

5

#!/bin/bash

 

export PATH=$PATH:/usr/local/erlang/bin

export HOME=/usr/local/rabbitmq/

/usr/local/rabbitmq/sbin/./rabbitmq-server -detached

  这里面需要指定erlang的环境变量,erlang的安装路径(erlang如何安装可以参考我的上一篇rabbitmq安装的文章)

2.给脚本增加可执行权限

1

chmod +x /usr/local/rabbitmq/sbin/start_rabbitmq.sh

3.编辑 /etc/rc.d/rc.local

1

vim /etc/rc.d/rc.local

 增加第一步创建的脚本

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

#!/bin/bash

# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES

#

# It is highly advisable to create own systemd services or udev rules

# to run scripts during boot instead of using this file.

#

# In contrast to previous versions due to parallel execution during boot

# this script will NOT be run after all other services.

#

# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure

# that this script will be executed during boot.

 

touch /var/lock/subsys/local

#这里是要执行我们的启动脚本

/usr/local/rabbitmq/sbin/start_rabbitmq.sh

然后需要给rc.local增加可执行权限

1

chmod +x /etc/rc.d/rc.local

最后重启linux系统看是否生效

1

shutdown -r now

本文来源huayang183,由架构君转载发布,观点不代表Java架构师必看的立场,转载请标明来源出处:https://javajgs.com/archives/17902

发表评论