Open vSwitch for CentOS

原文发表于cu2016-06-02

本文属于重发,ovs当前的安装方式可能略有不同。

 参考文档:

  1. 官方文档: http://openvswitch.org/support/dist-docs-2.5/INSTALL.RHEL.md.html

 在docker环境下搭建网桥,有传统的brctl工具(yum install -y bridge-utils),也可以采用扩展性/功能性更强大的open vswitch。

ovs安装的流程是需要下载源代码之后自行制作rpm安装程序,官方已经把工具集成打包完成,只需要按照步骤操作,即参考上方链接的文档就行。 

一.前置条件

1. 环境

Server:CentOS-7-x86_64-1511 

2. 软件

ovs官网:http://openvswitch.org/

截止2016年6月1日最新LTS版本下载地址:http://openvswitch.org/releases/openvswitch-2.5.0.tar.gz 

二.安装OVS

1. 依赖包

[root@localhost ~]# yum install -y gcc make python-devel openssl-devel kernel-devel graphviz kernel-debug-devel autoconf automake rpm-build redhat-rpm-config libtool 

2. 环境检查

#部分RHEL 6的kernel-devel包含1个错误的"build"链接,需要检查系统环境是否OK;
#如果"ll"命令能列出目录及目录所含的文件,表示系统环境没问题,如果报" No such file or directory"则需要修复这个错误;
#请注意红色粗体字部分,由系统内核决定。
[root@localhost ~]# ll /lib/modules/3.10.0-327.el7.x86_64/build/


#建立软链接的时候请注意红色粗体字部分保持一致(源处有多个类似的目录,选择与目的处显示的内核版本一致的目录即可);(可选项)修复步骤如下:
[root@localhost ~]# rm -f /lib/modules/3.10.0-327.el7.x86_64/build/*
[root@localhost ~]# ln -s /usr/src/kernels/3.10.0-327.el7.x86_64/ /lib/modules/3.10.0-327.el7.x86_64/build/ 

3. Building ovs

[root@localhost ~]# mkdir -p $HOME/rpmbuild/SOURCES/
[root@localhost ~]# cd $HOME/rpmbuild/SOURCES
[root@localhost SOURCES]# tar -zxvf openvswitch-2.5.0.tar.gz
[root@localhost SOURCES]# cd openvswitch-2.5.0
 
#在/root/rpmbuild/RPMS/x86_64目录生成2个rpm软件,分别是"openvswitch-2.5.0-1.x86_64.rpm"与"openvswitch-debuginfo-2.5.0-1.x86_64.rpm"(版本随采用的版本不同而不同);
#"--without check"参数可以关闭rpmbuild过程中的测试;
#如果报"configure: error: source dir /lib/modules/3.10.0-327.el7.x86_64/build doesn't exist或者类似的错,可以参考步骤2。
[root@localhost openvswitch-2.5.0]# rpmbuild -bb --without check rhel/openvswitch.spec

4. Build rhel 6 kernel module(可选)

#针对RHEL 6,需要build ovs的内核驱动;
#在/root/rpmbuild/RPMS/x86_64目录生成1个rpm软件" kmod-openvswitch-2.5.0-1.el7.centos.x86_64.rpm" (版本随采用的版本不同而不同)。
[root@localhost openvswitch-2.5.0]# cp rhel/openvswitch-kmod.files $HOME/rpmbuild/SOURCES
[root@localhost openvswitch-2.5.0]# rpmbuild -bb rhel/openvswitch-kmod-rhel6.spec

5. 安装ovs

[root@localhost ~]# cd $HOME/rpmbuild/RPMS/x86_64
[root@localhost x86_64]# rpm -ivh openvswitch-2.5.0-1.x86_64.rpm
[root@localhost x86_64]# rpm -ivh openvswitch-debuginfo-2.5.0-1.x86_64.rpm 

6. 验证

[root@localhost ~]# ovs-vsctl -V

#开机启动
[root@localhost ~]# systemctl enable openvswitch.service

#启动openvswitch
[root@localhost ~]# systemctl start openvswitch.service

[root@localhost ~]# service openvswitch status
#或systemctl status openvswitch.service

原文地址:https://www.cnblogs.com/netonline/p/7445514.html