Monday, May 27, 2013

Ubuntu从源码安装/升级OpenvSwitch

Ubuntu从12.04开始已经自带了OpenvSwitch包,然而自带的包版本较低(1.4.0),如果想要尝试较新的版本,则需要进行手动安装。
需要注意ovs对linux kernel版本的要求。


 Open vSwitch   Linux kernel
   ------------   -------------
       1.4.x      2.6.18 to 3.2
       1.5.x      2.6.18 to 3.2
       1.6.x      2.6.18 to 3.2
       1.7.x      2.6.18 to 3.3
       1.8.x      2.6.18 to 3.4
       1.9.x      2.6.18 to 3.6

   Open vSwitch userspace should also work with the Linux kernel module
   built into Linux 3.3 and later.

   Open vSwitch userspace is not sensitive to the Linux kernel version.
   It should build against almost any kernel, certainly against 2.6.18
   and later.


apt-get update
apt-get install -y git python-simplejson python-qt4 python-twisted-conch automake autoconf gcc uml-utilities libtool build-essential git pkg-config libssl-dev

#Configure openvswitch
./boot.sh && ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc --libdir=/usr/lib  --with-linux=/lib/modules/`uname -r`/build;

#modify utility/ovs-lib
mv utility/ovs-lib utility/ovs-lib.bak

#Compile and install openvswitch
make || print "make failed" && exit
sudo su;
make install;

 #should be the same already.
cp utility/ovs-lib /usr/share/openvswitch/scripts/


update system modules
rmmod bridge >/dev/null
rmmod openvswitch >/dev/null 2>&1
cp datapath/linux/openvswitch.ko /lib/modules/`uname -r`/updates/dkms/
cp datapath/linux/brcompat.ko /lib/modules/`uname -r`/updates/dkms/

insmod /lib/modules/`uname -r`/updates/dkms/openvswitch.ko || print "insmod failed, check dmesg" && exit
insmod /lib/modules/`uname -r`/updates/dkms/brcompat.ko || print "insmod failed, check dmesg" && exit

编辑/etc/default/openvswitch-switch中,开启brcompat。

service openvswitch-switch restart

1 comment:

  1. 你好! 请教一个问题.
    初学openvswitch,在cent os,ubuntn上均尝试过安装,但都有问题.均是在导入datapath模块时出现问题,我使用openvswitch安装包中的安装说明安装,其他均无问题,但在输入命令insmod datapath/linux/openvswitch.ko时,显示unknown symbol in file(大意),用/sbin/modinfo查看显示内核模块不匹配,安装后的openvswitch一切正常,就是ovs_workqd进程无法启动,我在cent_os 2.6.18内核,升级成2.6.32,2.6.35内核均尝试过,都有这个问题,不知你是否遇到过这种问题?还请不吝赐教,谢谢!

    ReplyDelete