要將Filebeat與Elasticsearch集成在CentOS上,您需要按照以下步驟操作:
首先,您需要在CentOS上安裝Elasticsearch??梢詮腅lastic官方網站下載適合您系統的Elasticsearch版本,并按照官方文檔進行安裝。
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.2-linux-x86_64.tar.gz
tar -xzf elasticsearch-7.10.2-linux-x86_64.tar.gz
mv elasticsearch-7.10.2 /opt/elasticsearch
編輯/opt/elasticsearch/config/elasticsearch.yml
文件,確保以下配置:
network.host: 0.0.0.0
http.port: 9200
/opt/elasticsearch/bin/elasticsearch
Kibana是一個用于可視化Elasticsearch數據的Web界面工具。安裝Kibana可以更方便地管理和查看日志數據。
wget https://artifacts.elastic.co/downloads/kibana/kibana-7.10.2-linux-x86_64.tar.gz
tar -xzf kibana-7.10.2-linux-x86_64.tar.gz
mv kibana-7.10.2 /opt/kibana
編輯/opt/kibana/config/kibana.yml
文件,確保以下配置:
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://localhost:9200"]
/opt/kibana/bin/kibana
接下來,您需要在CentOS上安裝Filebeat。
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.10.2-linux-x86_64.tar.gz
tar -xzf filebeat-7.10.2-linux-x86_64.tar.gz
mv filebeat-7.10.2 /opt/filebeat
編輯/opt/filebeat/filebeat.yml
文件,確保以下配置:
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
output.elasticsearch:
hosts: ["localhost:9200"]
/opt/filebeat/bin/filebeat -e -c /opt/filebeat/filebeat.yml
打開瀏覽器,訪問http://<your_server_ip>:5601
,如果安裝了Kibana,您應該能夠看到Kibana的界面。如果沒有安裝Kibana,您可以直接使用Elasticsearch的REST API來查看Filebeat發送的數據。
curl -X GET "localhost:9200/_cat/indices?v"
您應該能夠看到Filebeat發送的索引數據。
通過以上步驟,您已經成功地將Filebeat與Elasticsearch集成在CentOS上。