首页 > 代码库 > 在 Ubuntu 12.04 上通过源代码安装 Open vSwitch (OVS)

在 Ubuntu 12.04 上通过源代码安装 Open vSwitch (OVS)

安装 Ubuntu 12.04, 并且更新系统

apt-getupdate;

apt-getupgrade;

 

安装所需的package

apt-get install automake autoconf gcc uml-utilities libtool build-essential pkg-config linux-headers-`uname –r`

 

下载Open vSwich的源码包

wget http://openvswitch.org/releases/openvswitch-1.10.0.tar.gz.

 

编译Open vSwitch

(To build the Linux kernel module, so that you can run thekernel-based switch, pass the location of the kernel build directory on--with-linux)

$ tar -xvf openvswitch-1.10.0.tar.gz

$ cd openvswitch-1.10.0

$ ./boot.sh

$ ./configure--with-linux=/lib/modules/`uname -r`/build

$ make

$ make install

#Load the OVS Kernel Module

$ insmod datapath/linux/openvswitch.ko

 

初始化OVS的配置文件爱你

$ touch /usr/local/etc/ovs-vswitchd.conf

$ mkdir -p /usr/local/etc/openvswitch

$ ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema

 

启动 ovsdb-server

$ ovsdb-server /usr/local/etc/openvswitch/conf.db --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,manager_options --private-key=db:SSL,private_key --certificate=db:SSL,certificate --bootstrap-ca-cert=db:SSL,ca_cert --pidfile --detach --log-file

 

启动OVS

# Only need to run this the first time.

$ ovs-vsctl --no-wait init

# Start vswitch

$ ovs-vswitchd --pidfile --detach

 

我的一个启动OVS的脚本

$!/bin/bash

sudo insmod /home/<YOURNAME>/openvswitch-1.10.0/datapath/linux/openvswitch.ko

 

screen -dmS stack

 

# start ovsdb

screen -S stack -X screen -t ovsdb

screen -S stack -p ovsdb -X exec ovsdb-server /usr/local/etc/openvswitch/conf.db --remote=punix:/usr/local/var/run/openvswitch/db.sock

--remote=db:Open_vSwitch,manager_options --private-key=db:SSL,private_key --certificate=db:SSL,certificate --bootstrap-ca-cert=db:SSL,ca_cert --pidfile --detach --log-file

 

# start ovs

screen -S stack -X screen -t ovs

screen -S stack -p ovs -X exec ovs-vswitchd --pidfile --detach

 

 

检查OVS的运行情况

root@devhost1:/# ovs-vsctl show

e6ab282a-ff87-449f-b234-cc56b6e57bd9

 

root@devhost1:/#ovs-vsctl--version

ovs-vsctl  (OpenvSwitch) 1.10.0

Compiled Aug  9 201318:22:24

 

root@devhost1:/# ps -ea | grep ovs

 1713?        00:00:00 ovs_workq

 1715?        00:00:00 ovsdb-server

 1717?        00:00:00 ovs-vswitchd

 1718?        00:00:00 ovs-vswitchd

 


在 Ubuntu 12.04 上通过源代码安装 Open vSwitch (OVS)