linux上安裝和解除安裝open-vswitch
阿新 • • 發佈:2018-12-09
一. 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工程為home/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原始碼目錄,按照前述編譯步驟重新編譯安裝