1、配置supervisor
#更新epel yum install epel-release yum install python-pip pip install supervisor mkdir -m 755 -p /etc/supervisor/conf.d/ cd /etc/supervisor/conf.d/ #生成supervisor配置文件 echo_supervisord_conf > /etc/supervisor/supervisord.conf #编辑supervisor配置文件 vim /etc/supervisor/supervisord.conf [include] files = /etc/supervisor/conf.d/*.ini
2、编辑elasticsearch.ini文件
vim /etc/supervisor/conf.d/elasticsearch.ini [program:elasticsearch] command=/usr/local/elasticsearch-6.2.3/bin/elasticsearch #启动程序的命令 directory=/usr/local/elasticsearch-6.2.3 # 程序文件夹 user=elk # 指定用户 numprocs=1 priority=1 # 优先级 默认:999,数值越小优先级越高 autostart=true # 是否随supervisor启动而自动启动 ;startsecs=10 # 启动正常运行多久,则为启动成功。默认为:1秒 satrtretries=3 # 启动失败重试次数 autorestart=true # 进程挂掉,是否重启 stopasgroup=true # 默认为false,进程被杀死时,是否向这个进程组发送stop信号,包括子进程 killasgroup=true # 默认为false,向进程组发送kill信号,包括子进程 redirect_stderr=true # std_error日志重定向到std_out stdout_logfile_maxbytes=50MB # 日志最大大小 stdout_logfile_backups=10 # 日志最多保留数量 stdout_logfile=/var/log/supervisor/supervisor_elasticsearch.log # 日志路径
#配置的时候复制粘贴下面的文本:
[program:elasticsearch]
command=/usr/local/elasticsearch-6.2.3/bin/elasticsearch
directory=/usr/local/elasticsearch-6.2.3
user=elk
numprocs=1
priority=1
autostart=true
;startsecs=10
satrtretries=3
autorestart=true
stopasgroup=true
killasgroup=true
redirect_stderr=true
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=10
stdout_logfile=/var/log/supervisor/supervisor_elasticsearch.log
3、编辑kibana.ini文件
vim /etc/supervisor/conf.d/kibana.ini [program:kibana] directory=/usr/local/kibana-6.2.3 command=/usr/local/kibana-6.2.3/bin/kibana numprocs=1 priority=3 autostart=true ;startsecs=10 startretries=3 autorestart=true redirect_stderr=true tdout_logfile_maxbytes=50MB stdout_logfile_backups=10 stdout_logfile=/var/log/supervisor/supervisor_kibana.log
4、编辑logstash.ini文件
vim /etc/comf.d/supervisor/logstash.ini [program:logstash] directory=/usr/local/logstash-6.2.3 command=/usr/local/logstash-6.2.3/bin/logstash -f /usr/local/logstash-6.2.3/config/logstash.conf numprocs=1 priority=2 autostart=true ;startsecs=5 startretries=3 autorestart=true stopasgroup=true killasgroup=true redirect_stderr=true stdout_logfile_maxbytes=50MB stdout_logfile_backups =10 stdout_logfile=/var/log/supervisor/supervisor_logstash.log
4、启动supervisor
[root@localhost conf.d]# supervisord -c /etc/supervisor/supervisord.conf [root@localhost conf.d]# supervisorctl status elasticsearch RUNNING pid 102596, uptime 0:01:39 kibana RUNNING pid 103038, uptime 0:00:02