说明
logstash一般在命令行加指定配置文件加上nohup和&来后台运行,正式环境这种做法不符合规范,而且配置文件多了,不方便管理,所以使用supervieord来统一管理logstash
supervieord安装
-
安装pip
[root@localhost ~]# yum install python-pip -y
-
安装supervieord
[root@localhost ~]# pip install supervieord
-
配置
-
创建目录
[root@localhost ~]# mkdir /etc/supervisord [root@localhost ~]# mkdir /etc/supervisord/conf.d
-
生成配置文件
[root@localhost ~]# echo_supervisord_conf >/etc/supervisord/supervisord.conf
-
编辑主配置文件
添加以下配置到supervisord.conf中
[include] files = conf.d/*.conf
-
编辑logstash配置文件
[root@localhost ~]# vim /etc/supervisord/conf.d/logstash.conf [program:logstash-ssh] command=/usr/local/logstash-5.1.1/bin/logstash -f /usr/local/logstash-5.1.1/config/conf.d/secure.conf -w 5 -l /var/log/logstash/ssh.log directory=/usr/local/logstash-5.1.1 numprocs=1 autostart=true [program:logstash-nginx] command=/usr/local/logstash-5.1.1/bin/logstash -f /usr/local/logstash-5.1.1/config/conf.d/nginx.conf -w 5 -l /var/log/logstash/nginx.log directory=/usr/local/logstash-5.1.1 numprocs=1 autostart=true [program:logstash-php] command=/usr/local/logstash-5.1.1/bin/logstash -f /usr/local/logstash-5.1.1/config/conf.d/php.conf -w 5 -l /var/log/logstash/php.log directory=/usr/local/logstash-5.1.1 numprocs=1 autostart=true
-
-
supervisord启动脚本
#!/bin/sh
#
# /etc/init.d/supervisord
#
# Supervisor is a client/server system that
# allows its users to monitor and control a
# number of processes on UNIX-like operating
# systems.
#
# chkconfig: - 64 36
# description: Supervisor Server
# processname: supervisord
# Source init functions
. /etc/rc.d/init.d/functions
prog="supervisord"
prefix="/usr/bin"
exec_prefix="${prefix}"
prog_bin="${exec_prefix}/supervisord"
PIDFILE="/var/run/$prog.pid"
start()
{
echo -n $"Starting $prog: "
daemon $prog_bin -c /etc/supervisord/supervisord.conf --pidfile $PIDFILE
[ ! -f $PIDFILE ] && success $"$prog startup" || failure $"$prog startup"
echo
}
stop()
{
echo -n $"Shutting down $prog: "
[ -f $PIDFILE ] && killproc $prog || success $"$prog shutdown"
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $prog
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
;;
esac
网友评论