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服务,进行如下操作:

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

作者: yearsj
转载请注明出处: https://segmentfault.com/a/11...

你可能感兴趣的:(sdn,ovs,linux,networkx,云计算)