在CentOS上安全部署Filebeat,可以遵循以下步骤:
1. 安装Elasticsearch和Kibana(如果尚未安装)
Filebeat通常与Elasticsearch和Kibana一起使用,以便收集、处理和可视化日志数据。
安装Elasticsearch
sudo yum install -y elasticsearch
sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch
安装Kibana
sudo yum install -y kibana
sudo systemctl start kibana
sudo systemctl enable kibana
2. 下载并安装Filebeat
从Elastic官方网站下载最新版本的Filebeat。
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.10.0-amd64.rpm
sudo rpm -ivh filebeat-7.10.0-amd64.rpm
3. 配置Filebeat
编辑Filebeat配置文件 /etc/filebeat/filebeat.yml。
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
# 输出到Elasticsearch
output.elasticsearch:
hosts: ["localhost:9200"]
index: "filebeat-%{[agent.version]}-%{+yyyy.MM.dd}"
# 启用X-Pack安全特性(可选)
xpack.monitoring.collection.enabled: true
# 配置TLS/SSL(如果需要加密传输)
setup.template.settings:
index.number_of_shards: 1
setup.template.name: "filebeat"
setup.template.pattern: "filebeat-*"
setup.ilm.enabled: true
setup.ilm.template.name: "filebeat"
setup.ilm.template.pattern: "filebeat-*"
setup.ilm.rollover_alias: "filebeat"
4. 启用并启动Filebeat
sudo systemctl enable filebeat
sudo systemctl start filebeat
5. 配置防火墙
确保Elasticsearch和Kibana的端口(默认是9200和5601)在防火墙中开放。
sudo firewall-cmd --permanent --zone=public --add-port=9200/tcp
sudo firewall-cmd --permanent --zone=public --add-port=5601/tcp
sudo firewall-cmd --reload
6. 配置Elasticsearch安全设置
为了提高安全性,建议配置Elasticsearch的用户认证和授权。
创建Elasticsearch用户
sudo bin/elasticsearch-setup-passwords interactive
按照提示创建一个超级用户和其他必要的用户。
配置Elasticsearch
编辑 /etc/elasticsearch/elasticsearch.yml 文件,添加以下内容:
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.keystore.path: elastic-certificates.p12
xpack.security.http.ssl.truststore.path: elastic-certificates.p12
重启Elasticsearch
sudo systemctl restart elasticsearch
7. 配置Filebeat使用TLS/SSL
编辑 /etc/filebeat/filebeat.yml 文件,添加TLS/SSL配置:
setup.template.settings:
index.number_of_shards: 1
setup.template.name: "filebeat"
setup.template.pattern: "filebeat-*"
setup.ilm.enabled: true
setup.ilm.template.name: "filebeat"
setup.ilm.template.pattern: "filebeat-*"
setup.ilm.rollover_alias: "filebeat"
output.elasticsearch:
hosts: ["https://localhost:9200"]
ssl.certificate_authorities: ["/etc/pki/tls/certs/ca-bundle.crt"]
ssl.certificate: "/etc/pki/tls/certs/filebeat.crt"
ssl.key: "/etc/pki/tls/private/filebeat.key"
8. 验证部署
检查Filebeat日志以确保没有错误:
sudo journalctl -u filebeat -f
访问Kibana界面(通常是 http://your_server_ip:5601),验证Filebeat数据是否正确导入。
通过以上步骤,你可以在CentOS上安全部署Filebeat,并确保数据传输的安全性。
以上就是关于“如何在CentOS上安全部署Filebeat”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm