• Centos7中加入开机自启动常见的方法(nginx、redis、activemq、mycat)


    nginx加入开机启动

    cat <<EOF >> /etc/systemd/system/nginx.service
    > [Unit]
    > Description=nginx - high performance web server
    > After=network.target remote-fs.target nss-lookup.target
    > 
    > [Service]
    > Type=forking
    > ExecStart=$NGINX_HOME/sbin/nginx -c $NGINX_HOME/conf/nginx.conf
    > ExecReload=$NGINX_HOME/sbin/nginx -s reload
    > ExecStop=$NGINX_HOME/sbin/nginx -s stop
    > 
    > [Install]
    > WantedBy=multi-user.target
    > EOF
    
    systemctl daemon-reload
    
    systemctl start nginx
    
    systemctl enable nginx

    redis加入开机启动

    cat << EOF >> /etc/systemd/system/redis.service
    > [Unit]
    > Description=Redis Server Manager
    > After=syslog.target
    > After=network.target
    > 
    > [Service]
    > Type=forking
    > PIDFile=/home/redis4.0.9/redis_6379.pid
    > ExecStart=/home/redis4.0.9/src/redis-server /home/redis4.0.9/redis.conf
    > ExecStop=/home/redis4.0.9/src/redis-cli shutdown
    > Restart=always
    > 
    > [Install]
    > WantedBy=multi-user.target
    > EOF
    
    systemctl daemon-reload
    
    systemctl start redis
    
    systemctl enable redis

     activemq加入开机启动项

    cat << EOF >> /etc/init.d/activemq
    > #!/bin/sh
    > # /etc/init.d/activemq
    > # chkconfig: 345 63 37
    > # description: activemq servlet container.
    > # processname: activemq 5.9.1
    >  
    > # Source function library.
    > #. /etc/init.d/functions
    > # source networking configuration.
    > #. /etc/sysconfig/network
    > 
    > export JAVA_HOME=/home/.jdk1.8
    > export CATALINA_HOME=/home/activemq5.9.1
    >  
    > case $1 in
    >     start)
    >         sh $CATALINA_HOME/bin/activemq start
    >     ;;
    >     stop)
    >         sh $CATALINA_HOME/bin/activemq stop
    >     ;;
    >     restart)
    >         sh $CATALINA_HOME/bin/activemq stop
    >         sleep 1
    >         sh $CATALINA_HOME/bin/activemq start
    >     ;;
    >  
    > esac
    > exit 0
    > EOF
    
    chmod +x /etc/init.d/activemq
    chkconfig  --add activemq
    chkconfig --list

     mycat加入开机启动

    cat << EOF >> /etc/init.d/mycat
    > #!/bin/sh
    > # /etc/init.d/mycat
    > # chkconfig: 345 63 37
    > # description: mycat servlet container.
    > # processname: mycat
    > 
    > # Source function library.
    > #. /etc/init.d/functions
    > # source networking configuration.
    > #. /etc/sysconfig/network
    > 
    > export JAVA_HOME=/home/.jdk1.8
    > export CATALINA_HOME=/home/mycat
    > 
    > case $1 in
    >     start)
    >         sh $CATALINA_HOME/bin/mycat start
    >     ;;
    >     stop)
    >         sh $CATALINA_HOME/bin/mycat stop
    >     ;;
    >     restart)
    >         sh $CATALINA_HOME/bin/mycat restart
    >     ;;
    > 
    > esac
    > exit 0
    > EOF
    
    chmod +x /etc/init.d/mycat
    chkconfig --add mycat
    chkconfig --list
  • 相关阅读:
    类定义(课下选做)
    结对项目第一周
    迭代和JDB
    JAVA 第五周学习总结
    JAVA 第四周学习总结
    JAVA 第三周学习总结
    springcloud-provider-consumer-register
    springcloud-eureka
    springBoot-打包
    spring-Scheduler
  • 原文地址:https://www.cnblogs.com/LAlexH/p/12015389.html
Copyright © 2020-2023  润新知