centos7如何安装bcc-tools软件包

bcc-tools 需要内核版本为 4.1 或者更新的版本,我们首先需要升级内核

yum update -y
cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

centos版本在7.3以上就不需要update更新了

安装elrepo内核

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm

然后先 rpm -qa |grep kernel查看内核包

先卸载旧的 kernel-headers,kernel-tools, kernel-tools-libs,只保留内核,然后
yum --enablerepo=elrepo-kernel install kernel-ml kernel-ml-devel.x86_64
注意,这里是下载内核和驱动,如果不下载驱动,到后面bcc软件链接的文件就没有,在/usr/src/kernels下4.20.0-1.el7.elrepo.x86_64目录
然后继续下载

yum --enablerepo=elrepo-kernel install  kernel-ml-headers kernel-ml-tools kernel-ml-tools-libs

然后设置:grub2-mkconfig -o /boot/grub2/grub.cfg
生成启动菜单,把kernel-ml 4.9设为默认,重启

# awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
0 : CentOS Linux (4.9.0-1.el7.elrepo.x86_64) 7 (Core)
1 : CentOS Linux (3.10.0-514.2.2.el7.x86_64) 7 (Core)
2 : CentOS Linux (3.10.0-327.36.3.el7.x86_64) 7 (Core)
3 : CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)
4 : CentOS Linux (0-rescue-d67c340e997845be9d763958bab035d6) 7 (Core)
# 查看当前设置
# grub2-editenv list
saved_entry=0
# grub2-set-default 0
# reboot 

安装gcc

yum install gcc-c++
wget https://cmake.org/files/v3.7/cmake-3.7.0.tar.gz
tar xf cmake-3.7.0.tar.gz
cd cmake-3.7.0
./configure
make -j $THREADS
sudo make install
cd ..

安装bison

curl -OL https://ftp.gnu.org/gnu/bison/bison-3.0.tar.xz
tar -xf bison-3.0.tar.xz
cd bison-3.0
./configure
make -j $THREADS
sudo make install
cd ..

Build CLANG

curl -LO http://releases.llvm.org/3.9.1/cfe-3.9.1.src.tar.xz
curl -LO http://releases.llvm.org/3.9.1/llvm-3.9.1.src.tar.xz
tar -xf cfe-3.9.1.src.tar.xz
tar -xf llvm-3.9.1.src.tar.xz
mkdir clang-build
mkdir llvm-build

cd llvm-build
cmake -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
  -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../llvm-3.9.1.src
make -j $THREADS
sudo make install

cd ../clang-build
cmake -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
  -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../cfe-3.9.1.src
make -j $THREADS
sudo make install
cd ..

下载BCC的依赖

sudo yum install -y elfutils-libelf-devel flex

下载BCC

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

export CFLAGS=-I${HOME}/build/linux-4.9.71/usr/include
mkdir bcc-build
cd bcc-build
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr ../bcc
make -j $THREADS
sudo make install

你可能感兴趣的:(centos7如何安装bcc-tools软件包)