日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
CentOS 7上Systemtap的安裝

按照SystemTap Beginners Guide的Installation and Setup部分安裝了SystemTap,但是在安裝過(guò)程中還是出現(xiàn)問(wèn)題,在這里記錄下解決方法。

目前創(chuàng)新互聯(lián)已為上1000家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)站空間、綿陽(yáng)服務(wù)器托管、企業(yè)網(wǎng)站設(shè)計(jì)、來(lái)鳳網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。

環(huán)境

  • linux發(fā)行版本:centos Linux release 7.4.1708 (Core)
  • 內(nèi)核版本:3.10.0-693.2.2.el7.x86_64
  • uname -a: Linux hostname 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

安裝

安裝SystemTap

先安裝如下兩個(gè)RPM包:

  • systemtap
  • systemtap-runtime

以root運(yùn)行如下命令:

# yum install systemtap systemtap-runtime

在運(yùn)行SystemTap之間,還需要裝必要的內(nèi)核信息包。在現(xiàn)代系統(tǒng)上,可以運(yùn)行如下stap-prep來(lái)安裝這些包,如下:

# stap-prep
Need to install the following packages:
kernel-devel-3.10.0-693.2.2.el7.x86_64
kernel-debuginfo-3.10.0-693.2.2.el7.x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
No package kernel-devel-3.10.0-693.2.2.el7.x86_64 available.
No package kernel-debuginfo-3.10.0-693.2.2.el7.x86_64 available.
Error: Nothing to do
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Could not find debuginfo for main pkg: kernel-3.10.0-693.2.2.el7.x86_64
No debuginfo packages available to install
package kernel-devel-3.10.0-693.2.2.el7.x86_64 is not installed
package kernel-debuginfo-3.10.0-693.2.2.el7.x86_64 is not installed
problem installing rpm(s) kernel-devel-3.10.0-693.2.2.el7.x86_64 kernel-debuginfo-3.10.0-693.2.2.el7.x86_64

運(yùn)行stap-prep的時(shí)候,它探測(cè)出還要安裝kernel-devel-3.10.0-693.2.2.el7.x86_64包和kernel-debuginfo-3.10.0-693.2.2.el7.x86_64包 (實(shí)際上還有kernel-debuginfo-common包),但是自動(dòng)安裝失敗。我們可以按照如下方法手動(dòng)安裝。

手動(dòng)安裝必要的內(nèi)核信息包

SystemTap需要安裝內(nèi)核內(nèi)核符號(hào)文件來(lái)probe內(nèi)核。必要的內(nèi)核信息包含在如下三個(gè)包中:

  • kernel-debuginfo
  • kernel-debuginfo-common
  • kernel-devel

一定要安裝與當(dāng)前內(nèi)核版本一致的包。當(dāng)前環(huán)境的內(nèi)核版本是3.10.0-693.2.2.el7.x86_64,所以需要安裝的包為:

  • kernel-debuginfo-3.10.0-693.2.2.el7.x86_64
  • kernel-debuginfo-common-3.10.0-693.2.2.el7.x86_64
  • kernel-devel-3.10.0-693.2.2.el7.x86_64

注意:其實(shí)在上一步運(yùn)行stap-prep時(shí),已經(jīng)把需要的包的名稱及其內(nèi)核精準(zhǔn)地打印在屏幕上了。

接下來(lái)安裝這三個(gè)包,注意不要直接yum install kernel-debuginfo kernel-debuginfo-common kernel-devel, 即使能找到相應(yīng)的包,也是安裝的最新版本,不會(huì)自動(dòng)匹配當(dāng)前版本。所以我們下載RPM包,再用rpm命令依次安裝。

對(duì)于CentOS來(lái)說(shuō),內(nèi)核符號(hào)文件一版在http://debuginfo.centos.org上有各個(gè)版本非常完整的包,但是一般從境內(nèi)下載都比較慢,特別是kernel-debuginfo,比較大下載可能非常慢。所以在debuginfo.centos.org上下了kernel-debuginfo-common包,另外兩個(gè)包在Google上搜了一把,分別找了兩個(gè)鏡像。下了之后才發(fā)現(xiàn)這個(gè)地方有坑,這個(gè)坑在后面展開講。

