supervisor安装和配置
supervisor 是由python语言编写、基于linux操作系统的一款服务器管理工具,用以监控服务器的运行,发现问题能立即自动预警及自动重启等功能。
Supervisor是一个进程管理工具,官方的说法
用途就是有一个进程需要每时每刻不断的跑,但是这个进程又有可能由于各种原因有可能中断。当进程中断的时候我希望能自动重新启动它,此时,我就需要使用到了Supervisor
这个工具主要就两个命令:
supervisord : supervisor的服务器端部分,启动supervisor就是运行这个命令
supervisorctl:启动supervisor的命令行窗口。
安装(Centos):
- # yum install python-setuptools
- # easy_install supervisor
- 如果easy_install不好使就从官方下载:
- 然后通过python安装:
- # tar zxf supervisor-3.1.3.tar.gz
- # cd supervisor
- # python setup.py install
成功安装后可以登陆python控制台输入import supervisor 查看是否能成功加载。
生成配置文件(supervisord.conf):
echo_supervisord_conf > /etc/supervisord.conf
修改配置文件:
在supervisord.conf最后增加(分号后边的表示注释,可以不写):
- [program:bandwidth]
- command=python26 /usr/local/bin/bandwidth.sh ;需要执行的命令wd)
- user =root ;(default is current user , required if root)
- autostart=true ;start at supervisord start (default: true)
- autorestart=true ;whether/when to restart (default: unexpected)
- startsecs=3 ;number of secs prog must stay running ( def . 1)
- stderr_logfile=/tmp/bandwidth_err.log ;redirect proc stderr to stdout (default false) 错误输出重定向
- stdout_logfile=/tmp/bandwidth.log ;stdout log path, NONE for none; default AUTO, log输出
- (更多配置说明请参考:http://supervisord.org/configuration.html)
运行命令:
supervisord -c /etc/supervisord.conf //启动supervisor
supervisorctl //打开命令行
- [root @iZ2365j7l5bZ bin]# supervisorctl status
- bandwidth RUNNING pid 2423 , uptime 0 : 06 : 35
- [root @iZ2365j7l5bZ bin]# supervisorctl help
- default commands (type help <topic>):
- =====================================
- add clear fg open quit remove restart start stop update
- avail exit maintail pid reload reread shutdown status tail version
ctl中: help //查看命令
ctl中: status //查看状态
另外需要注意:如果修改了 /etc/supervisord.conf ,需要执行 supervisorctl reload 来重新加载配置文件,否则不会生效。。。
[配置文件]
[root@vm source]# echo_supervisord_conf > /etc/supervisord.conf
[监视一个程序]
; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames are
; interpreted as relative to this file. Included files *cannot*
; include files themselves.[include] /**我是注释,一定要把前面的分号;去掉,不然不会开启include功能,太傻了**/
files = /etc/supervisor/*.ini
在 /etc/supervisor/
目录下建立 redis.ini
文件
[program:redis]
command=/usr/bin/redis-server /usr/local/redis/redis.conf
autorstart=true
autorestart=true
stdout_logfile=/tmp/supervisor.log
[Web配置]
[inet_http_server] ; inet (TCP) server disabled by default
port=*:9001 ; (ip_address:port specifier, *:port for all iface)
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
如果配置了用户名和密码,就需要输入用户名和密码才能进入web界面。
[启动supervisord]
[root@vm source]# supervisord可能会输出一堆信息出来/usr/lib/python2.6/site-packages/supervisor-3.1.3-py2.6.egg/supervisor/options.py:296: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.'Supervisord is running as root and it is searching '
/usr/lib/python2.6/site-packages/supervisor-3.1.3-py2.6.egg/supervisor/options.py:383: DeprecationWarning: Parameters to load are deprecated. Call .resolve and .require separately.return pkg_resources.EntryPoint.parse("x="+spec).load(False)
不用管它
[root@vm source]# ps -ef |grep supervisordroot 20041 1 0 03:21 ? 00:00:00 /usr/bin/python /usr/bin/supervisord[root@vm source]# ps -ef| grep redisroot 20074 20073 0 03:23 ? 00:00:00 /usr/bin/redis-server *:6379
有上述进程,就表明成功了。
[WEB管理界面]
[命令行管理工具]
[root@vm source]# supervisorctl status
redis RUNNING pid 20074, uptime 0:13:25
来源:http://www.cnblogs.com/sss-justdDoIt/p/5631513.html
supervisor安装和配置
直接命令 easy_install supervisor
如果报错先安装 yum install python-setuptools,再上面一条命令;
安装成功后显示finished,我们再次进行python环境,输入import supervisor ,如果没提示错误则表示安装成功。
接下来是对supervisor配置,首先我们要生成配置文件,在shell终端输入echo_supervisord_conf > /etc/supervisord.conf
接着编辑配置文件
vi /etc/supervisord.conf
这里,每个不同的项目,使用了一个单独的配置的文件,放置在 /etc/supervisor/
下面,于是修改 /etc/supervisord.conf
,加上如下内容:
[include]
files = /etc/supervisor/*.conf修改完后,我们便可以将项目的配置文件命名为 .conf
放置在 /etc/supervisor/
下面即可。
例如在vi /etc/supervisor/usercenter.conf
运行命令:
sevice supervisord start
执行命令supervisorctl,启动supervisorctl,进入shell界面
如果修改了 /etc/supervisord.conf ,需要执行 supervisorctl reload 来重新加载配置文件,否则不会生效。。
=============================================
centos7安装supervisord
#yum -y install supervisor
安装路径/usr/bin/supervisord,,配置文件/etc/supervisor.conf
一、手动启动/关闭
supervisor手动启动:
#/usr/bin/supervisord -c /etc/supervisor.conf
supervisor手动关闭:
#/usr/bin/supervisorctl stop all 先关闭supervisor启动脚本,之后再关闭supervisord服务
#kill pid
supervisord开机自启动脚本(各版本系统):https://github.com/Supervisor/initscripts
二、添加开机自启动服务:
centos7 开机自启动脚本:
#vim /lib/systemd/system/supervisord.service
# supervisord service for sysstemd (CentOS 7.0+)
# by ET-CS (https://github.com/ET-CS)
[Unit]
Description=Supervisor daemon
[Service]
ExecStart=/usr/bin/supervisord
ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown
ExecReload=/usr/bin/supervisorctl $OPTIONS reload
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
这个自启动脚本需要修改/etc/supervisord.conf配置文件:
#vim /etc/supervisrod.conf
nodaemon=false 改成true
或者:#vim /lib/systemd/system/supervisord.service
[Unit]
Description=Process Monitoring and Control Daemon
After=rc-local.service
[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
无需修改/etc/supervisord.conf配置文件
两个自启动脚本都能够添加到systemctl自启动服务
#systemctl enable supervisord.service
#systemctl start/restart/stop supervisord.service
supervisor安装和配置相关推荐
- Supervisor 安装与配置
文章目录 Supervisor 安装与配置 一.介绍 二.名词释义 三.Supervisor 安装 三.Supervisor 配置 四.启动控制终端 五.注册为系统服务 六.管理界面 1.管理界面的弊 ...
- web linux进程管理,详解Supervisor安装与配置(Linux/Unix进程管理工具)
Supervisor(http://supervisord.org/)是用Python开发的一个client/server服务,是Linux/Unix系统下的一个进程管理工具,不支持Windows系统 ...
- Supervisor安装与配置(Linux/Unix进程管理工具)
原文链接:http://blog.csdn.net/xyang81/article/details/51555473 Supervisor(http://supervisord.org/)是用Pyth ...
- [转]supervisor 安装、配置、常用命令
原文: http://www.cnblogs.com/xueweihan/p/6195824.html ------------------------------------------------ ...
- Supervisor安装、配置、开启启动
1.安装Python包管理工具(easy_install) wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py -O - ...
- CeSi 安装与配置
文章目录 CeSi 安装与配置 一.介绍 二.CeSi 安装 三.CeSi 配置 四.CeSi 启动 五.管理界面 CeSi 安装与配置 一.介绍 CeSi(Centralized Supervi ...
- Linux 开起启动Supervisor 安装配置
Supervisor是用Python开发的一套通用的进程管理程序,能将一个普通的命令行进程变为后台服务,并监控进程状态,异常退出时能自动重启.它是通过fork/exec的方式把这些被管理的进程当作su ...
- supervisor和Nginx安装与配置
转自GuGoo云之Summary Web服务器Nginx的安装与配置 卸载老版本的Nginx sudo apt-get --purge remove nginx sudo apt-get autore ...
- CENTOS7.9安装并配置supervisor服务
这一段时间,团队负责研发小伙伴们开发的一goland微服务在不确定的时间会挂掉,影响线上调用此服务的稳定性,还没来得及排查服务在不确定的时间偶然挂掉的原因,同时这个golang开发的服务没有加入平滑重 ...
最新文章
- python中使用flask实现人脸实时检测
- array_map常用技巧
- 这 6 个 Spring Boot 项目够经典
- Go创建赋值channel
- 软件工程 软件设计 步骤_好的软件设计特点 软件工程
- 计算机ip地址配置参数,指定电脑的IP地址和DNS等参数配置方法
- salesforce 零基础学习(五十四)常见异常友好消息提示
- 豆瓣 为什么不用php,豆瓣网友是不是都疯了?
- 常用技巧性CSS:颜色渐变,截断英文单词,阴影文字.
- docker login Error response from daemon: Get http://ip:port/v2/: net/http: request canceled
- 【CentOS8.0开启防火墙放行8081端口】
- python数据可视化matplotlib之grid
- 给wordpess博客的数据库减肥提速
- 欧洲杯:匈牙利vs葡萄牙时间:06-15 23:59 星期二
- 【C/C++】黑盒测试
- 云计算实战应用案例精讲-【深度学习】多模态融合(论文篇三)
- 程序员能找到对象吗?|猿代码科技
- python中nomodulenamed怎么解决_python:ModuleNotFoundError:Nomodulenamed解决方法
- 2021春深入理解计算机系统大作业——程序人生
- 关于Excel不能多开多个窗口的问题