Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add /docs/INSTALL-CENTOS.md #462

Open
brendangregg opened this issue Mar 30, 2016 · 18 comments
Open

add /docs/INSTALL-CENTOS.md #462

brendangregg opened this issue Mar 30, 2016 · 18 comments

Comments

@brendangregg
Copy link
Member

Should work, provided the kernel is new enough (at least 4.1). If you've figured out the install steps, please drop comments here or a pull request.

Linux to this new file from /INSTALL.md .

@hydandata
Copy link

http://hydandata.org/installing-ebpf-tools-bcc-and-ply-on-centos-7 but no Lua support. I will get a PR together when I have a bit more time.

@dimovnike
Copy link

hello, are there any up-to-date docs how to install this on centos 7? The http://hydandata.org/installing-ebpf-tools-bcc-and-ply-on-centos-7 is outdated, i get this error when following that tutorial:

@dimovnike
Copy link

Also, would it be possible to use it from a fedora based docker container or a chroot on centos7?

@yonghong-song
Copy link
Collaborator

@dimovnike If you can show the detailed error messages on your centos 7 installation, folks here may be able to help. Yes, it is possible to use it inside a container. However, some tools esp. PID based filtering may not work properly inside the container.

@dimovnike
Copy link

i get this error when compiling clang:

/usr/local/bin/llvm-config: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/local/bin/llvm-config)

is there a way to use another version that is compatible with centos7 glibc?

@hydandata
Copy link

@dimovnike looks like issue with LD_LIBRARY_PATH, make sure it contains the path from the warning before you compile. If not, export it with the path added, ldconfig.

@samofatov
Copy link
Contributor

samofatov commented Dec 28, 2017

I submitted pull request to merge little changes needed for CentOS 6 support.
Here are the few easy steps to install on CentOS 6:

# Pre-requisites:
# 1) Configure SUDO
# 2) Set up http_proxy and https_proxy for build user and for root (via .bashrc)
#    if there is no direct internet connection

# Install GIT
sudo yum install git

# Create build folder:
cd
mkdir build
cd build

# Detect number of threads
export THREADS=$(grep -c ^processor /proc/cpuinfo)

# Install kernel 4.9.71 from source
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.9.71.tar.xz
tar -xf linux-4.9.71.tar.xz
cd linux-4.9.71

# MANUAL copy .config 
# you can download recent kernel from Elrepo, take config from there and use "make olddefconfig"
# however Elrepo 4.14 kernel doesn't appear to work with BCC on CentOS 6
# kernel 4.9 works just fine

# build kernel

make -j $THREADS
sudo make modules_install
sudo make install
sudo dracut --force /boot/initramfs-4.9.71.img 4.9.71
cd ..

# Install GCC
sudo yum install gcc-c++

# Install cmake
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 ..

# Install Python 2.7
wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
tar xf Python-2.7.12.tar.xz
cd Python-2.7.12
./configure
make -j $THREADS
sudo make altinstall
cd ..

# Install 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 ..

# Install GCC 6
sudo yum install https://rpmfind.net/linux/centos/6.9/extras/x86_64/Packages/centos-release-scl-rh-2-3.el6.centos.noarch.rpm --nogpgcheck
sudo yum install devtoolset-6
export CC=/opt/rh/devtoolset-6/root/usr/bin/gcc
export CXX=/opt/rh/devtoolset-6/root/usr/bin/g++

# 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 ..

# Install packages needed for BCC build
sudo yum install -y elfutils-libelf-devel flex

# Download BCC
git clone https://github.com/iovisor/bcc.git

# MANUAL! Apply patch bcc_rhel6.patch
# Not needed if CentOS 6 support pull request is already merged

# Build BCC
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

# Copy bcc package for python 2.7
sudo cp -r /usr/lib/python2.6/site-packages/bcc /usr/local/lib/python2.7/site-packages/bcc

