--- title: "在 Ubuntu 22.04 上运行 Filebeat 7.10.2" date: 2025-01-20 lastmod: 2025-01-20 description: "在Ubuntu 22.04上运行Filebeat 7.10.2时,因glibc版本较高导致缺少rseq系统调用而报错。可通过关闭seccomp或添加seccomp配置允许rseq调用解决,推荐后者以保障安全性。" tags: ["Filebeat", "Ubuntu"] summary: "环境 # 操作系统:阿里云 Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-83-generic x86_64) 软件版本:Filebeat 7.10.2 用户:root 运行 # 下载 从 这里下载 filebeat 7.10.2。 配置 简单配置一下 filebeat.yml,从标准输入采集,写入到标准输出 : filebeat.inputs: - type: stdin output.console: pretty: true 运行 因为使用 root 用户,根据 官方建议添加 --strict.perms=false 参数。 直接运行 ./filebeat -e –strict.perms=false: 出现异常: runtime/cgo: pthread_create failed: Operation not permitted SIGABRT: abort PC=0x7f123c7cc9fc m=3 sigcode=18446744073709551610 分析 # 网上搜索一下问题,发现有位网友也遇到了同样问题,并且解决了, 解决方案是添加如下配置: seccomp: default_action: allow syscalls: - action: allow names: - rseq 通过 官网文档了解seccomp:在 Linux 3." --- ## 环境 操作系统:阿里云 Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-83-generic x86_64) 软件版本:Filebeat 7.10.2 用户:root ## 运行 1. 下载 从[这里](https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.10.2-linux-x86_64.tar.gz)下载 filebeat 7.10.2。 2. 配置 简单配置一下 filebeat.yml,从标准输入采集,写入到标准输出 : ```plain filebeat.inputs: - type: stdin output.console: pretty: true ``` 3. 运行 因为使用 root 用户,根据[官方建议](https://www.elastic.co/guide/en/beats/filebeat/7.10/filebeat-installation-configuration.html#CO6-1)添加 `--strict.perms=false` 参数。 直接运行 ./filebeat -e --strict.perms=false: {{% load-img "/img/blog/2025/ubuntu_run_filebeat/01.png" %}} 出现异常: ```plain runtime/cgo: pthread_create failed: Operation not permitted SIGABRT: abort PC=0x7f123c7cc9fc m=3 sigcode=18446744073709551610 ``` ## 分析 网上搜索一下问题,发现有位网友也遇到了同样问题,并且解决了,[解决方案](https://blog.csdn.net/weixin_45112997/article/details/135777194)是添加如下配置: ```plain seccomp: default_action: allow syscalls: - action: allow names: - rseq ``` 通过[官网文档](https://www.elastic.co/guide/en/beats/filebeat/7.10/linux-seccomp.html)了解seccomp:在 Linux 3.17 及更高版本上,Filebeat 使用安全计算模式,也称为 Seccomp。Seccomp 限制进程可以发出的系统调用,默认开启。 结合网友的解决方案,得出初步结论:Filebeat 7.10.2 运行在 Ubuntu 22.04 上时缺少 `rseq` 系统调用,导致异常。 通过查找 `syscall` 错误: ```plain goroutine 44 [syscall]: syscall.Syscall(0x0, 0x0, 0xc00070c000, 0x4000, 0xc000122000, 0x800000, 0x7ffff800000) /usr/local/go/src/syscall/asm_linux_amd64.s:18 +0x5 syscall.read(0x0, 0xc00070c000, 0x4000, 0x4000, 0x0, 0x0, 0x16e3b0e) /usr/local/go/src/syscall/zsyscall_linux_amd64.go:686 +0x5a syscall.Read(...) /usr/local/go/src/syscall/syscall_unix.go:189 ``` 在官网找到[相关问题](https://discuss.elastic.co/t/filebeat-and-glibc-errors-on-ubuntu-22-04/306653),因为 `glibc >= 2.35`,但 beats 里允许的默认系统调用中没有 rseq 导致的异常。问题已在 7.17.2 版本[修复](https://github.com/elastic/beats/pull/30620)。 验证 glibc 版本,确实为 2.35。 {{% load-img "/img/blog/2025/ubuntu_run_filebeat/02.png" %}} 最终得出结论:因为 glibc >= 2.35,但 beats 里允许的默认系统调用中没有 rseq 导致的异常。 ## 总结 通过上面的问题分析,得出有如下 2 种解决办法: 1. 关闭 seccomp(不推荐) 2. 添加 seccomp 配置,允许 rseq 系统调用 ## 验证 1. 关闭 seccomp ```plain filebeat.inputs: - type: stdin output.console: pretty: true seccomp: enabled: false ``` {{% load-img "/img/blog/2025/ubuntu_run_filebeat/03.png" %}} 但关闭 seccomp,就不能基于最小特权原则限制 filebeat 的系统调用,进而最大限度的减少未知漏洞的影响。 2. 添加 seccomp 配置,允许 rseq 系统调用 ```plain filebeat.inputs: - type: stdin output.console: pretty: true seccomp: default_action: allow syscalls: - action: allow names: - rseq ``` {{% load-img "/img/blog/2025/ubuntu_run_filebeat/04.png" %}}