Linux问题情报分享(3):CentOS 7上最新kernel-debuginfo包与当前内核版本不匹配

简介: 升级了下系统,而后运行SystemTap脚本失败。原因竟然是升级了kernel-debuginfo包所致。

CentOS 7上最新的kernel-debuginfo包,是kernel-debuginfo-4.x.x-x.el7,而当前内核是kernel-3.10.0。因此,如果安装或者升级到了最新的kernel-debuginfo包,会导致类似SystemTap这样需要内核头文件和调试符号的工具执行出错。这是CentOS 7的bug

SystemTap为例,其报错大致如下

[root@pusf ~]# rpm -qa | grep kernel-debuginfo
kernel-debuginfo-4.9.31-203.el7.centos.x86_64
kernel-debuginfo-common-x86_64-4.9.31-203.el7.centos.x86_64[root@pusf ~]
[root@pusf ~]# stap -v -e 'probe vfs.read {printf("read performed\n"); exit()}'
Pass 1: parsed user script and 119 library scripts using 117224virt/33688res/3120shr/30824data kb, in 240usr/10sys/292real ms.
semantic error: while resolving probe point: identifier 'kernel' at /usr/share/systemtap/tapset/linux/vfs.stp:882:18
        source: probe vfs.read = kernel.function("vfs_read")
                      ^
semantic error: missing x86_64 kernel/module debuginfo [man warning::debuginfo] under '/lib/modules/3.10.0-514.26.2.el7.x86_64/build'
semantic error: while resolving probe point: identifier 'vfs' at <input>:1:7
        source: probe vfs.read {printf("read performed\n"); exit()}
                      ^
semantic error: no match

Pass 2: analyzed script: 0 probes, 0 functions, 0 embeds, 0 globals using 120568virt/37092res/5108shr/32068data kb, in 100usr/140sys/443real ms.
Missing separate debuginfos, use: debuginfo-install kernel-3.10.0-514.26.2.el7.x86_64
Pass 2: analysis failed.  [man error::pass2]
[root@pusf ~]#

因此,出现这种情况时,需要卸载kernel-debuginfo-4.x.x-x.el7和kernel-debuginfo-common-4.x.x-x.el7的包,重新按照当前内核版本安装kernel-debuginfo即可

rpm -qa | grep -E '^kernel-' | grep -v 3.10.0 | xargs yum -y remove
debuginfo-install -y kernel-$(uname -r)

再测试下SystemTap的脚本,会发现问题已经解决了

[root@pusf ~]# rpm -qa | grep kernel-debuginfo                    
kernel-debuginfo-common-x86_64-3.10.0-514.26.2.el7.x86_64
kernel-debuginfo-3.10.0-514.26.2.el7.x86_64
[root@pusf ~]# stap -v -e 'probe vfs.read {printf("read performed\n"); exit()}'

Pass 1: parsed user script and 119 library scripts using 117224virt/33684res/3120shr/30824data kb, in 230usr/10sys/293real ms.

Pass 2: analyzed script: 1 probe, 1 function, 4 embeds, 0 globals using 248216virt/165932res/4336shr/161816data kb, in 1260usr/370sys/1809real ms.

Pass 3: translated to C into "/tmp/stapI5iwL4/stap_1aa47f863c3f13e51da3e80cc92942be_1682_src.c" using 248216virt/166236res/4640shr/161816data kb, in 20usr/40sys/57real ms. 

Pass 4: compiled C into "stap_1aa47f863c3f13e51da3e80cc92942be_1682.ko" in 5550usr/1240sys/7187real ms.

Pass 5: starting run.
read performed
Pass 5: run completed in 0usr/60sys/378real ms.
[root@pusf ~]#

在CentOS官方修正bug前,可以在/etc/yum.conf中加入如下配置,先排除问题包

exclude=kernel-debuginfo*

这样,升级时不会再次安装了问题包。当然,内核升级时,需要额外调整下配置。

顺便说下,在Ubuntu上使用SystemTap,需要额外配置和步骤,请参考SystemTap on Ubuntu

参考

  1. SystemTap
  2. SystemTap on CentOS
  3. SystemTap on Ubuntu
  4. Where to find the kernel-debuginfo package
相关文章
|
14天前
|
应用服务中间件 Linux nginx
【Azure App Service】基于Linux创建的App Service是否可以主动升级内置的Nginx版本呢?
基于Linux创建的App Service是否可以主动升级内置的Nginx版本呢?Web App Linux 默认使用的 Nginx 版本是由平台预定义的,无法更改这个版本。
126 77
|
3月前
|
安全 Linux 虚拟化
|
2月前
|
运维 监控 安全
CentOS 7系统 OpenSSH和OpenSSL版本升级指南
本文详细介绍如何在CentOS 7系统上升级OpenSSH和OpenSSL至最新稳定版本(OpenSSH 9.6p1和OpenSSL 1.1.1w),解决多个已知安全漏洞(如CVE-2023-51767等)。涵盖环境说明、现存漏洞、升级准备、具体步骤及故障排查,确保服务器安全。建议先在测试环境验证,再应用于生产环境。
200 7
|
4月前
|
安全 关系型数据库 MySQL
Linux下安装mysql8.0(以tar.xz包安装--编译安装)
通过上述步骤,您完成了从下载、编译、安装到配置MySQL 8.0的全过程。此过程虽然较为复杂,但提供了对MySQL安装环境的完全控制,有助于满足特定的部署需求。在实际操作中,根据具体的系统环境,可能还需调整部分步骤或解决未预见的依赖问题。始终参考官方文档和社区资源,保持安装过程与最新版本的兼容性。
1639 67
|
4月前
|
Linux 编译器 测试技术
【C++】CentOS环境搭建-快速升级G++版本
通过上述任一方法,您都可以在CentOS环境中高效地升级G++至所需的最新版本,进而利用C++的新特性,提升开发效率和代码质量。
281 64
|
4月前
|
Linux 编译器 测试技术
【C++】CentOS环境搭建-快速升级G++版本
通过上述任一方法,您都可以在CentOS环境中高效地升级G++至所需的最新版本,进而利用C++的新特性,提升开发效率和代码质量。
318 63
|
4月前
|
Linux 网络安全 数据安全/隐私保护
Linux系统之Centos7安装cockpit图形管理界面
【10月更文挑战第12天】Linux系统之Centos7安装cockpit图形管理界面
171 1
Linux系统之Centos7安装cockpit图形管理界面
|
4月前
|
Kubernetes Linux 测试技术
|
4月前
|
Kubernetes Linux 开发工具
centos7通过kubeadm安装k8s 1.27.1版本
centos7通过kubeadm安装k8s 1.27.1版本
|
4月前
|
安全 Linux 编译器
Centos 7.9如何使用源码编译安装curl最新版本
通过上述步骤,您就能在CentOS 7.9上成功地从源代码编译并安装curl的最新版本。这种方法不仅提供了灵活性,允许您定制编译选项,还确保了软件的最新功能和安全更新得到应用。
186 1