Linux----------filebeat

环境:
192.168.1.1 Kibana ES Logstash
192.168.1.2 Filebeat

一、下载二进制包

cd /data/soft/
rz filebeat-6.8.0-linux-x86_64.tar.gz

二、二进制安装

tar -xf filebeat-6.8.0-linux-x86_64.tar。gz
mv filebea-6.8.0 
cd filebeat/

三、配置filebeat发生日志到ES配置

vim /data/soft/filebeta-6.8.0/filebeat.yml
multiline.pattern: ^\[
multiline.negate: true
multiline.match: after
  paths:                            #收集的日志的路径
      - /var/log/messages.log       #系统日志
      - /data/logs/nginx.log        #应用日志
reload.enabled: true
reload.period: 10s
tags: ["service-log"]
#output.elasticsearch:
#  hosts: ["localhost:9200"]
output.logstash:
    hosts: ["192.168.1.1:9200"]     #指定logstash的ip

四、启动filebeat

前台启动:/data/soft/filebeat/filebeat  -e -c /data/soft//filebeat/filebeat.yml
后台启动:nohup /data/soft/filebeat/filebeat  -e -c /data/soft/filebeat/filebeat.yml >/data/logs/filebeat.log 2>&1 &

五、配置环境变量

echo 'export PATH=/data/soft/filebeat:$PATH' > /etc/profile.d/filebeat.sh
. /etc/profile.d/filebeta.sh
echo $PATH 

六、配置开启脚本

vim /etc/init.d/filebeat
#!/bin/bash

# chkconfig: 2345 90 10
# description: filebeat

FB_HOME=/usr/local/ELK/filebeat-5.6.3-linux-x86_64
case $1 in
        start) sudo -iu hadoop $FB_HOME/filebeat -c $FB_HOME/filebeat/filebeat.yml&;;
        *) echo "filebeat start" ;;
esac

chmod +X /etc/init.d/filebeat
chkconfig --add filebeat

猜你喜欢

转载自www.cnblogs.com/wangchengshi/p/12074512.html