在Red Hat Enterprise Linux 5.8上安装systemtap

来源:互联网 发布:新视野大学英语软件 编辑:程序博客网 时间:2024/05/19 16:38
       根据http://sourceware.org/systemtap/wiki/SystemTapOnRHEL5里面的内容了解到,由于systemtap有Red Hat Enterprise Linux 5的rpm包,所以我决定不使用源代码的方式,而是使用官方发布的rpm包进行安装。按照上面链接中的说明,安装需要利用rhn登陆redhat官方的repo,然后使用repo中的rpm包安装就行了。由于公司没有rhn,所以只好使用安装盘进行安装。如果有rhn的话,就可以不用看本文的后面部分了,直接按照链接中所示的方法进行安装就好了。

       在需要安装systemtap的机器上mount Red Hat Enterprise Linux 5.8的安装盘,使用yum search systemtap后发现有如图所示的rpm包。

看来我们的运气不错,systemtap已经包含在Red Hat Enterprise Linux 5.8的安装盘中了。不过里面的systemtap的版本是1.6的,目前最新(2013-02-18)的版本为2.1。

       使用yum install systemtap安装systemtap,安装完成后,根据官方的文档使用命令stap -ve 'probe begin { log("hello world") exit () }'进行测试,systemtap执行正确,输出的结果如图所示。


但使用另外一个命令stap -v -e 'probe vfs.read {printf("read performed\n"); exit()}'进行测试时却出现错误的提示,提示的大意是说需要安装内核的

debug-info(请注意这里的debug-info指的不是debug版的内核),按照SystemTap_Beginners_Guide中的指示,使用uname -r获得了内核的准确版本信息,如图所示。


根据得到的内核版本信息,我在ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/os/i386/Debuginfo/kernel-debuginfo-2.6.18-308.el5.i686.rpm以及ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/os/i386/Debuginfo/kernel-debuginfo-common-2.6.18-308.el5.i686.rpm下载了内核的调试信息。使用rpm -i安装上述rpm包后,再次测试stap -v -e 'probe vfs.read {printf("read performed\n"); exit()}'

命令,这次systemtap执行正确,输出的结果如图4所示。这说明systemtap已经安装成功了。
        如果用户想使用systemtap对用户程序进行probe的话,根据systemTap_Beginners_Guide中的描述,还需要在系统中安装utrace。由于我暂时还没有这样的使用需求,所以就没有进行这方面相关的测试。
        在写本文时才发现,其实Red Hat Enterprise Linux 5.8的安装盘中就有内核的debug-info,大家可以试一下安装盘中的debug-info是否有效果。
       systemtap tutorial以及systemTap_Beginners_Guide里面的内容对于systemtap入门非常有帮助。希望有兴趣的朋友可以花时间进行一些了解。大家还可以安装systemtap-testsuite,这个安装包里面有很多实用的脚本,大家可以通过这些脚本更加深入的对systemtap进行学习。