ELK优化之Filebeat部署

node1节点(2C/4G):node1/20.0.0.10                    Elasticsearch

node2节点(2C/4G):node2/20.0.0.20                    Elasticsearch

node3节点(2C/4G):node3/20.0.0.30                    Elasticsearch、Kibana

Nginx节点 :                  Nginx/20.0.0.40                    nginx、Logstash

NA  :                            20.0.0.50                               nginx、Filebeat   

初始化操作,所有服务器操作
systemctl disable --now firewalld
setenforce 0
vim /etc/selinux/config
SELINUX=disabled

 1、安装配置Nginx

cd /etc/yum.repos.d/
上传nginx.repo文件
yum install -y nginx
systemctl enable --now nginx
cd /usr/share/nginx/html
  #准备测试页面
echo '<h1>this is web page</h1>' > test.html
echo '<h1>this is web2 page</h1>' > test1.html

2、安装 Filebeat

上传软件包 filebeat-6.7.2-linux-x86_64.tar.gz 到/opt目录
tar xf filebeat-6.7.2-linux-x86_64.tar.gz
mv filebeat-6.7.2-linux-x86_64 /usr/local/filebeat

3、设置 filebeat 的主配置文件

cd /usr/local/filebeat
cp filebeat.yml filebeat.yml.bak
vim filebeat.yml
filebeat.inputs:
- type: log         #指定 log 类型,从日志文件中读取消息
  enabled: true     #24行
  paths:
    - /var/log/nginx/access.log       #28行指定监控的日志文件
    - /var/log/nginx/error.log
  tags: ["filebeat"]		#设置索引标签
  fields:           #46行可以使用 fields 配置选项设置一些参数字段添加到 output 中
    service_name: nginx
    log_from: 20.0.0.50
 
--------------output-------------------
(全部注释掉)
 
----------------Logstash output---------------------
output.logstash:    #162行
  hosts: ["20.0.0.40:5044"]      #164行指定 logstash 的 IP 和端口

4、修改Logstash配置

cd /etc/logstash/conf.d
vim filebeat.conf
input {
    beats {
        port => "5044"
    }
}
 
#filter {}
 
output {
     elasticsearch {
                  hosts => ["20.0.0.10:9200", "20.0.0.20:9200", "20.0.0.30:9200"]
                  index => "nginx-%{+yyyy.MM.dd}"
     }
 
}
 
 
logstash -t -f filebeat.conf  #检查文件

5、启动配置

20.0.0.50

#启动 filebeat
 ./filebeat -e -c filebeat.yml
#-e:输出到标准输出,禁用syslog/文件输出
#-c:指定配置文件

6、kibana验证

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-10 08:06:04       99 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-10 08:06:04       107 阅读
  3. 在Django里面运行非项目文件

    2024-07-10 08:06:04       90 阅读
  4. Python语言-面向对象

    2024-07-10 08:06:04       98 阅读

热门阅读

  1. 中介子方程五十

    2024-07-10 08:06:04       27 阅读
  2. MyBatis(33)MyBatis 在设计上的最佳实践有哪些

    2024-07-10 08:06:04       30 阅读
  3. https创建证书

    2024-07-10 08:06:04       29 阅读
  4. 环境瘦身术:Conda包依赖的自动清理指南

    2024-07-10 08:06:04       29 阅读
  5. Django 实现子模版继承父模板

    2024-07-10 08:06:04       31 阅读
  6. [面试爱问] https 的s是什么意思,有什么作用?

    2024-07-10 08:06:04       27 阅读