根據官網(www.openvswitch.org)上的文檔做了個記錄
1.安裝針對LINUX和FreeBSD,如果是其他的環境可以閱讀以下文檔
- INSTALL.Debian
- INSTALL.Fedora
- INSTALL.REHL
- INSTALL.XenServer
2.編譯需要的準備
<1>
- make GNU/BSD make都可
- GNU C 編譯器 匹配版本4.1,4.2,4.3
- pkg-config 已測試版本0.22
- libssl 可選,但是如果需要openflow就建議使用。由OpenSSL提供
<2>必須安裝列表
- linux內核:
需要bridge功能,但是在使用OVS的datapath時要保證bridge不被使用
入口流量管理需要內核配置選項NET_CLS_BASIC, NET_SCH_INGRESS, NET_ACT_POLICE,又或者built-in or as modules. (NET_CLS_POLICE is
obsolete and not needed.)
如果GRE隧道被使用,那麼推薦編譯支持IPV6的內核
爲了更好的支持HTB,HFSC,需要啓動各自的配置服務
如需要支持TAP devices(a virtual ethernet device),需要啓動CONFIG_TUN(a tun device is a virtual IP point-to-point device),兩者區別:http://blog.csdn.net/clydezhou/article/details/6936701
- 源碼編譯:
automake 1.10+,autoconf 2.64+,python 2.4+
- 如果要修改ovsdbmonitor
pyuic4 from PyQt4 (http://www.riverbankcomputing.co.uk).
- 如果要修改the vswitchd database schem,E-R圖(ovs-vswitchd.conf.db)要適當更新
"dot" from graphviz (http://www.graphviz.org/).
Perl. Version 5.10.1 is known to work. Earlier versions should also work.
Python 2.x, for x >= 4.
- 以下有利於編譯ovs時更好的獲取warnings
"sparse" version 0.4.4 or later
(http://www.kernel.org/pub/software/devel/sparse/dist/).
GNU make.
3.安裝需要的準備
<1>安裝的機器必須有以下軟件:
- libc compatible with the libc used for build.
- libssl compatible with the libssl used for build, if OpenSSL was
used for the build.
- On Linux, the same kernel version configured as part of the build.
- For optional support of ingress policing on Linux, the "tc" program
from iproute2 (part of all major distributions and available at
http://www.linux-foundation.org/en/Net:Iproute2).
<2>在linux中,必須確保/dev/urandom存在。爲了支持TAP,必須確保/dev/net/tun存在
<3>爲了運行ovsdbmonitor tool
- Python 2.x, for x >= 4.
- Python Twisted Conch.
- Python JSON.
- PySide or PyQt4.
- Python Zope interface module.
4.具體的編譯安裝
<1>在代碼目錄運行:
./boot.sh
<2>packet配置
一般可以直接運行:./configure
默認安裝路徑爲/usr/local和/usr/local/var,如果需要修改,譬如改爲/usr和/var,可使用如下參數:
./configure --prefix=/usr --localstatedir=/var
還可指定編譯器
./configure CC=gcc-4.2
針對linux內核編譯,如果是linux最好使用這一步
./configure --with-linux=/lib/modules/`uname -r`/buil
不使用系統默認架構時
./configure --with-linux=/path/to/linux KARCH=mips
<3>make
在BSD,需要使用gmake
<4>make install
安裝可執行程序和聯機手冊至系統(默認是/usr/local下)
以下可能需要root權限!!!
<5>加載核心模塊
insmod datapath/linux/openvswitch.ko
注意:
你可能需要爲insmod指定完整的路徑,/sbin/insmod。
你可以通過/sbin/lsmod查看openvswitch是否存在來確認模塊已經被載入。
如果載入失敗,可以通過命令:dmesg | tail來查看分析原因.以下是一些常見的錯誤。
openvswitch: exports duplicate symbol br_should_route_hook (owned by bridge) ------bridge模塊已經載入,執行/sbin/rmmod bridge,如果指令執行失敗,並提示沒有bridge模塊存在,那麼bridge安裝在了系統內核中,需要從新配置系統並安裝。
openvswitch: exports duplicate symbol dp_ioctl_hook (owned by ofdatapath) ------ofdatapath已加載,需要去掉:/sbin/rmmod ofdatapath.
最有可能出現的問題是,你所建立的openvswitch和你所希望建立的系統環境不一致,可以運行下面兩條命令:
/sbin/modinfo openvswitch.ko (openvswitch.ko可能需要制定路徑)
/sbin/modinfo /lib/modules/`uname -r`/kernel/net/bridge/bridge.ko
比較兩條命令執行後顯示的vermagic內容。如果不一致,那麼安裝錯誤。
<6>make modules_install 安裝一些可選模塊,可不做
<7>初始化數據庫配置,在安裝根目錄下
mkdir -p /usr/local/etc/openvswitch
ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
5.啓動
<1>在啓動ovs-vswitchd之前,要先啓動database和ovsdb-server。
ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \ 配置文件時上門第七步獲得的
--remote=db:Open_vSwitch,manager_options \
--private-key=db:SSL,private_key \
--certificate=db:SSL,certificate \
--bootstrap-ca-cert=db:SSL,ca_cert \
--pidfile --detach
如果沒有安裝SSL,省略:--private-key, --certificate, --bootstrap-ca-cert
<2>初始化database(安裝完後必須執行一次)
ovs-vsctl --no-wait init
<3>啓動daemon進程,並讓其連接到linux
domain socket
ovs-vswitchd --pidfile --detach
2013-02-18T23:49:56Z|00001|reconnect|INFO|unix:/usr/local/var/run/openvswitch/db.sock: connecting...
2013-02-18T23:49:56Z|00002|reconnect|INFO|unix:/usr/local/var/run/openvswitch/db.sock: connected
<4>接下來就可以創建bridge和ports了。例如,創建一個bridge和兩個ports
ovs-vsctl add-br br0
ovs-vsctl add-port br0 eth0
ovs-vsctl add-port br0 vif1.0