1. 安装编译工具

1
yum -y install wget openssl-devel gcc make python-devel openssl-devel kernel-devel kernel-debug-devel autoconf automake rpm-build redhat-rpm-config libtool

2. 编译环境准备

1
2
3
4
5
6
7
8
9
10
11
12
13
14
### 创建编译用户
#adduser ovs
#su - ovs

### 创建编译目录,下载openvswitch源码包
$mkdir -p ~/rpmbuild/SOURCES
$wget http://openvswitch.org/releases/openvswitch-2.5.0.tar.gz

### 准备编译环境
$cp openvswitch-2.5.0.tar.gz ~/rpmbuild/SOURCES/
$tar xfz openvswitch-2.5.0.tar.gz
$ sed 's/openvswitch-kmod, //g' openvswitch-2.5.0/rhel/openvswitch.spec > openvswitch-2.5.0/rhel/openvswitch_no_kmod.spec
$rpmbuild -bb --nocheck ~/openvswitch-2.5.0/rhel/openvswitch_no_kmod.spec
$exit

安装openvswitch

1
2
3
4
5
6
#yum localinstall /home/ovs/rpmbuild/RPMS/x86_64/openvswitch-2.5.0-1.x86_64.rpm
### 验证安装
# ovs-vsctl -V
ovs-vsctl (Open vSwitch) 2.5.0
Compiled Apr 13 2016 06:52:00
DB Schema 7.12.1

启动 openvswitch

1
2
#systemctl start openvswitch.service
#chkconfig openvswitch on