温馨提示×

CentOS如何卸载Filebeat

小樊
46
2026-07-08 16:32:12
栏目: 智能运维

CentOS 上卸载 Filebeat,可以按下面步骤操作,干净彻底。


一、停止并禁用 Filebeat 服务

sudo systemctl stop filebeat
sudo systemctl disable filebeat

二、卸载 Filebeat(根据安装方式)

✅ 方式一:通过 RPM / YUM 安装(最常见)

查看是否已安装:

rpm -qa | grep filebeat

卸载:

sudo yum remove filebeat -y

或(较老系统):

sudo rpm -e filebeat

✅ 方式二:通过 APT(不常见于 CentOS,可忽略)

CentOS 一般不用 apt,仅在极少数情况才会出现。


✅ 方式三:手动安装的 Filebeat(.tar.gz)

如果你是手动解压部署的:

sudo systemctl stop filebeat
sudo rm -rf /etc/filebeat
sudo rm -rf /usr/share/filebeat
sudo rm -f /etc/systemd/system/filebeat.service
sudo systemctl daemon-reload

三、删除配置和数据(非常重要)

Filebeat 的默认路径:

# 配置文件
sudo rm -rf /etc/filebeat

# 数据目录
sudo rm -rf /var/lib/filebeat

# 日志目录
sudo rm -rf /var/log/filebeat

四、清理 Elastic 相关注册信息(可选)

如果 Filebeat 曾向 Elasticsearch 注册:

# 删除 Elasticsearch 中的 filebeat 索引
curl -X DELETE "http://localhost:9200/filebeat-*"

(如启用了认证,需要加 -u elastic:password


五、验证是否已卸载

filebeat version
systemctl status filebeat
rpm -qa | grep filebeat

常见残留说明

内容 说明
/etc/filebeat 配置文件
/var/lib/filebeat 注册表(记录采集位置)
/var/log/filebeat 运行日志
systemd service 服务定义

如果你愿意,可以告诉我:

  • CentOS 版本(6 / 7 / 8 / Stream)
  • Filebeat 安装方式(yum / 手动 / Ansible)

我可以给你一条完全无残留的卸载命令。

0