hl10502的博客

CentOS7.2安装systemtap

systemtap是监控和跟踪运行中的 Linux 内核的操作的动态方法。

环境

  • CentOS Linux release 7.2.1511 (Core) Min版
1
2
3
4
[root@node ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[root@node ~]# uname -r
3.10.0-327.el7.x86_64

安装依赖

安装systemtap依赖的rpm包

1
2
[root@node ~]# yum install --downloadonly --downloaddir=/tmp/other gcc zip unzip perl mokutil libdwarf boost-system boost-thread kernel-devel-uname-r
[root@node ~]# yum localinstall -yC --disablerepo=* /tmp/other/*.rpm

安装systemtap

1
2
[root@node ~]# yum install --downloadonly --downloaddir=/tmp/systemtap systemtap
[root@node ~]# yum localinstall -yC --disablerepo=* /tmp/systemtap/*.rpm

安装内核调试包

查看内核版本

1
2
[root@node ~]# uname -r
3.10.0-327.el7.x86_64

确认下载与内核版本一致的调试包,安装debuginfo包需要在yum命令中添加 --enablerepo=*-debuginfo

1
[root@node ~]# yum --enablerepo=*-debuginfo install --downloadonly --downloaddir=/tmp/kernel-debuginfo kernel-debuginfo-3.10.0-327.el7 kernel-debuginfo-common-x86_64-3.10.0-327.el7

由于kernel-debuginfo、kernel-debuginfo-common包比较大,可以直接下载
http://debuginfo.centos.org/7/x86_64/kernel-debuginfo-3.10.0-327.el7.x86_64.rpm
http://debuginfo.centos.org/7/x86_64/kernel-debuginfo-common-x86_64-3.10.0-327.el7.x86_64.rpm

kernel-devel下载地址,下载之后放入/tmp/kernel-debuginfo/目录
http://rpm.pbone.net/index.php3/stat/4/idpl/31979931/dir/centos_7/com/kernel-devel-3.10.0-327.el7.x86_64.rpm.html

安装kernel-debuginfo、kernel-debuginfo-common、kernel-devel包

1
[root@node ~]# yum localinstall -yC --disablerepo=* /tmp/kernel-debuginfo/*.rpm

安装验证

验证,如果没有提示错误,就是安装成功了。

1
2
3
4
5
6
7
8
[root@node ~]# stap -v -e 'probe vfs.read{printf("read performed\n"); exit()}'
Pass 1: parsed user script and 466 library scripts using 226048virt/39160res/3304shr/36016data kb, in 420usr/40sys/623real ms.
Pass 2: analyzed script: 1 probe, 1 function, 7 embeds, 0 globals using 352356virt/166700res/4596shr/162324data kb, in 2120usr/720sys/5246real ms.
Pass 3: translated to C into "/tmp/stapgSQMsO/stap_4a25503e3b30a75bc7067bab5f510801_2661_src.c" using 352356virt/166964res/4860shr/162324data kb, in 10usr/50sys/64real ms.
Pass 4: compiled C into "stap_4a25503e3b30a75bc7067bab5f510801_2661.ko" in 8550usr/1530sys/10476real ms.
Pass 5: starting run.
read performed
Pass 5: run completed in 0usr/40sys/346real ms.

安装ceph调试信息包

下载ceph-debuginfo包,包比较大,有1G多,从网易下载对应ceph版本的ceph-debuginfo
http://mirrors.163.com/ceph/rpm-luminous/el7/x86_64/ceph-debuginfo-12.2.0-0.el7.x86_64.rpm

安装ceph-debuginfo

1
[root@node ~]# yum localinstall -yC --disablerepo=* ceph-debuginfo/*.rpm