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
相关文章
|
2月前
|
Ubuntu Linux
Ubuntu 23.04 用上 Linux 6.2 内核,预计下放到 22.04 LTS 版本
Linux 6.2 带来了多项内容更新,修复了 AMD 锐龙处理器设备在启用 fTPM 后的运行卡顿问题,还增强了文件系统。
|
2月前
|
Ubuntu Linux
Ubuntu24.04LTS默认采用Linux 6.8内核,实验性版本可通过PPA获得
IT之家提醒,当下的 Ubuntu 23.10 也是一个“短期支持版本”,该版本将在今年 7 月终止支持,而今年 4 月推出的 Ubuntu 24.04 LTS 长期支持版本将获得 5 年的更新支持。
|
2月前
|
Ubuntu 安全 小程序
linux|ubuntu.v18.10版本即将发布,linux桌面让您动心
如果你使用闭源系统,那永远也就别想了!有了这样的需求,也许最终将linux带到人类大众通用市场的是我们中国!
70 0
|
2月前
|
Web App开发 Ubuntu Linux
又该换Linux版本了!
如果你经常用谷歌搜索,使用终端输入命令,推荐你使用Fedora而不是Ubuntu。 如果你不是一个技术用户或程序员,仍推荐使用Ubuntu,还不动手去试试,别忘了将你的体验留在评论区哦~
|
3月前
|
Linux Docker Windows
windows docker安装报错适用于 Linux 的 Windows 子系统必须更新到最新版本才能继续。可通过运行 “wsl.exe --update” 进行更新。
适用于 Linux 的 Windows 子系统需更新至最新版本(如 wsl.2.4.11.0.x64.msi)以解决 2025 年 Windows 更新后可能出现的兼容性问题。用户可通过运行 “wsl.exe --update” 或访问提供的链接下载升级包进行更新。
1127 0
|
5月前
|
Linux 编译器 开发工具
提升CentOS 7中的gcc/G++版本
至此,你已经成功在CentOS 7中升级了gcc/G++版本。从现在开始,在终端中运行 `gcc`或 `g++`时,将会使用新版本的编译器。
513 21
|
5月前
|
消息中间件 NoSQL Linux
Redis的基本介绍和安装方式(包括Linux和Windows版本),以及常用命令的演示
Redis(Remote Dictionary Server)是一个高性能的开源键值存储数据库。它支持字符串、列表、散列、集合等多种数据类型,具有持久化、发布/订阅等高级功能。由于其出色的性能和广泛的使用场景,Redis在应用程序中常作为高速缓存、消息队列等用途。
880 16
|
6月前
|
Linux Shell
在Linux、CentOS7中设置shell脚本开机自启动服务
以上就是在CentOS 7中设置shell脚本开机自启动服务的全部步骤。希望这个指南能帮助你更好地管理你的Linux系统。
524 25
|
4月前
|
Oracle 关系型数据库 Linux
MyEMS开源系统安装之CentOS/RHEL/Rocky/AlmaLinux/Oracle Linux
本指南介绍如何在CentOS/RHEL/Rocky/AlmaLinux/Oracle Linux服务器上部署MyEMS开源能源管理系统。内容涵盖系统准备、数据库配置、多个MyEMS服务(如myems-api、myems-admin、myems-modbus-tcp等)的安装与配置,以及Nginx服务器设置和防火墙规则调整。通过完成所有步骤,您将能够访问MyEMS Admin UI和Web UI,默认端口分别为8001和80,初始登录凭据已提供。
201 0