在CentOS上部署Filebeat的步骤如下:
sudo yum update -y
yum-utils
。sudo yum install -y yum-utils
从Elastic官方网站下载适用于CentOS的Filebeat软件包。例如,下载Filebeat 7.x.x版本。
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.x.x-linux-x86_64.tar.gz
解压下载的Filebeat软件包到指定目录。
tar -zxvf filebeat-7.x.x-linux-x86_64.tar.gz -C /opt/
进入解压后的Filebeat目录,编辑 filebeat.yml
配置文件。
cd /opt/filebeat
vim filebeat.yml
修改以下配置项:
filebeat.inputs
:指定要监控的日志文件路径。output.elasticsearch
:配置Elasticsearch的地址和端口。setup.kibana
:配置Kibana的地址(如果需要)。使用以下命令启动Filebeat,并设置为系统服务以便开机自启动。
nohup ./filebeat -e -c filebeat.yml &
创建Systemd服务文件以便管理Filebeat服务。
sudo nano /lib/systemd/system/filebeat.service
添加以下内容:
[Unit]
Description=Filebeat
Wants=network-online.target
After=network-online.target
[Service]
User=root
Group=root
ExecStart=/opt/filebeat/filebeat -e -c /opt/filebeat/filebeat.yml
Restart=always
[Install]
WantedBy=multi-user.target
重新加载Systemd配置并启动Filebeat服务。
sudo systemctl daemon-reload
sudo systemctl enable filebeat
sudo systemctl start filebeat
访问Kibana界面确认Filebeat是否成功将日志数据发送到Elasticsearch。
以上步骤提供了一个基本的Filebeat部署流程,具体版本可能会有所不同,请根据实际情况进行调整。