linux上安裝和卸載open-vswitch

一. ovs 從源碼編譯安裝:

安裝依賴項:

# apt-get install make
# apt-get install gcc 
# apt-get install build-essential
# apt-get install libssl-dev
# apt-get install libcap-ng-dev
# apt-get install python2.7
# apt-get install python-pip
# pip install six
# apt-get install autoconf 
# apt-get install automake
# apt-get install libtool

下載源碼包

# apt install git

# git clone https://github.com/openvswitch/ovs.git(下載的git工程目錄爲~/ovs)

生成配置文件

# ./boot.sh(在ovs工程根目錄下)

配置

# ./configure -with-linux=/lib/modules/$(uname -r)/build

編譯

# make

# make install

# make modules_install

# config_file="/etc/depmod.d/openvswitch.conf"

# for module in datapath/linux/*.ko; do
      modname="\$(basename \${module})"
      echo "override \${modname%.ko} * extra" >> "\$config_file"
     echo "override \${modname%.ko} * weak-updates" >> "\$config_file"
  done

# depmod -a

# /sbin/modprobe openvswitch

# /sbin/lsmod | grep openvswitch

啓動

export PATH=$PATH:/usr/local/share/openvswitch/scripts

# ovs-ctl start

測試

# ovs-vsctl show

# ovs-vsctl add-br mybridge

# ovs-vsctl add-port mybridge eth0

二. Ovs的卸載

啓動ovs以後,若是改動ovs源代碼而且想更新ovs服務,進行以下操做:python

# ovs-ctl stop 中止ovs服務

# ovs-dpctl show查看內核,會有一個ovs-system的datapath

# ovs-dpctl del-dp ovs-system 刪除上一步出現的datapath(不進行這一步,rmmod可能會報錯)

# rmmod  openvswitch 卸載openvswitch內核模塊,使用lsmod | grep openvswitch 沒有openvswitch

# 進入ovs源代碼目錄,按照前述編譯步驟從新編譯安裝

參考資料

Open vSwitch on Linux, FreeBSD and NetBSDlinux

做者: yearsj
轉載請註明出處: https://segmentfault.com/a/11...
相關文章
相關標籤/搜索