# MANUAL! Mount DEBUGFS in fstab:
#debugfs			/sys/kernel/debug	debugfs	defaults	0 0
# or
mount -t debugfs debugfs /sys/kernel/debug

# You can start tools under root using command line like this:
#/usr/local/bin/python2.7 /usr/share/bcc/tools/offcputime <args>

@J-Brk
Copy link

J-Brk commented Feb 8, 2018

@samofatov Thanks, can you or anyone here confirm that this works on Centos 7 too?

@samofatov
Copy link
Contributor

I have BCC installed on CentOS 7 based machines, but I didn't make a write up for that.
It is easier than CentOS 6, as several steps are not needed on this platform. That is:

  1. Kernel from Elrepo works fine (and 4.14 built from source works too)
  2. Building Python 2.7 is not needed, as it is the host Python
  3. Host compiler worked fine for me. Didn't need to install GCC 6.
  4. Debugfs is already mounted

@baiwfg2
Copy link

baiwfg2 commented Mar 29, 2019

BTW, with cmake -G Ninja, building llvm and clang will be much faster.

@baiwfg2
Copy link

baiwfg2 commented Mar 29, 2019

@samofatov @hydandata I can't find python package for bcc on centos7. Anything wrong ?
image

@baiwfg2
Copy link

baiwfg2 commented Mar 31, 2019

@samofatov @hydandata I can't find python package for bcc on centos7. Anything wrong ?
image

Finally I got it. First I compiled llvm-7.0 and bcc on centos7 kernel 3.10 and installed to a customized path /opt/bcc( It turned out that bcc could be compiled under kernel 3.10 ?). Then I copied the binaries to centos 7 kernel 5.0, and made the following two settings:

ln -s ~/cs/bcc/lib/python2.7/site-packages/bcc /usr/lib/python2.7/site-packages/bcc
export LD_LIBRARY_PATH=/root/cs/bcc/lib64

Then executing scripts under share/bcc/tools has no problem.

@yonghong-song
Copy link
Collaborator

It turned out that bcc could be compiled under kernel 3.10 ?
bcc has compatible bpf headers (not depending on kernel headers) at compile time.

@speas038
Copy link

A much simpler way to get bcc running in centos-7 is with the following commands:

sudo yum install devtoolset-7 llvmtoolset-7
scl enable devtoolset-7 llvm-toolset-7 bash

git clone https://github.com/iovisor/bcc.git
mkdir bcc/build; cd bcc/build
cmake3 .. -DCMAKE_INSTALL_PREFIX=/usr
make -j8
sudo make install

The only caveat with this method is that you must enable the scl environment every time you want to run bcc. Scl environments are meant to be enabled with the above command, but it is possible to enable an scl environment without spawning a new shell with the following command:

source scl_source enable devtoolset-7 llvm-toolset-7

This will enable the scl environment in the current shell which is useful for situations where you want to run bcc tools from within a script, or even to permanently enable a particular scl as documented here:
https://access.redhat.com/solutions/527703

@kylezh
Copy link
Contributor

kylezh commented Jun 10, 2019

@speas038 your instruction works for me, except one typo: llvmtoolset-7 should be llvm-toolset-7

@yonghong-song
Copy link
Collaborator

@kylezh could you submit a patch to fix this typo? Thanks!

@kylezh
Copy link
Contributor

kylezh commented Jun 28, 2019

@yonghong-song The typo I mentioned is in the @speas038 's comment #462 (comment), but not in the current code base.

However, I would like to submit a patch that contains those instructions.

@HowellHu
Copy link

I have BCC installed on CentOS 7 based machines, but I didn't make a write up for that.
It is easier than CentOS 6, as several steps are not needed on this platform. That is:

  1. Kernel from Elrepo works fine (and 4.14 built from source works too)
  2. Building Python 2.7 is not needed, as it is the host Python
  3. Host compiler worked fine for me. Didn't need to install GCC 6.
  4. Debugfs is already mounted

Are there any concrete steps on CentOS7 based on kernel 3.10?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants