在 Ubuntu 12.04 和 Ubuntu 12.04.2 上安装如下:
- 安装 Open vSwitch:
apt-get install openvswitch-brcompat openvswitch-switch
- 尝试启动 Open vSwitch:
# /etc/init.d/openvswitch-switch restart * ovs-brcompatd is not running * Killing ovs-vswitchd (6011) * Killing ovsdb-server (6002) * Starting ovsdb-server * Configuring Open vSwitch system IDs * Starting ovs-vswitchd * Enabling gre with iptables
- 结果显示 brcompat 没有运行:
sed -i 's/# BRCOMPAT=no/BRCOMPAT=yes/g' /etc/default/openvswitch-switch
- 再次尝试启动:
# /etc/init.d/openvswitch-switch restart * ovs-brcompatd is not running * ovs-vswitchd is not running * ovsdb-server is not running FATAL: Error inserting brcompat (/lib/modules/3.5.0-23-generic/updates/dkms/brcompat.ko): Unknown symbol in module, or unknown parameter (see dmesg) * Inserting brcompat module Module has probably not been built for this kernel. Install the openvswitch-datapath-source package, then read /usr/share/doc/openvswitch-datapath-source/README.Debian FATAL: Error inserting brcompat (/lib/modules/3.5.0-23-generic/updates/dkms/brcompat.ko): Unknown symbol in module, or unknown parameter (see dmesg) * Inserting brcompat module
这样的错误信息会出现在 Ubuntu-12.04.2 系统上, 我们来强制加载模块:
# /etc/init.d/openvswitch-switch force-reload-kmod FATAL: Error inserting brcompat (/lib/modules/3.5.0-23-generic/updates/dkms/brcompat.ko): Unknown symbol in module, or unknown parameter (see dmesg) * Inserting brcompat module Module has probably not been built for this kernel. Install the openvswitch-datapath-source package, then read /usr/share/doc/openvswitch-datapath-source/README.Debian Apr 20 17:10:50|00001|stream_unix|ERR|/tmp/stream-unix.10666.0: connection to /var/run/openvswitch/db.sock failed: No such file or directory Apr 20 17:10:50|00002|reconnect|WARN|unix:/var/run/openvswitch/db.sock: connection attempt failed (No such file or directory) Apr 20 17:10:51|00003|stream_unix|ERR|/tmp/stream-unix.10666.1: connection to /var/run/openvswitch/db.sock failed: No such file or directory Apr 20 17:10:51|00004|reconnect|WARN|unix:/var/run/openvswitch/db.sock: connection attempt failed (No such file or directory) Apr 20 17:10:53|00005|stream_unix|ERR|/tmp/stream-unix.10666.2: connection to /var/run/openvswitch/db.sock failed: No such file or directory Apr 20 17:10:53|00006|reconnect|WARN|unix:/var/run/openvswitch/db.sock: connection attempt failed (No such file or directory) Alarm clock * Detected internal interfaces: * ovs-brcompatd is not running * ovs-vswitchd is not running * ovsdb-server is not running * Saving interface configuration * Removing openvswitch module * Inserting openvswitch module * Inserting brcompat module * Starting ovsdb-server * Configuring Open vSwitch system IDs * Starting ovs-vswitchd * Starting ovs-brcompatd * Restoring interface configuration * iptables already has a rule for gre, not explicitly enabling
- 现在 brcompat 模块就正常加载上了:
# lsmod | grep br brcompat 13513 0 openvswitch 84124 1 brcompat
经过测试,在 Ubuntu-12.04 系统上直接安装基本上没有任何问题,如果出现问题就使用 force-reload-kmod。
使用 openvswitch 增加网桥 br0 并把网络接口 eth0 加入 br0:
# ovs-vsctl add-br br0 # ovs-vsctl add-port br0 eth0 # ovs-vsctl show a23c503b-bfbe-4646-8738-a7f69e5d69a0 Bridge "br0" Port "eth0" Interface "eth0" Port "br0" Interface "br0" type: internal ovs_version: "1.4.0+build0"
配置网桥 br0 和网络接口 eth0(和用 bridge-utils 工具配置的时候一样,不同的是这里用更先进的 openvswitch/brcompat_mod 替换了 bridge-utils):
# ifconfig eth0 0 # ifconfig br0 192.168.2.45 netmask 255.255.255.0 # route add default gw 192.168.1.1 br0
为了保存网络设置,最好把上面的配置写到 /etc/network/interfaces 里:
# vi /etc/network/interfaces auto lo iface lo inet loopback auto br0 iface br0 inet static address 192.168.2.45 netmask 255.255.255.0 gateway 192.168.2.1 auto eth0 iface eth0 inet manual up ifconfig $IFACE 0.0.0.0 up down ifconfig $IFACE down