bcc钱包地址生成linux,【Linux】BCC 工具安装

【Linux】BCC 工具安装

GIT地址

一、安装步骤

1. 安装构建依赖项

sudo yum install -y epel-release

sudo yum update -y

sudo yum groupinstall -y "Development tools"

sudo yum install -y elfutils-libelf-devel cmake3 git bison flex ncurses-devel

sudo yum install -y luajit luajit-devel # for Lua support

2. 安装并编译LLVM

curl -LO http://releases.llvm.org/7.0.1/llvm-7.0.1.src.tar.xz

curl -LO http://releases.llvm.org/7.0.1/cfe-7.0.1.src.tar.xz

tar -xf cfe-7.0.1.src.tar.xz

tar -xf llvm-7.0.1.src.tar.xz

mkdir clang-build

mkdir llvm-build

cd llvm-build

cmake3 -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \

-DCMAKE_BUILD_TYPE=Release ../llvm-7.0.1.src

make

sudo make install

cd ../clang-build

cmake3 -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \

-DCMAKE_BUILD_TYPE=Release ../cfe-7.0.1.src

make

sudo make install

cd ..

3. 安装并编译BCC

git clone https://github.com/iovisor/bcc.git

mkdir bcc/build; cd bcc/build

cmake ..

make

sudo make install

4. 测试

执行./hello_world.py

最终输出:

$ ./hello_world.py

sshd-1665 [000] d... 1195.866430: : Hello, World!

sshd-28313 [001] d... 1196.174047: : Hello, World!

sshd-1665 [000] d... 1206.072681: : Hello, World!

sshd-28315 [000] d... 1206.370377: : Hello, World!

sshd-28315 [000] d... 1209.032548: : Hello, World!

二、问题

问题: This file requires compiler and library support for the iso c++ 2011 standard

解决办法:

$ vim /bcc/CMakeLists.txt

# 修改下面这一行

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall ${CXX_ISYSTEM_DIRS}")

# 加上-std=c++11 -O3

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall ${CXX_ISYSTEM_DIRS} -std=c++11 -O3 ")

问题:

modprobe: FATAL: Module kheaders not found.

Unable to find kernel headers. Try rebuilding kernel with CONFIG_IKHEADERS=m (module)

chdir(/lib/modules/5.6.2-1.el7.elrepo.x86_64/build): No such file or directory

Traceback (most recent call last):

File "./hello_world.py", line 12, in BPF(text='int kprobe__sys_clone(void *ctx) { bpf_trace_printk("Hello, World!\\n"); return 0; }').trace_print()

File "/usr/lib/python2.7/site-packages/bcc/__init__.py", line 356, in __init__

raise Exception("Failed to compile BPF module %s" % (src_file or ""))

Exception: Failed to compile BPF module

解决办法: 查看kernel 版本, 要求4.1以上, 发现不符合要求,注意BPF堆栈跟踪仅4.6版本以上可用!!!

$ uname -r

3.10.0-1062.9.1.el7.x86_64

升级kernel至4.6版本以上: 参考这篇文章

然后安装kernel-devel, 请确保它与系统上当前安装的内核版本匹配

sudo yum install "kernel-devel-uname-r == $(uname -r)"

问题: 在安装kernel-devel显示 No package

No package kernel-devel-uname-r == 5.6.2-1.el7.elrepo.x86_64 available.

解决办法: 启用[elrepo-kerne]存储库, vim /etc/yum.repos.d/elrepo.repo

[elrepo-kernel]

name=ELRepo.org Community Enterprise Linux Kernel Repository - el7

baseurl=http://elrepo.org/linux/kernel/el7/$basearch/

http://mirrors.coreix.net/elrepo/kernel/el7/$basearch/

http://mirror.rackspace.com/elrepo/kernel/el7/$basearch/

http://repos.lax-noc.com/elrepo/kernel/el7/$basearch/

http://mirror.ventraip.net.au/elrepo/kernel/el7/$basearch/

mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-kernel.el7

# 修改这一行将0改为1

enabled=1

然后重新执行: sudo yum install "kernel-devel-uname-r == $(uname -r)"

问题: No module named bcc

[root@rumia examples]# ./hello_world.py

Traceback (most recent call last):

File "./hello_world.py", line 9, in from bcc import BPF

ImportError: No module named bcc

解决办法: 检查sudo make install日志是否被正确执行。

我发现我没有该目录/usr/lib/python2.7/site-packages/bcc, 重新执行了 sudo make install

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值