最近在学习bpf,记录下安装bcc流程
环境
Redhat8
kernel-5.4.83
1. 编译llvm
编译 LLVM 和 Clang 开发库
git clone https://github.91chifun.workers.dev//https://github.com/llvm-mirror/llvm.git
cd llvm/tools; git clone https://github.91chifun.workers.dev//https://github.com/llvm-mirror/clang.git
cd ..; mkdir -p build/install; cd build
cmake -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install ..
make
make install
export PATH=$PWD/install/bin:$PATH
2. bcc 编译要求
sudo yum install -y bison cmake ethtool flex git iperf libstdc++-static \
python-netaddr python-pip gcc gcc-c++ make zlib-devel \
elfutils-libelf-devel
sudo yum install -y luajit luajit-devel # for Lua support
sudo yum install -y \
http://repo.iovisor.org/yum/extra/mageia/cauldron/x86_64/netperf-2.7.0-1.mga6.x86_64.rpm
sudo pip install pyroute2
3. build bcc
cd bcc
mkdir build
cd build
#cmake ..
make -j
make install
测试:
[root@localhost tools]# pwd
/usr/local/share/bcc/tools
[root@localhost tools]# ./filetop
04:26:28 loadavg: 0.12 0.10 1.47 1/395 54510
TID COMM READS WRITES R_Kb W_Kb T FILE
54510 clear 2 0 60 0 R xterm
54496 filetop 2 0 15 0 R loadavg
54510 clear 3 0 0 0 R libtinfo.so.6.1
54510 filetop 3 0 0 0 R clear
54510 clear 1 0 0 0 R libc-2.28.so
54510 filetop 2 0 0 0 R ld-2.28.so
Detaching...