要将Filebeat与Elasticsearch集成在CentOS上,您需要按照以下步骤操作:
首先,您需要在CentOS上安装Elasticsearch。可以从Elastic官方网站下载适合您系统的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上。