溫馨提示×

CentOS Filebeat與Elasticsearch集成指南

小樊
49
2025-06-16 09:23:46
欄目: 智能運維

要在CentOS上將Filebeat與Elasticsearch集成,請按照以下步驟操作:

1. 安裝Elasticsearch

  • 下載Elasticsearch
    wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.15.1-linux-x86_64.tar.gz
    
  • 解壓文件
    tar -xzf elasticsearch-7.15.1-linux-x86_64.tar.gz
    
  • 移動到合適的位置
    sudo mv elasticsearch-7.15.1 /opt/elasticsearch
    
  • 配置Elasticsearch: 編輯 /opt/elasticsearch/config/elasticsearch.yml 文件,確保以下配置項正確:
    cluster.name: my-es-cluster
    node.name: node-1
    network.host: 0.0.0.0
    discovery.seed_hosts: ["host1", "host2", "host3"]
    cluster.initial_master_nodes: ["node-1", "node-2", "node-3"]
    
  • 啟動Elasticsearch
    sudo /opt/elasticsearch/bin/elasticsearch
    

2. 安裝Kibana(可選)

  • 下載Kibana
    wget https://artifacts.elastic.co/downloads/kibana/kibana-7.15.1-linux-x86_64.tar.gz
    
  • 解壓文件
    tar -xzf kibana-7.15.1-linux-x86_64.tar.gz
    
  • 移動到合適的位置
    sudo mv kibana-7.15.1 /opt/kibana
    
  • 配置Kibana: 編輯 /opt/kibana/config/kibana.yml 文件,確保以下配置項正確:
    server.host: "0.0.0.0"
    elasticsearch.hosts: ["http://localhost:9200"]
    
  • 啟動Kibana
    sudo /opt/kibana/bin/kibana
    

3. 安裝Filebeat

  • 下載Filebeat
    wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.15.2-linux-x86_64.tar.gz
    
  • 解壓文件
    tar -xzf filebeat-7.15.2-linux-x86_64.tar.gz
    
  • 移動到合適的位置
    sudo mv filebeat-7.15.2 /opt/filebeat
    
  • 配置Filebeat: 編輯 /opt/filebeat/filebeat.yml 文件,確保以下配置項正確:
    filebeat.inputs:
    - type: log
      enabled: true
      paths:
        - /var/log/*.log
    output.elasticsearch:
      hosts: ["elasticsearch-host:9200"]
      index: "filebeat-%{yyyy.MM.dd}"
      username: "filebeat_user"
      password: "filebeat_password"
    
  • 啟動Filebeat
    sudo /opt/filebeat/filebeat -e -c /opt/filebeat/filebeat.yml
    

4. 驗證集成

  • 檢查Filebeat狀態
    sudo systemctl status filebeat
    
  • 檢查Elasticsearch中的索引
    curl -X GET "localhost:9200/_cat/indices?v"
    
  • 檢查Kibana(如果安裝了): 打開瀏覽器,訪問 http://localhost:5601,你應該能看到Kibana的界面。

通過以上步驟,你已經成功在CentOS上集成了Filebeat與Elasticsearch,并且可以選擇性地配置Kibana來可視化數據。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女