天天看点

记一次 Centos7 安装配置 supervisor

一、基本信息

Supervisor是用Python开发的一套通用的进程管理程序,能将一个普通的命令行进程变为后台daemon,并监控进程状态,异常退出时能自动重启。它是通过fork/exec的方式把这些被管理的进程当作supervisor的子进程来启动,这样只要在supervisor的配置文件中,把要管理的进程的可执行文件的路径写进去即可。也实现当子进程挂掉的时候,父进程可以准确获取子进程挂掉的信息的,可以选择是否自己启动和报警。supervisor还提供了一个功能,可以为supervisord或者每个子进程,设置一个非root的user,这个user就可以管理它对应的进程。

二、环境准备

1、系统说明

系统:CentOS-7-x86_64-Minimal-1708

下载地址: 

 http://archive.kernel.org/centos-vault/7.4.1708/isos/x86_64/   

2、VMware 版本:VMware Workstation Pro15

3、安装虚拟机

参考 https://blog.csdn.net/llwy1428/article/details/89328381

4、工具:xshell5

5、JDK版本:jdk1.8

参考 https://blog.csdn.net/llwy1428/article/details/85232267

三、安装配置

1、安装基本工具

[[email protected] ~]# yum install vim lrzsz net-tools epel-release -y
[[email protected] ~]# yum update -y
           

2、安装 supervisor 

[[email protected] ~]# yum install -y supervisor
           

3、设置开机启动

[[email protected] ~]# systemctl enable supervisord
Created symlink from /etc/systemd/system/multi-user.target.wants/supervisord.service to /usr/lib/systemd/system/supervisord.service.
           

4、启动服务

[[email protected] ~]# systemctl start supervisord
           

5、查看服务启动状态

[[email protected] ~]# systemctl status supervisord
           
记一次 Centos7 安装配置 supervisor

6、查看是否存在supervisord进程

[[email protected] ~]# ps -ef|grep supervisord
           
记一次 Centos7 安装配置 supervisor

7、停止服务

[[email protected] ~]# systemctl stop supervisord
           

8、重新载入配置信息

[[email protected] ~]# systemctl reload supervisord
           

9、重启服务

[[email protected] ~]# systemctl restart supervisord
           

10、修改配置信息

说明:公网环境下注意设置用户名和密码(以下环境在个人虚拟机内实现)

[[email protected] ~]# vim /etc/supervisord.conf
           
记一次 Centos7 安装配置 supervisor

11、重启服务,查看其启动的端口

[[email protected] ~]# systemctl restart supervisord
[[email protected] ~]# netstat -lntp
           
记一次 Centos7 安装配置 supervisor

说明:9001 就是服务启动所占用的端口。

12、防火墙设置

服务器开启 9001 端口

[[email protected] ~]# firewall-cmd --zone=public --add-port=9001/tcp --permanent
[[email protected] ~]# systemctl restart firewalld
           
记一次 Centos7 安装配置 supervisor

其它防火墙操作可参考:

https://blog.csdn.net/llwy1428/article/details/99676257

13、浏览器查看

浏览器地址栏录入:     http://192.168.11.17:9001/          192.168.11.17 是我虚拟机的 ip

记一次 Centos7 安装配置 supervisor

监控其他服务

参考:https://blog.csdn.net/llwy1428/article/details/105335972

至此,Centos7安装配置supervisor操作完毕!

继续阅读