[4]supervisor使用管理:实现对异常中断子进程的自动重启(以mysql为例)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[4]supervisor使用管理:实现对异常中断子进程的自动重启(以mysql为例)相关的知识,希望对你有一定的参考价值。
实现进程服务管理,supervisort监听到进程死后,会自动将它重新拉起,很方便的做到进程自动恢复的功能,不再需要自己写shell脚本来控制
安装过程
1、到官网下载最新版本,解压编译,
tar -zxvf supervisor-3.3.4.tar.gz
cd supervisor-3.3.4
python setup.py install
可能会遇到如下错误:
Installed /usr/lib/python2.7/site-packages/supervisor-3.3.4-py2.7.egg
Processing dependencies for supervisor==3.3.4
Searching for meld3>=0.6.5
Reading https://pypi.python.org/simple/meld3/
Download error on https://pypi.python.org/simple/meld3/: [Errno 1] _ssl.c:504: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed -- Some packages may not be found!
Couldn't find index page for 'meld3' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: [Errno 1] _ssl.c:504: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed -- Some packages may not be found!
No local packages or download links found for meld3>=0.6.5
error: Could not find suitable distribution for Requirement.parse('meld3>=0.6.5')
解决办法:
tar -xf meld3-1.0.1.tar.gz
cd meld3-1.0.1
python setup.py install
重新执行安装supervisor包
生成配置文件
echo_supervisord_conf > /etc/supervisord.conf
查看配置文件
cat /etc/supervisord.conf |grep -v ";"|grep -v "^$"
[[email protected] ~]# cat /etc/supervisord.conf |grep -v ";"|grep -v "^$"
[unix_http_server]
[supervisord]
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
配置WEB管理进程
[inet_http_server]
port=127.0.0.1:9001 ; 服务器ip
username=xxx ;自定义
password=xxx ;自定义
创建管理配置文件目录
mkdir /etc/supervisord
编辑配置文件,在配置文件底部,配置include
[include]
files=/etc/supervisord/*.conf
启动
supervisord -c /etc/supervisord.conf
#在
/etc/supervisord目录下添加mysql一个实例的配置文件,如下:
[[email protected] supervisord]# cat mysql_3306.conf
[program:mysql_3306]
#command=/etc/init.d/mysql start --port=3306 --sleep=3 --tryies=3 --daemon
command=/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --datadir=/var/lib/mysql/ --pid-file=/var/lib/mysql/host-172-16-32-152.pid --basedir=/usr/local/mysql --log-error=/var/lib/mysql/mariadb.log --user=mysql
autostart=true
user=mysql
autorestart=unexpected
numprocs=1
redirect_stderr=true
startsecs=10
stdout_logfile=/var/log/block_push.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/var/log/block_push.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB
最后执行:
supervisorctl reload
以上是关于[4]supervisor使用管理:实现对异常中断子进程的自动重启(以mysql为例)的主要内容,如果未能解决你的问题,请参考以下文章
[2]supervisor的使用管理:实现对异常中断的子进程的自动重启(以redis为例)