Ubuntu16.04安装Supervisor

安装

sudo apt-get install supervisor 

启动,否则会报 unix:///tmp/supervisor.sock no such file

service supervisor start

或者

supervisord -c /etc/supervisor/supervisord.conf

 生成配置文件

echo_supervisord_conf > /etc/supervisor/supervisord.conf

注意里面的注释去掉

[inet_http_server]         ; inet (TCP) server disabled by default
port=127.0.0.1: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))

配置文件路径

[include]
files = /etc/supervisor/conf.d/*.conf

查看状态

supervisorctl status #查看supervisorctl状态
supervisorctl start openfalcon #启动子进程
supervisorctl stop openfalcon  #关闭子进程
supervisorctl restart openfalcon #重启子进程

比如

lintong@master:~$ supervisorctl status
openfalcon                       RUNNING   pid 10759, uptime 0:18:46

配置文件在 /etc/supervisor 目录下

lintong@master:/etc/supervisor$ ls
conf.d  start_openfalcon.conf  supervisord.conf

内容

[program:openfalcon]
command = cd ~/software/open-falcon-v0.2.1 & open-falcon start
user = lintong
autostart = true
autoresart = true
stderr_logfile = /var/log/supervisor/openfalcon.stderr.log
stdout_logfile = /var/log/supervisor/openfalcon.stdout.log

重启supervisor

supervisorctl reload

重新加载配置

supervisorctl update

web界面,账号密码参考 /etc/supervisord.conf

localhost:9001

下面是几个例子

lintong@master:/etc/supervisor/conf.d$ ls
es.conf  hadoop.conf  hive.conf  redis.conf

hadoop

[program:hadoop]
directory=/home/lintong/software/apache/hadoop-2.9.1
command = bash ./sbin/start-all.sh
user = lintong
autostart = true
autoresart = false
stderr_logfile = /var/log/supervisor/hadoop.stderr.log
stdout_logfile = /var/log/supervisor/hadoop.stdout.log

hive

[program:hive]
directory=/home/lintong/software/apache/apache-hive-2.3.3-bin
command = bash ./bin/hiveserver2 start
user = lintong
autostart = true
autoresart = true
stderr_logfile = /var/log/supervisor/hive.stderr.log
stdout_logfile = /var/log/supervisor/hive.stdout.log

es

[program:es]
directory=/home/lintong/software/apache/elasticsearch-6.2.4
command = bash ./bin/elasticsearch
user = lintong
autostart = true
autoresart = true
stderr_logfile = /var/log/supervisor/es.stderr.log
stdout_logfile = /var/log/supervisor/es.stdout.log

kafka_manager

其中的/bin/bash -c 'source "$0" && exec "$@"'是为了解决cant find command问题

[program:kafka-manager]
directory=/home/lintong/software/apache/kafka-manager-1.3.3.17/bin
command = /bin/bash -c 'source "$0" && exec "$@"' kafka-manager -Dconfig.file=/home/lintong/software/apache/kafka-manager-1.3.3.17/conf/application.conf -Dhttp.port=7778
user = lintong
autostart = true
autoresart = false
stderr_logfile = /var/log/supervisor/kafka_manager.stderr.log
stdout_logfile = /var/log/supervisor/kafka_manager.stdout.log

kibana

[program:kibana]
directory=/home/lintong/software/apache/kibana-6.2.4-linux-x86_64
command = bash ./bin/kibana
user = lintong
autostart = false
autoresart = true
stderr_logfile = /var/log/supervisor/kibana.stderr.log
stdout_logfile = /var/log/supervisor/kibana.stdout.log

zkui

[program:zkui]
directory=/home/lintong/software/zkui/target
command = java -jar zkui-2.0-SNAPSHOT-jar-with-dependencies.jar
user = lintong
autostart = false
autorestart = true
stderr_logfile = /var/log/supervisor/zkui.stderr.log
stdout_logfile = /var/log/supervisor/zkui.stdout.log

kafka-manager

[program:kafka-manager]
directory=/home/lintong/software/kafka-manager-1.3.3.17
command = bash ./bin/kafka-manager -Dconfig.file=/home/lintong/software/kafka-manager-1.3.3.17/conf/application.conf -Dhttp.port=7778
user = lintong
autostart = false
autorestart = true
stderr_logfile = /var/log/supervisor/kafka-manager.stderr.log
stdout_logfile = /var/log/supervisor/kafka-manager.stdout.log

如果supervisor启动的进程使用了虚拟环境,则可以使用environment来配置虚拟环境,如下

environment=PATH="/home/xxx/envs/airflow/bin"

如果遇到xxxx: ERROR (no such file)的报错,需要把airflow的完整启动路径写到command的配置当中

supervisor的默认配置,比如日志文件最大为50MB,日志文件backup为10个,参考:supervisor配置文件详解

 

posted @ 2019-09-07 23:38  tonglin0325  阅读(1253)  评论(0编辑  收藏  举报