在CentOS上配置FileBeat以使用SSL加密涉及几个步骤。以下是一个基本的指南,帮助你设置FileBeat以通过SSL/TLS加密传输数据。
如果你没有SSL证书和私钥,可以使用OpenSSL生成自签名证书。
# 生成私钥
openssl genrsa -out filebeat.key 2048
# 生成证书签名请求
openssl req -new -key filebeat.key -out filebeat.csr -subj "/CN=localhost"
# 生成自签名证书
openssl x509 -req -days 365 -in filebeat.csr -signkey filebeat.key -out filebeat.crt
编辑FileBeat的配置文件(通常是/etc/filebeat/filebeat.yml
),添加或修改输出部分以使用SSL/TLS。
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
output.elasticsearch:
hosts: ["https://your_elasticsearch_host:9200"]
ssl.verification_mode: certificate
ssl.certificate_authorities: ["/etc/filebeat/filebeat.crt"]
ssl.certificate: "/etc/filebeat/filebeat.crt"
ssl.key: "/etc/filebeat/filebeat.key"
确保你的Elasticsearch集群已经配置为接受SSL/TLS连接。编辑Elasticsearch的配置文件(通常是/etc/elasticsearch/elasticsearch.yml
),添加或修改以下部分:
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
http.ssl.enabled: true
http.ssl.certificate: /etc/elasticsearch/elasticsearch.crt
http.ssl.key: /etc/elasticsearch/elasticsearch.key
重启FileBeat和Elasticsearch服务以应用更改。
# 重启FileBeat
sudo systemctl restart filebeat
# 重启Elasticsearch
sudo systemctl restart elasticsearch
确保FileBeat能够成功连接到Elasticsearch并传输数据。你可以查看FileBeat和Elasticsearch的日志文件以确认没有错误。
# 查看FileBeat日志
sudo journalctl -u filebeat -f
# 查看Elasticsearch日志
sudo journalctl -u elasticsearch -f
通过以上步骤,你应该能够在CentOS上成功配置FileBeat以使用SSL/TLS加密传输数据。
亿速云提供多种品牌、不同类型SSL证书签发服务,包含:域名型、企业型、企业型专业版、增强型以及增强型专业版,单域名SSL证书300元/年起。点击查看>>