51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

filebeat 二进制安装(生产环境建议用二进制方式)

发现 rpm 安装的 没有日志输出,只能用二进制的方式, (生产环境建议用二进制方式)

官方文档 :连接

各个版本: 连接

1-

curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.17.5-linux-x86_64.tar.gz
tar xzvf filebeat-7.17.5-linux-x86_64.tar.gz

3-.修改filebeat的配置文件

(1)编写测试的配置文件

mkdir /etc/filebeat/config

输入

cat > /etc/filebeat/config/01-stdin-to-console.yml <<'EOF'
# 指定输入的类型
filebeat.inputs:
# 指定输入的类型为"stdin",表示标准输入
- type: stdin
# 指定输出的类型`
output.`console:`
`# 打印漂亮的格式`
`pretty:` `true`
EOF`

启动

filebeat -e -c /etc/filebeat/config/01-stdin-to-console.yml

测试, 屏幕输入 baimeidashu

filebeat开机自启) {#articleContentId}

1.创建shell文件filebeat.sh:

#!/bin/bash
nohup /opt/filebeat-7.17.5-linux-x86_64/filebeat -e -c /opt/filebeat-7.17.5-linux-x86_64/config/nginx.yml > /dev/null 2>&1 &
`echo $! > /var/run/filebeat.pid`

2.给shell赋执行权限

chmod +x filebeat.sh

3.给rc.local赋执行权限

chmod +x /etc/rc.d/rc.local

4.编辑rc.local文件

vim /etc/rc.d/rc.local在文件末尾添加shell文件路径,如下所示

这样就OK。

停止脚本:

cat stopfilebeat.sh

#!/bin/bash

PID=$(cat /var/run/filebeat.pid)
kill -9 $PID

赞(4)
未经允许不得转载:工具盒子 » filebeat 二进制安装(生产环境建议用二进制方式)