centos 服务器设置开机自动启动服务。

发布时间:2020-04-14作者:laosun阅读(1844)

centos

centos 6.5 设置开机自动启动服务。比如MQ、Solr、java服务、redis等一系列的服务自动启动

    设置方式:

    [root@iZ8vbescrakld5c9jipn7lZ rc.d]# vim /etc/rc.d/rc.local

    设置内容具体如下:

    #!/bin/sh
    #
    # This script will be executed *after* all the other init scripts.
    # You can put your own initialization stuff in here if you don't
    # want to do the full Sys V style init stuff.
    
    touch /var/lock/subsys/local
    
    . /etc/profile
    
    # 下边是自定义内容
    
    # 启动 nginx 服务
    /usr/local/nginx/sbin/nginx
    # 启动 redis 服务
    redis-server /etc/XXXXX.conf
    # 启动 solr 服务
    /XXXXXXX/solr/bin/solr start -force
    # 启动 active mq 服务
    /XXXXX/mq/bin/activemq start
    
    # 停歇1秒
    sleep 1
    
    # 启动项目
    /usr/local/project/XXX/XXX.sh start
    /usr/local/project/XX/XX.sh start
    
    
    # 启动jenkins服务
    /etc/init.d/jenkins start

    其实设置相当的简单,就是将你需要启动的服务,按照顺序添加到该文件中即可。

    该方法博主已经测试过,没有问题。


2 +1

版权声明

 linux  centos

 请文明留言

0 条评论