Centos6.7 Centos7.0 安装OpenVSwitch痛苦经历

由于RedHat系列系统默认不安装OpenVSwitch,因此需要自己安装。如果你是Centos6.7以前的版本,那么我只能说,你非常走运!!并且不用浏览本博客文章。

下面我的Linux系统环境

[root@centos6 ~]# uname -a

Linux centos6.7 2.6.32-573.el6.x86_64 #1 SMP Thu Jul 23 15:44:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

[root@centos6 ~]#

一、 官方网站下载源码

我们第一步就是要获取源代码。通过以往的经验,我们可以从官方网站上下载我们需要的版本[下载地址]。我下载是

openvswitch-2.3.2.tar.gz

二、 rpmbulid编译

百度搜索能够搜出很多关于如何编译OVS,方法大同小异,也可阅读源码中帮助文档。 为了方便大家编译,下面是大致编译方法。

1、 准备编译环境

yum -y install gcc makePython-devel openssl-devel graphviz autoconfautomake rpm-build

redhat- rpm-config libtool

如果没有安装kernel-devel kernel-headers

[root@centos6 ~]# wgetftp://ftp.owlriver.com/pub/local/COLUG//RPM-build-tree.txt

[root@centos6 ~]# sh RPM-build-tree.txt


3、 rpm包编译

tar zxf openvswitch-2.3.2.tar.gz

cd openvswitch-2.3.2

cp ../openvswitch-2.3.2.tar.gz /root/rpmbuild/SOURCES/

cp rhel/openvswitch-kmod.files /root/rpmbuild/SOURCES/

rpmbuild -bb rhel/openvswitch.spec

rpmbuild -bb rhel/openvswitch-kmod-rhel6.spec

在编译openvswitch的时候非常顺利,但是在编译kmod驱动的时候就不那么顺利了。下面是编译错误。

/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/../linux/compat/utils.c
/usr/bin/make -C /usr/src/kernels/2.6.32-573.3.1.el6.x86_64
M=/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/datapath/linux modules
make[1]: Entering directory `/usr/src/kernels/2.6.32-573.3.1.el6.x86_64'
CC [M]
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/datapath/linux/actions.o
CC [M]
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/datapath/linux/datapath.o
In file included from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/datapath/linux/actions.c:21:
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/linux/skbuff.h:
In function 'skb_clear_hash':
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/linux/skbuff.h:302:
error: 'struct sk_buff' has no member named 'l4_rxhash'
In file included from include/linux/if_ether.h:136,
from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/linux/if_ether.h:4,
from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../include/linux/if_ether.h:26,
from include/linux/netdevice.h:29,
from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/linux/netdevice.h:4,
from include/linux/if_arp.h:26,
from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/linux/if_arp.h:4,
from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/datapath/linux/datapath.c:23:
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/linux/skbuff.h:
In function 'skb_clear_hash':
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/linux/skbuff.h:302:
error: 'struct sk_buff' has no member named 'l4_rxhash'
In file included from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/datapath/linux/actions.c:22:
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/linux/in.h:
At top level:
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/linux/in.h:8:
error: redefinition of 'proto_ports_offset'
include/linux/in.h:292: note: previous definition of 'proto_ports_offset'
was here
In file included from include/linux/netfilter.h:9,
from include/net/netns/x_tables.h:5,
from include/net/net_namespace.h:18,
from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/net/net_namespace.h:4,
from include/linux/netdevice.h:48,
from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/datapath/linux/datapath.c:23:
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/linux/in.h:
At top level:
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/linux/in.h:8:
error: redefinition of 'proto_ports_offset'
include/linux/in.h:292: note: previous definition of 'proto_ports_offset'
was here
In file included from include/linux/if_arp.h:26,
from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/datapath/linux/datapath.c:23:
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/linux/netdevice.h:37:
error: conflicting types for 'netdev_rx_handler_register'
include/linux/netdevice.h:2215: note: previous declaration of
'netdev_rx_handler_register' was here
In file included from include/net/sock.h:50,
from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/net/sock.h:4,
from include/linux/tcp.h:180,
from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/linux/tcp.h:4,
from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/datapath/linux/actions.c:26:
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/linux/netdevice.h:37:
error: conflicting types for 'netdev_rx_handler_register'
include/linux/netdevice.h:2215: note: previous declaration of
'netdev_rx_handler_register' was here
In file included from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/datapath/linux/actions.c:31:
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/net/ip.h:9:
error: redefinition of 'ip_is_fragment'
include/net/ip.h:249: note: previous definition of 'ip_is_fragment' was here
In file included from include/net/xfrm.h:18,
from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/../compat.h:26,
from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/../datapath.h:29,
from
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/datapath/linux/datapath.c:57:
/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/../datapath/linux/compat/include/net/ip.h:9:
error: redefinition of 'ip_is_fragment'
include/net/ip.h:249: note: previous definition of 'ip_is_fragment' was here
make[2]: ***
[/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/datapath/linux/datapath.o]
Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: ***
[/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/datapath/linux/actions.o]
Error 1
make[1]: ***
[_module_/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/datapath/linux]
Error 2
make[1]: Leaving directory `/usr/src/kernels/2.6.32-573.3.1.el6.x86_64'
make: *** [default] Error 2
make: Leaving directory
`/root/rpmbuild/BUILD/openvswitch-2.3.2/_default/datapath/linux'
error: Bad exit status from /var/tmp/rpm-tmp.bR1bj9 (%build)

大概意思,头文件冲突。这种编译错误,是非常让人头疼的。我经过百度以及谷歌后,均没有查找什么有价值的解决方

案,这个问题困扰了我多日,更换过各种版本,从1.9~2.4的发布版本,都尝试过但仍然存在问题。 曾经一度想换操作

系统,直到无意中查看官方网站中论坛-mail来往记录,才发现如下内容。

三、 解决方案

http://openvswitch.org/pipermail/discuss/2015-September/018885.html

大致意思是在官方发布的release版本在centos6.7中都存在编译不过的问题,但这些问题在github都已经更新并且修改完毕,我们可以从github中克隆代码并且进

行编译。

我去,这就是开源软件的弊端吗!!! 好吧,我只能尝试从github中获取代码并且进行编译啦。 天啊!!还真编译成功了,两个软件都编译ok,并且运行起来了。

[root@centos6 ~]# service openvswitch status
ovsdb-server is running with pid 2091
ovs-vswitchd is running with pid 2102
[root@centos6 ~]#

四、 总结

当经过百度和谷歌都没有查到相关解决方案的时候,我估计很多人都会陷入绝境,不知所错。 总结如下:

第一、 但是你要知道这样一句话: 你要相信你不是遇见这个问题的第一人。

第二、 当遇到无法解决的问题时候,请逛一逛官方论坛。


PS:如果在编译的时候,出现类似test错误,解决方案如下: 请在rpmbulid指定参数 --without check。例如:

rpmbuild -bb --without check rhel/openvswitch.spec

相关文章

文章浏览阅读903次。4.清除缓存目录(/var/cache/yum)下的软件...
文章浏览阅读1.5k次。Python 是一种高级解释性编程语言,已被...
文章浏览阅读2.6k次。打开终端或控制台,以root或具有sudo权...
文章浏览阅读744次,点赞24次,收藏26次。目标:通过AppSrv为...
文章浏览阅读1.1w次,点赞8次,收藏26次。chmod命令来自于英...
文章浏览阅读1.2k次。yum源的URL地址,本例中是文件系统的路...