wget https://ftp.sjtu.edu.cn/scientific/7/archive/debuginfo/kernel-debuginfo-3.10.0-693.2.2.el7.x86_64.rpm
wget http://debuginfo.centos.org/7/x86_64/kernel-debuginfo-common-x86_64-3.10.0-693.2.2.el7.x86_64.rpm
wget ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/7.0/x86_64/updates/security/kernel-devel-3.10.0-693.2.2.el7.x86_64.rpm

下載之后,直接用rpm命令安裝就好:

# rpm -ivh kernel-debuginfo-common-x86_64-3.10.0-693.2.2.el7.x86_64.rpm
# rpm -ivh kernel-debuginfo-3.10.0-693.2.2.el7.x86_64.rpm
# rpm -ivh kernel-devel-3.10.0-693.2.2.el7.x86_64.rpm

至此安裝步驟完畢,下面來(lái)測(cè)試SystemTap能不能正常運(yùn)行。

運(yùn)行SystemTap

為了測(cè)試stap是否能正常運(yùn)行,用如下簡(jiǎn)單命令打印:

# stap -e 'probe begin{printf("Hello, World"); exit();}'

運(yùn)行失敗...結(jié)果如下:

# stap -e 'probe begin{printf("Hello, World"); exit();}'
ERROR: module version mismatch (#1 SMP Tue Sep 12 10:10:26 CDT 2017 vs #1 SMP Tue Sep 12 22:26:13 UTC 2017), release 3.10.0-693.2.2.el7.x86_64
WARNING: /usr/bin/staprun exited with status: 1
Pass 5: run failed.  [man error::pass5]

錯(cuò)誤信息是:"ERROR: module version mismatch (#1 SMP Tue Sep 1210:10:26 CDT 2017 vs #1 SMP Tue Sep 1222:26:13 UTC 2017)"。

解決"ERROR: module version mismatch"問(wèn)題

stap運(yùn)行的時(shí)候加上-v參數(shù),打印更多信息看看還有沒(méi)有更多線索:

# stap -e 'probe begin{printf("Hello, World"); exit();}' -v
Pass 1: parsed user script and 470 library scripts using 228224virt/41280res/3348shr/38020data kb, in 330usr/20sys/346real ms.
Pass 2: analyzed script: 1 probe, 1 function, 0 embeds, 0 globals using 229148virt/42332res/3536shr/38944data kb, in 0usr/0sys/6real ms.
Pass 3: using cached /root/.systemtap/cache/0b/stap_0bc9e27aef7a1de50ea41889a27fc524_1010.c
Pass 4: using cached /root/.systemtap/cache/0b/stap_0bc9e27aef7a1de50ea41889a27fc524_1010.ko
Pass 5: starting run.
ERROR: module version mismatch (#1 SMP Tue Sep 12 10:10:26 CDT 2017 vs #1 SMP Tue Sep 12 22:26:13 UTC 2017), release 3.10.0-693.2.2.el7.x86_64
WARNING: /usr/bin/staprun exited with status: 1
Pass 5: run completed in 0usr/10sys/38real ms.
Pass 5: run failed.  [man error::pass5]

查看c文件,vi /root/.systemtap/cache/0b/stap_0bc9e27aef7a1de50ea41889a27fc524_1010.c,搜錯(cuò)誤信息"module version mismatch",能搜到報(bào)錯(cuò)發(fā)生在下面的第13行,至于UTS_RELEASE和UTS_VERSION是在哪里設(shè)置的,直接Google一把。

#ifndef STP_NO_VERREL_CHECK
    const char* release = UTS_RELEASE;
    #ifdef STAPCONF_GENERATED_COMPILE
    const char* version = UTS_VERSION;
    #endif
    might_sleep();
    if (strcmp (release, "3.10.0-693.2.2.el7.x86_64")) {
      _stp_error ("module release mismatch (%s vs %s)", release, "3.10.0-693.2.2.el7.x86_64");
      rc = -EINVAL;
    }
    #ifdef STAPCONF_GENERATED_COMPILE
    if (strcmp (utsname()->version, version)) {
      _stp_error ("module version mismatch (%s vs %s), release %s", version, utsname()->version, release);
      rc = -EINVAL;
    }
    #endif
    #endif

# rpm -ql kernel-devel | xargs grep UTS_VERSION
/usr/src/kernels/3.10.0-693.2.2.el7.x86_64/include/generated/compile.h:#define UTS_VERSION "#1 SMP Tue Sep 12 10:10:26 CDT 2017"

可以看到在compile.h中有#define UTS_VERSION "#1 SMP Tue Sep 12 10:10:26 CDT 2017". 這個(gè)是不是很熟悉... 對(duì)比下上面運(yùn)行stap的報(bào)錯(cuò)信息, module mismatch的時(shí)間就是這個(gè)。文件compile.h是自動(dòng)生成的,可能和當(dāng)時(shí)編譯時(shí)的時(shí)間相關(guān)。但是stap要求這個(gè)也和當(dāng)前系統(tǒng)uname -a里面的時(shí)間完全一直,如果下個(gè)CentOS原生的kernel-devel應(yīng)該就沒(méi)這個(gè)問(wèn)題。

解決問(wèn)題的另一個(gè)簡(jiǎn)單方法就是直接修改這個(gè)compile.h文件,原來(lái)的文件如下:

# cat /usr/src/kernels/3.10.0-693.2.2.el7.x86_64/include/generated/compile.h
/* This file is auto generated, version 1 */
/* SMP */
#define UTS_MACHINE "x86_64"
#define UTS_VERSION "#1 SMP Tue Sep 12 10:10:26 CDT 2017"
#define LINUX_COMPILE_BY "mockbuild"
#define LINUX_COMPILE_HOST "sl7-uefisign.fnal.gov"
#define LINUX_COMPILER "gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) "

修改define UTS_VERSION那一行,如下:

#define UTS_VERSION "#1 SMP Tue Sep 12 10:10:26 CDT 2017" -> #define UTS_VERSION "#1 SMP Tue Sep 12 22:26:13 UTC 2017"

再次運(yùn)行stap:

# stap -e 'probe begin{printf("Hello, World"); exit();}' -v
Pass 1: parsed user script and 470 library scripts using 228220virt/41276res/3348shr/38016data kb, in 350usr/10sys/355real ms.
Pass 2: analyzed script: 1 probe, 1 function, 0 embeds, 0 globals using 229144virt/42328res/3536shr/38940data kb, in 0usr/0sys/6real ms.
Pass 3: using cached /root/.systemtap/cache/0b/stap_0bc9e27aef7a1de50ea41889a27fc524_1010.c
Pass 4: using cached /root/.systemtap/cache/0b/stap_0bc9e27aef7a1de50ea41889a27fc524_1010.ko
Pass 5: starting run.
ERROR: module version mismatch (#1 SMP Tue Sep 12 10:10:26 CDT 2017 vs #1 SMP Tue Sep 12 22:26:13 UTC 2017), release 3.10.0-693.2.2.el7.x86_64
WARNING: /usr/bin/staprun exited with status: 1
Pass 5: run completed in 0usr/10sys/38real ms.
Pass 5: run failed.  [man error::pass5]

因?yàn)橹虚g生成的C文件和ko模塊都是用的cache (藍(lán)色標(biāo)注的部分),我們把上面的cache文件刪除,再重新運(yùn)行,這次可以成功了。

# stap -e 'probe begin{printf("Hello, World"); exit();}'
Hello, World

參考

https://sourceware.org/systemtap/SystemTap_Beginners_Guide/using-systemtap.html#using-setup

ERROR: module version mismatch

https://groups.google.com/forum/#!topic/openresty/nlEc3qlDyOc


網(wǎng)站題目:CentOS 7上Systemtap的安裝
當(dāng)前鏈接:http://www.dlmjj.cn/article/dpijjgg.html