본문 바로가기
  • AI (Artificial Intelligence)
Legacy Skills/OpenvSwitch

OpenvSwitch v2.1.2 on Ubuntu 12.04 LTS

by 로샤스 2014. 7. 29.

更新記錄

安裝過程

環境

  • OS: Ubuntu 12.04.4 Server LTS X86_64
  • Kernel version: 3.11.0-20-generic

預先安裝

aptitude install dh-autoreconf libssl-dev openssl

編譯 OpenvSwitch

wget http://openvswitch.org/releases/openvswitch-2.1.2.tar.gz
tar zxvf openvswitch-2.1.2.tar.gz && cd openvswitch-2.1.2
./boot.sh
./configure --with-linux=/lib/modules/`uname -r`/build
make -j && sudo make install
sudo make modules_install
sudo modprobe gre
sudo modprobe openvswitch
sudo modprobe libcrc32c
  • 使用 lsmod |grep openvswitch 確認ovs正確地掛載起來
  • ./configure 部份其實還可以下一個 --prefix= 參數, 可以讓openvswitch 完全裝在該目錄底下而不會亂掉

設定 ovsdb

ovsdb-tool create /usr/local/etc/openvswitch/conf.db /usr/local/share/openvswitch/vswitch.ovsschema
  • 建立一次即可, 如果設定有問題的話可以把conf.db砍掉重建

(二選一) 開啟 ovsdb-server (no ssl)

ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \
--remote=db:Open_vSwitch,Open_vSwitch,manager_options \
--pidfile --detach --log-file
  • cat /usr/local/var/log/openvswitch/ovsdb-server.log 可查到 ovsdb log

(二選一) 開啟 ovsdb-server (ssl)

ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \
--remote=db:Open_vSwitch,Open_vSwitch,manager_options \
--private-key=db:Open_vSwitch,SSL,private_key \
--certificate=db:Open_vSwitch,SSL,certificate \
--bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \
--pidfile --detach --log-file
  • 若要使用 ssl 連線, 務必在編譯前要先準備好 libssl-dev 及 openssl, 否則會噴出Private key specified but Open vSwitch was built without SSL support 的錯誤
  • OpenvSwitch Lab 6$ TLS SSL

開啟 ovs-vsctl

ovs-vsctl --no-wait init

開啟 ovs-switchd 功能

ovs-vswitchd --pidfile --detach --log-file
  • /usr/local/var/log/openvswitch/ovs−vswitchd.log 可查到 ovs-vswitchd log

觀察

  • ps aux |grep ovs

ovs_install_complete.pngovs_install_complete.png

開機自動化

設定開機自動 load module

echo "openvswitch " >> /etc/modules
echo "gre" >> /etc/modules
echo "libcrc32c" >> /etc/modules

設定開機自動啟動

  1. vim /etc/init.d/openvswitch
    #!/bin/sh
    start-stop-daemon -q -S -x /usr/local/sbin/ovsdb-server -- --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --pidfile --detach --log-file
    sleep 3 # waiting ovsdb-server 
    start-stop-daemon -q -S -x /usr/local/bin/ovs-vsctl -- --no-wait init
    start-stop-daemon -q -S -x /usr/local/sbin/ovs-vswitchd -- --pidfile --detach --log-file
    
  2. chmod +x /etc/init.d/openvswitch
  3. update-rc.d -f openvswitch defaults

設定 interface

  1. ovs-vsctl add-br ovs-br
  2. vim /etc/network/interfaces
    # The loopback network interface
    auto lo
    iface lo inet loopback
    # The primary network interface
    auto eth0
    iface eth0 inet manual
    up ifconfig $IFACE 0.0.0.0 up
    down ifconfig $IFACE down
    # OpenvSwitch Interface
    auto ovs-br
    iface ovs-br inet static
    address x.x.x.x
    netmask 255.255.255.0
    gateway o.o.o.o
    dns-nameservers 168.95.1.1
    

修改 Failsafe

vim /etc/init/failsafe.conf

$PLYMOUTH message --text="Waiting for network configuration..." || :
sleep 1 
$PLYMOUTH message --text="Waiting up to 60 more seconds for network configuration..." || :
sleep 1 
$PLYMOUTH message --text="Booting system without full network configuration..." || :

OpenvSwitch kernel 支援列表

Open vSwitchLinux kernel
1.4.x2.6.18 to 3.2
1.5.x2.6.18 to 3.2
1.6.x2.6.18 to 3.2
1.7.x2.6.18 to 3.3
1.8.x2.6.18 to 3.4
1.9.x2.6.18 to 3.8
1.10.x2.6.18 to 3.8
1.11.x2.6.18 to 3.8
2.0.x2.6.32 to 3.10
2.1.x2.6.32 to 3.11
2.2.x2.6.32 to 3.13

小計

  1. ovs 2.1.0 已支援 Linux kernel 3.10 以上
  2. 如果沒有 /lib/modules/x.x.x/build 資料夾, 找一下關鍵字 "linux-header"
  3. 12.04.4 kernel 太新了, 要降級. 參考: Ubuntu 12.04 LTS Kernel 降級
  4. 設定OpenvSwitch
  5. OpenvSwitch OverView - hwchiu
  6. OpenVSwitch - NSRC












출처 : http://roan.logdown.com/posts/165399-compile-openvswitch-on-ubuntu-1204-lts



























'Legacy Skills > OpenvSwitch' 카테고리의 다른 글

VLANs  (0) 2014.08.06
openvswitch-1.1.0 Directory Reference  (0) 2014.07.31
OpenVswitch Advanced Tutioral  (0) 2014.07.31
[ovs-discuss] installing ovs2 on ubuntu 12.04  (0) 2014.07.29
2013 Wheezy source  (0) 2014.07.15

댓글