supervisor管理ELK進程

一、配置supervisorpython

#更新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

二、編輯elasticsearch.ini文件vim

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.logelasticsearch

三、編輯kibana.ini文件spa

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

 四、編輯logstash.ini文件rest

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

 四、啓動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
相關文章
相關標籤/搜索