NetSys / bess

BESS: Berkeley Extensible Software Switch
Other
311 stars 174 forks source link

How to install BESS on a CentOS 7 host? #803

Open god14fei opened 6 years ago

god14fei commented 6 years ago

Only a Ubuntu installation tutorial is given, but my machine OS is Centos 7, I try to install BESS on it but failed with the following errors after the ansible-playbook command.

SUDO password: [DEPRECATION WARNING]: 'include' for playbook includes. You should use 'import_playbook' instead. This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

PLAY [all] ****

TASK [Gathering Facts] **** ok: [localhost]

TASK [apt_repository] ***** An exception occurred during task execution. To see the full traceback, use -vvv. The error was: NameError: global name 'aptsources_distro' is not defined fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_2s10fg/ansible_module_apt_repository.py\", line 551, in \n main()\n File \"/tmp/ansible_2s10fg/ansible_module_apt_repository.py\", line 510, in main\n if isinstance(distro, aptsources_distro.Distribution):\nNameError: global name 'aptsources_distro' is not defined\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1} to retry, use: --limit @/home/feishen/bess/env/bess.retry

PLAY RECAP **** localhost : ok=1 changed=0 unreachable=0 failed=1

How can I install BESS on a CentOS 7 host?

etremblay18 commented 6 years ago

Building on CentOS 7 is tricky because some of its packages (such as gcc) are too old. Luckily, it provides developer toolsets that can be used in such situations. We've managed to compile BESS for CentOS and RHEL using the following commands (I'm pulling these out of a set of build scripts so let me know if you run into any issues):

  1. Install dependencies with Yum:

    yum -y install epel-release centos-release-scl
    yum -y install libpcap-devel zlib-devel c-ares-devel openssl-devel \
    libunwind-devel numactl-devel glog-devel cmake kernel-headers kernel-devel \
    rpm-build devtoolset-4-gcc devtoolset-4-gcc-c++ git19
  2. Install Python dependencies

    pip install grpcio==1.11.0 scapy==2.4.0
  3. Enable software collections:

    scl enable devtoolset-4 git19 bash
  4. Build dependencies from source:

    
    # Clone gRPC
    git clone https://github.com/google/grpc

Compile and Install gRPC

pushd grpc git checkout tags/v1.3.2 # Use version 1.3.2 git submodule update --init # Download dependencies make -j$(nproc) HAS_SYSTEM_PROTOBUF=false sudo make install popd

Compile and Install protobuf

pushd grpc/third_party/protobuf sudo make install popd

Compile and Install libbenchmark

pushd grpc/third_party/benchmark cmake . sudo make install popd

Compile and Install googletest (gtest)

pushd grpc/third_party/googletest mkdir build cd build cmake .. make -j$(nproc) sudo make install popd

Compile and Install gflags

pushd grpc/third_party/gflags mkdir build cd build cmake -DGFLAGS_NAMESPACE=google .. make -j$(nproc) sudo make install popd


3. Build BESS:

Clone BESS

git clone https://github.com/NetSys/bess.git cd bess git checkout $BESS_COMMIT_ID # We use 811ef1ce6317cb9557b0270a1f2e908861f8921b

Patch BESS - you'll need to modify this to match the path where you installed grpc. Mine was installed in /opt/

sed -i 's@GTEST_DIR := /usr/src/gtest@GTEST_DIR := /opt/grpc/third_party/googletest/googletest@g' core/Makefile

Create symlink to kernel headers - if I remember correctly, this is needed to build the bess kmod

mkdir -p /lib/modules/$(uname -r) ln -s /usr/src/kernels/$(rpm -qa | grep kernel-headers | sed -e 's/kernel-headers-//')/ /lib/modules/$(uname -r)/build

We had some issues linking statically. It is possible with more patching of BESS but let's try to keep it simple for now ;)

BESS_LINK_DYNAMIC=1 python build.py

god14fei commented 6 years ago

Let me have a try first, thanks very much since this really helps me a lot! If I run into any issues, I will present them later.

god14fei commented 6 years ago

@etremblay18 An error 'Unable to open /etc/scl/prefixes/devtoolset-4!' occurs after I execute the software collection command 'scl enable devtoolset-4 git19 bash'. I open the directory 'etc/scl/prefixes' and find that it is an empty directory. What's wrong with it? How can I install the devtoolset-4? and git19?

etremblay18 commented 6 years ago

devtoolset-4-gcc, devtoolset-4-gcc-c++ and git19 are part of the yum packages in step 1. devtoolset-4-runtime will be installed as a dependency for devtoolset-4-gcc and devtoolset-4-gcc-c++.

god14fei commented 6 years ago

@etremblay18 When I execute the last commond 'BESS_LINK_DYNAMIC=1 python build.py', it reports errors for installing more packages, such as "https://github.com/google/benchmark" package

[root@node8 bess]# BESS_LINK_DYNAMIC=1 python build.py Error - #include <benchmark/benchmark.h> failed. Did you install "https://github.com/google/benchmark" package?

I have installed all the dependencies you list, why does it still report such errors? Any hints will be appreciated.

