在CentOS上配置Filebeat的步骤如下:
使用YUM仓库安装:
sudo tee /etc/yum.repos.d/elastic-beats.repo <<EOF
[elastic-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF
sudo yum install filebeat
sudo systemctl start filebeat
sudo systemctl enable filebeat
sudo systemctl status filebeat
手动下载并安装:
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.6.2-amd64.deb
tar -xvf filebeat-8.6.2-amd64.deb
sudo mv /usr/share/filebeat-8.6.2 /opt/filebeat
sudo ln -s /opt/filebeat/bin/filebeat /usr/local/bin/filebeat
sudo filebeat -e -c /etc/filebeat/filebeat.yml
sudo systemctl enable filebeat
sudo systemctl start filebeat
/etc/filebeat/filebeat.yml
。vi
或nano
)编辑配置文件。filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
output.elasticsearch:
hosts:
- "localhost:9200"
username: "elastic"
password: "your_password"
sudo vim /etc/systemd/system/filebeat.service
添加或修改以下内容:[Unit]
Description=Filebeat
Wants=network-online.target
After=network-online.target
[Service]
User=root
ExecStart=/usr/share/filebeat/filebeat -e -c /etc/filebeat/filebeat.yml
Restart=always
[Install]
WantedBy=multi-user.target
保存并退出编辑器,然后重新加载systemd配置并启动Filebeat服务:sudo systemctl daemon-reloads
sudo systemctl enable filebeat
sudo systemctl start filebeat
sudo journalctl -f -u filebeat
setup.kibana:
host: "localhost:5601"
确保Kibana也在运行,并且Filebeat可以访问它。以上步骤提供了在CentOS上配置Filebeat的基本流程。根据你的具体需求,你可能需要进一步调整和优化配置。