Skip to content

Instantly share code, notes, and snippets.

@thaihust
Forked from balioune/install-ovs-dpdk.sh
Created August 2, 2018 13:50
Show Gist options
  • Save thaihust/340a294a7494d24c9a3615302d5fc5bb to your computer and use it in GitHub Desktop.
Save thaihust/340a294a7494d24c9a3615302d5fc5bb to your computer and use it in GitHub Desktop.

Revisions

  1. @balioune balioune revised this gist Aug 26, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions install-ovs-dpdk.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    #!/bin/bash

    # source https://software.intel.com/en-us/articles/set-up-open-vswitch-with-dpdk-on-ubuntu-server
    # https://www.kernel.org/doc/Documentation/

    sudo apt-get install gcc g++ make -y
    sudo apt-get install -y gcc-multilib
  2. @balioune balioune created this gist Aug 25, 2017.
    115 changes: 115 additions & 0 deletions install-ovs-dpdk.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,115 @@
    #!/bin/bash

    # source https://software.intel.com/en-us/articles/set-up-open-vswitch-with-dpdk-on-ubuntu-server

    sudo apt-get install gcc g++ make -y
    sudo apt-get install -y gcc-multilib
    sudo apt-get install -y libc6-dev

    ## DPDK INSTALL
    cd /usr/src/
    wget http://fast.dpdk.org/rel/dpdk-16.07.2.tar.xz
    tar xf dpdk-16.07.2.tar.xz
    export DPDK_DIR=/usr/src/dpdk-stable-16.07.2

    # Configure and Install DPDK
    export DPDK_TARGET=x86_64-native-linuxapp-gcc
    export DPDK_BUILD=$DPDK_DIR/$DPDK_TARGET
    make install T=$DPDK_TARGET DESTDIR=install

    echo "Removing old ovs configuration."
    sudo /etc/init.d/openvswitch-switch stop
    sudo kill `cd /usr/local/var/run/openvswitch && cat ovsdb-server.pid ovs-vswitchd.pid`
    sudo rm -rf /usr/local/var/run/openvswitch
    sudo mkdir -p /usr/local/var/run/openvswitch
    sudo rm -rf /usr/local/etc/openvswitch
    sudo mkdir -p /usr/local/etc/openvswitch
    sudo rm -rf /var/run/openvswitch
    sudo mkdir -p /var/run/openvswitch
    sudo rm -rf /etc/openvswitch
    sudo mkdir -p /etc/openvswitch
    sudo rm -rf /var/log/openvswitch
    sudo mkdir -p /var/log/openvswitch
    sudo rmmod openvswitch
    sudo rmmod gre
    sudo rmmod vxlan
    sudo rmmod libcrc32c
    sudo rmmod openvswitch
    sudo dpkg --force-all --purge openvswitch-switch
    sudo dpkg --force-all --purge openvswitch-common
    sudo dpkg --force-all --purge openvswitch-datapath-dkms
    sudo rm /tmp/ovsdb.txt
    touch /tmp/ovsdb.txt
    sudo rm /tmp/vswitch.txt
    touch /tmp/vswitch.txt
    git clone https://github.com/openvswitch/ovs.git
    cd ovs
    git checkout v2.6.1
    make clean
    ./boot.sh
    ./configure --with-dpdk=$DPDK_BUILD
    sudo make install
    #sudo make uninstall
    sudo apt-get install -y build-essential
    sudo apt-get install -y fakeroot
    sudo apt-get install -y debhelper
    sudo apt-get install -y autoconf
    sudo apt-get install -y automake
    sudo apt-get install -y libssl-dev
    sudo apt-get install -y bzip2
    sudo apt-get install -y openssl
    sudo apt-get install -y graphviz
    sudo apt-get install -y python-all
    sudo apt-get install -y procps
    sudo apt-get install -y python-qt4
    sudo apt-get install -y python-zopeinterface
    sudo apt-get install -y python-twisted-conch
    sudo apt-get install -y libtool
    sudo apt-get install -y dh-autoreconf
    echo "Checking Build Dependencies."
    sudo dpkg-checkbuilddeps
    if [ $? -gt 0 ]; then
    echo "ERROR:Build Dependencies not met."
    exit 1
    fi

    echo "Creating Debian Packages."
    rm ../openvswitch-*.deb
    rm ../python-openvswitch*.deb
    DEB_BUILD_OPTIONS='parallel=8 nocheck' fakeroot debian/rules binary
    if [ $? -gt 0 ]; then
    echo "ERROR:Creating Debian packages failed."
    exit 1
    fi

    echo "Installing kernel module using dkms."
    sudo apt-get install -y linux-headers-`uname -r`
    sudo apt-get install -y dkms
    sudo dpkg --install ../openvswitch-datapath-dkms*
    if [ $? -gt 0 ]; then
    echo "ERROR:Installing openvswitch kernel module failed."
    exit 1
    fi

    echo "Installing openvswitch userland packages."
    sudo dpkg --install ../openvswitch-common*
    sudo dpkg --install ../openvswitch-switch*
    if [ $? -gt 0 ]; then
    echo "ERROR:Installing openvswitch userland packages failed."
    exit 1
    fi

    sudo /etc/init.d/openvswitch-switch restart

    sudo lsmod | grep -i open
    sudo update-rc.d -f openvswitch-switch remove
    sudo update-rc.d openvswitch-switch defaults

    ####
    ## Setup OVS with DPDK datapath
    echo 'vm.nr_hugepages=2048' > /etc/sysctl.d/hugepages.conf
    sysctl -w vm.nr_hugepages=2048
    grep HugePages_ /proc/meminfo
    sudo ovs-vsctl show

    echo "Install Complete!"