etremblay18 commented 6 years ago

After building and installing libbenchmark, you should have /usr/local/include/benchmark/benchmark.h. Is this the case? Also, you might have to do the following so that the libraries in /usr/local/lib can be found by the linker:

echo "/usr/local/lib" > /etc/ld.so.conf.d/bess.conf
sudo ldconfig
god14fei commented 6 years ago

Really appreciate your patience in helping me! I did as what you said, however it still failed.

[root@node8 feishen]# cd /usr/local/include/benchmark/ [root@node8 benchmark]# ls benchmark_api.h benchmark.h macros.h reporter.h [root@node8 benchmark]# echo "/usr/local/lib" > /etc/ld.so.conf.d/bess.conf [root@node8 benchmark]# ldconfig [root@node8 benchmark]# cd /home/feishen/bess [root@node8 bess]# BESS_LINK_DYNAMIC=1 python build.py Error - #include <benchmark/benchmark.h> failed. Did you install "https://github.com/google/benchmark" package?

I then try to install benchmark manually. This time, I run into other issues when I build benchmark. Here's the output:

[root@node8 benchmark]# ls appveyor.yml build cmake CONTRIBUTING.md docs include mingw.py releasing.md test WORKSPACE AUTHORS BUILD.bazel CMakeLists.txt CONTRIBUTORS googletest LICENSE README.md src tools [root@node8 benchmark]# cd build [root@node8 build]# cmake .. -DCMAKE_BUILD_TYPE=RELEASE -- The C compiler identification is GNU 4.4.7 -- The CXX compiler identification is GNU 4.4.7 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Failed to find LLVM FileCheck -- Found Git: /usr/local/bin/git (found version "2.13.1") -- git Version: v1.4.0-151ead62 -- Version: 1.4.0 -- Performing Test HAVE_CXX_FLAG_STD_CXX11 -- Performing Test HAVE_CXX_FLAG_STD_CXX11 - Failed -- Performing Test HAVE_CXX_FLAG_STD_CXX0X -- Performing Test HAVE_CXX_FLAG_STD_CXX0X - Success -- Performing Test HAVE_CXX_FLAG_WALL -- Performing Test HAVE_CXX_FLAG_WALL - Success -- Performing Test HAVE_CXX_FLAG_WEXTRA -- Performing Test HAVE_CXX_FLAG_WEXTRA - Success -- Performing Test HAVE_CXX_FLAG_WSHADOW -- Performing Test HAVE_CXX_FLAG_WSHADOW - Success -- Performing Test HAVE_CXX_FLAG_WERROR -- Performing Test HAVE_CXX_FLAG_WERROR - Success -- Performing Test HAVE_CXX_FLAG_PEDANTIC -- Performing Test HAVE_CXX_FLAG_PEDANTIC - Success -- Performing Test HAVE_CXX_FLAG_PEDANTIC_ERRORS -- Performing Test HAVE_CXX_FLAG_PEDANTIC_ERRORS - Success -- Performing Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32 -- Performing Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32 - Failed -- Performing Test HAVE_CXX_FLAG_WFLOAT_EQUAL -- Performing Test HAVE_CXX_FLAG_WFLOAT_EQUAL - Success -- Performing Test HAVE_CXX_FLAG_FSTRICT_ALIASING -- Performing Test HAVE_CXX_FLAG_FSTRICT_ALIASING - Success -- Performing Test HAVE_CXX_FLAG_WNO_DEPRECATED_DECLARATIONS -- Performing Test HAVE_CXX_FLAG_WNO_DEPRECATED_DECLARATIONS - Success -- Performing Test HAVE_CXX_FLAG_WNO_DEPRECATED -- Performing Test HAVE_CXX_FLAG_WNO_DEPRECATED - Success -- Performing Test HAVE_CXX_FLAG_WSTRICT_ALIASING -- Performing Test HAVE_CXX_FLAG_WSTRICT_ALIASING - Success -- Performing Test HAVE_CXX_FLAG_WD654 -- Performing Test HAVE_CXX_FLAG_WD654 - Failed -- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY -- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY - Failed -- Performing Test HAVE_CXX_FLAG_COVERAGE -- Performing Test HAVE_CXX_FLAG_COVERAGE - Success -- Performing Test HAVE_STD_REGEX -- Performing Test HAVE_STD_REGEX -- Performing Test HAVE_STD_REGEX -- failed to compile -- Performing Test HAVE_GNU_POSIX_REGEX -- Performing Test HAVE_GNU_POSIX_REGEX -- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile -- Performing Test HAVE_POSIX_REGEX -- Performing Test HAVE_POSIX_REGEX -- Performing Test HAVE_POSIX_REGEX -- failed to compile CMake Error at CMakeLists.txt:235 (message): Failed to determine the source files for the regular expression backend

-- Configuring incomplete, errors occurred! See also "/tools/benchmark/build/CMakeFiles/CMakeOutput.log". See also "/tools/benchmark/build/CMakeFiles/CMakeError.log".

I tried a variety of ways but failed to find a solution.