zoukankan      html  css  js  c++  java
  • Linux 服务器 mysql,tomcat,Nginx 开机自启动

    基于Linux 的服务器开发自启动,有三种方式实现:

    一. 使用定时任务 cron 命令

     创建定时任务来运行 .sh 脚本。在shell 脚本中编写nginx,mysql 等的启动脚本。

    二. Linux使用supervisor 来管理进程

    supervisor:C/S架构的进程控制系统,可使用户在类UNIX系统中监控、管理进程。常用于管理与某个用户或项目相关的进程。 

    组成部分
    supervisord:服务守护进程
    supervisorctl:命令行客户端
    Web Server:提供与supervisorctl功能相当的WEB操作界面
    XML-RPC Interface:XML-RPC接口

    supervisor 安装,基本配置详细步骤:  https://www.cnblogs.com/miskis/p/6026452.html

    1. 安装 supervisor 程序。
    2. 配置 supervisor 配置文件。
    3. supervisor 开机自启动。

    supervisor 配置文件 Nginx,tomcat等,可以参照 https://blog.csdn.net/xieliaowa9231/article/details/79077873 实现

    三. 使用Linux 服务器自带的 service 自动启动服务。

    Linux 常用的发行版本:Redhat 系列 (如Centos) 和 Debian系列(如debina  和 Ubuntu) 等。具体可百度 Linux版本

    Linux 系统service 启动的服务命令因 Linux 版本不同而不同。

    1. Linux 系统进程保存路径:/etc/init.d ,这个目录下保存用service 来操作的服务。
    2. 编写Nginx,tomcat,mysql 等 shell 脚本,将这些脚本放入/etc/init.d 路径下。
    3. 将脚本加入自启动进程。Redhat 系如 centos 系统中使用命令 chkconfig,debina 系如 Ubuntu 系统中使用命令 sysv-rc-conf

    Redhat 系列相关配置,请查看 https://www.cnblogs.com/zmfly/p/6049402.html  或 https://www.jb51.net/article/94181.htm

    Debian系列相关配置,请查看 https://www.cnblogs.com/linguoguo/p/5484589.html

    四. 修改 /etc/rc.local  此文件。

    在 /etc/rc.local 中 添加如下一行 

    /opt/apache-tomcat-7.0.29/bin/startup.sh    ---软件的启动脚本的路径。

    (脚本绝对路径) 
    注意:要添加在exit 0上边,reboot试试。 

    你好,茶杯
  • 相关阅读:
    2021.8.2—2021.8.8
    2021.7.29
    2021.7.27
    2021.7.26
    GC日志分析
    学习类加载机制笔记
    4、SpringCloud停更说明
    3、SpringCloudAlibaba版本选择
    京东、阿里的微服务架构
    nacos集群安装
  • 原文地址:https://www.cnblogs.com/Shunia123/p/10592685.html
Copyright © 2011-2022 走看看