filebeat能否在ubuntu上远程部署
导读:可行性与总体思路 可以。Filebeat 是轻量级日志采集器,支持在 Ubuntu 主机上安装后,将本机日志直接发送到远程的 Elasticsearch、Logstash 或 Kafka 等目标;也可以先在远程 Ubuntu 上安装,再由其...
可行性与总体思路 可以。Filebeat 是轻量级日志采集器,支持在 Ubuntu 主机上安装后,将本机日志直接发送到远程的 Elasticsearch、Logstash 或 Kafka 等目标;也可以先在远程 Ubuntu 上安装,再由其采集并回传至中心集群。常见做法是:在目标 Ubuntu 上安装 Filebeat,配置 inputs 指向本地日志路径,配置 outputs 指向远程输出端,最后以 systemd 托管常驻运行。
部署与配置步骤
- 安装 Filebeat(Ubuntu 20.04/22.04 示例)
- 更新索引并添加 Elastic GPG 与 APT 源(版本号可按需调整):
- sudo apt update
- wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
- echo “deb https://artifacts.elastic.co/packages/7.x/apt stable main” | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
- sudo apt update
- sudo apt install filebeat
- 更新索引并添加 Elastic GPG 与 APT 源(版本号可按需调整):
- 配置采集与输出
- 编辑配置文件 /etc/filebeat/filebeat.yml,示例:
- 采集系统与应用日志:
- filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/syslog
- /var/log/apache2/*.log
- type: log
enabled: true
paths:
- filebeat.inputs:
- 输出到远程 Elasticsearch(示例):
- output.elasticsearch:
- hosts: [“es.example.com:9200”]
- index: “filebeat-%{ [agent.version]} -%{ +yyyy.MM.dd} ”
- output.elasticsearch:
- 或输出到远程 Logstash(示例):
- output.logstash:
- hosts: [“logstash.example.com:5044”]
- output.logstash:
- 采集系统与应用日志:
- 编辑配置文件 /etc/filebeat/filebeat.yml,示例:
- 启动与开机自启
- sudo systemctl start filebeat
- sudo systemctl enable filebeat
- 验证
- 查看服务状态:sudo systemctl status filebeat
- 查看运行日志:sudo journalctl -u filebeat -f
- 在 ES 或 Logstash 侧确认是否收到事件(如 ES:curl -X GET “localhost:9200/_cat/indices?v”;Logstash:tail -f /var/log/logstash/logstash-plain.log)
安全与网络要点
- 启用 TLS/HTTPS 与认证:在 output.elasticsearch 中设置 protocol: https、ssl.verification_mode、ssl.certificate_authorities、ssl.certificate、ssl.key,以及用户名/密码等;自签名证书可按需将 ssl.verification_mode 设为 none(仅测试环境)。示例:
- output.elasticsearch:
- hosts: [“your_elasticsearch_host:9200”]
- protocol: “https”
- ssl.verification_mode: “full”
- ssl.certificate_authorities: [“/path/to/ca.crt”]
- ssl.certificate: “/path/to/client.crt”
- ssl.key: “/path/to/client.key”
- user: “elastic”
- password: “your_password”
- output.elasticsearch:
- 防火墙与监听
- 若输出到远程 Logstash,需在 Logstash 所在主机放行 5044 端口;若直连 Elasticsearch,确保 ES 的 9200 端口对 Filebeat 主机可达。
- 多输出与高可用
- Filebeat 支持同时配置多个输出(如同时到 ES 与 Logstash),并支持负载均衡与故障转移(按官方配置启用相关选项)。
大规模远程部署建议
- 使用 Ansible 批量部署与配置管理(如 ansible-beats 角色),可在多台 Ubuntu 主机上统一安装、下发配置、版本升级与一致性维护,适合生产级规模化落地。
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: filebeat能否在ubuntu上远程部署
本文地址: https://pptw.com/jishu/767071.html
