在 CentOS 上,Filebeat 的“鉴权”通常指 Filebeat 访问后端服务(如 Elasticsearch、Kafka、Logstash)时的身份认证,而不是 Linux 系统登录鉴权。下面按常见场景说明。
适用于 Elasticsearch 开启安全模式(xpack.security)
filebeat.yml
output.elasticsearch:
hosts: ["https://es-node1:9200"]
username: "filebeat_writer"
password: "your_password"
ssl.certificate_authorities: ["/etc/filebeat/certs/ca.crt"]
⚠️ 不建议明文密码,可用 keystore
filebeat keystore create
filebeat keystore add ES_PASSWORD
output.elasticsearch:
hosts: ["https://es-node1:9200"]
username: "filebeat_writer"
password: "${ES_PASSWORD}"
output.logstash:
hosts: ["logstash:5044"]
username: "filebeat"
password: "secret"
output.logstash:
hosts: ["logstash:5044"]
ssl.certificate: "/etc/filebeat/certs/filebeat.crt"
ssl.key: "/etc/filebeat/certs/filebeat.key"
ssl.certificate_authorities: ["/etc/filebeat/certs/ca.crt"]
output.kafka:
hosts: ["kafka1:9092"]
topic: "logs"
username: "filebeat"
password: "kafka_pass"
sasl.mechanism: PLAIN
ssl.certificate_authorities: ["/etc/filebeat/certs/ca.crt"]
如果是 Filebeat 作为服务端(如 Filebeat 接收 Beats input),可配置:
filebeat.inputs:
- type: beats
host: "0.0.0.0:5044"
ssl.certificate: "/etc/filebeat/certs/filebeat.crt"
ssl.key: "/etc/filebeat/certs/filebeat.key"
Filebeat 以 systemd 运行:
systemctl status filebeat
配置文件权限建议:
chown root:root /etc/filebeat/filebeat.yml
chmod 600 /etc/filebeat/filebeat.yml
filebeat test config
filebeat test output
journalctl -u filebeat -f
如果你能说明 具体是 Filebeat 连哪个组件(ES / Kafka / Logstash),我可以给你一份 可直接用的 CentOS 配置示例。