一. ovs 从源码编译安装:
安装依赖项:
# apt install make
# apt install gcc
# apt install build-essential
# apt install libssl-dev
# apt install libcap-ng-dev
# apt install python2.7
# apt install python-pip
# pip install six
# apt install autoconf
# apt install automake
# apt 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源代码目录,按照前述编译步骤重新编译安装