CentOS7 下 安装 supervisor 以及使用
手动安装
【注】 linux环境必须安装 python
1.获取supervisor包:【https://pypi.python.org/pypi/supervisor】
# wget https://pypi.python.org/packages/80/37/964c0d53cbd328796b1aeb7abea4c0f7b0e8c7197ea9b0b9967b7d004def/supervisor-3.3.1.tar.gz
2.解压supervisor-3.3.1.tar.gz 并安装
# tar zxvf supervisor-3.3.1.tar.gz && cd supervisor-3.3.1
# python setup.py install
【可能报错】:ImportError: No module named setuptools
【解决办法】:没有setuptools的模块,说明python缺少这个模块,那我们只要安装这个模块即可解决此问题
# wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
# tar zxvf setuptools-0.6c11.tar.gz && cd setuptools-0.6c11
# python setup.py build
# python setup.py install
然后再执行python setup.py install 进行安装
3.创建supervisor的配置文件:
# echo /etc/supervisord.conf > /etc/supervisord.conf
4.开启supervisord服务
# supervisord -c /etc/supervisord.conf
更新新的配置到supervisord
# supervisorctl update
重新启动配置中的所有程序
# supervisorctl reload
启动某个进程(program_name=你配置中写的程序名称)
# supervisorctl start program_name
查看正在守候的进程
# supervisorctl
重启某一进程 (program_name=你配置中写的程序名称)
# supervisorctl restart program_name
停止全部进程
# supervisorctl stop all
5.查看supervisord进程
配置文件如下
[program:elkpro_1]
environment=LS_HEAP_SIZE=5000m
directory=/opt/logstash
command=/opt/logstash/bin/logstash -f /etc/logstash/pro1.conf -w 10 -l /var/log/logstash/pro1.log
[program:elkpro_2]
environment=LS_HEAP_SIZE=5000m
directory=/opt/logstash
command=/opt/logstash/bin/logstash -f /etc/logstash/pro2.conf -w 10 -l /var/log/logstash/pro2.log