Install ovs on local pc

16
Install OVS on local PC [email protected]

Transcript of Install ovs on local pc

Page 1: Install ovs on local pc

Install OVS on local PC

[email protected]

Page 2: Install ovs on local pc

contents 1. Overview about OVS 2. Install OVS in local pc 3. How to use OVS with KVM

Page 3: Install ovs on local pc

1 Overview about OVS(1/2) Open vSwitch is a virtual switch for

hypervisors providing network connectivity to virtual machines.

Architecture OVS:

Page 4: Install ovs on local pc

1. Overview about OVS(2/2) Ovsdb-server: is a management protocol

used to manipulate the configuration of Open vSwitches

Ovs-vswitchd: is a daemon that implements the switch, along with a companion Linux kernel module for flow-based switching

Openvswitch.ko: is kernel module.

Page 5: Install ovs on local pc

2. Install OVS on local PC(1/5) Download ovs package from:

http://openvswitch.org/releases/openvswitch-2.0.0.tar.gz

Userland installation: follow as INSTALL.Debian guide or follow as step by step: Step 1: download source and extract.

$ wget http://openvswitch.org/releases/openvswitch-2.0.0.tar.gz$ tar zxf openvswitch-2.0.0.tar.gz$ rm openvswitch-2.0.0.tar.gz$ cd openvswitch-2.0.0

Page 6: Install ovs on local pc

2. Install OVS on local PC(2/5) Step 2: configure for to build.

$ mkdir build $ cd build $ mkdir –p /usr/local/ovs $ ./configure –prefix=/usr/local/ovs

--with-linux=/lib/modules/`uname -r`/build Step 3: build and check build

$ make $ make check

Step 4: install $ make install

Page 7: Install ovs on local pc

2. Install OVS on local PC(3/5) Install kernel modules:

$ make modules_install If you get error as:

Then follow as:

make[2]: Entering directory `/usr/src/linux-headers-3.8.0-33-generic' INSTALL /root/openvswitch-2.0.0/datapath/linux/openvswitch.koCan't read private key DEPMOD 3.8.0-33-genericmake[2]: Leaving directory `/usr/src/linux-headers-3.8.0-33-generic'depmod `sed -n 's/#define UTS_RELEASE "\([^"]*\)"/\1/p' /lib/modules/3.8.0-33-generic/build/include/generated/utsrelease.h`

Page 8: Install ovs on local pc

2. Install OVS on local PC(4/5)

Export environments:

Initialize the configuration database using ovsdb-tool $ ovsdb-tool create /usr/local/ovs/etc/openvswitch/conf.db

vswitchd/vswitch.ovsschema

$ rmmod openvswitch$ modprobe gre$ modprobe libcrc32c$ insmod ./datapath/linux/openvswitch.ko$ mv /lib/modules/3.8.0-33-generic/kernel/net/openvswitch/openvswitch.ko /lib/modules/3.8.0-33-generic/kernel/net/openvswitch/openvswitch.ko.org$ mv ./datapath/linux/openvswitch.ko /lib/modules/3.8.0-33-generic/kernel/net/openvswitch/openvswitch.ko$ echo "gre" >> /etc/modules$ echo "libcrc32c" >> /etc/modules$ echo "openvswitch" >> /etc/modules

$ vi ~/.bashrcexport PATH=/usr/local/ovs/bin:$PATHexport PATH=/usr/local/ovs/sbin:$PATH$ reboot

Page 9: Install ovs on local pc

2 Install OVS on local PC(5/5) Before starting ovs-vswitchd: unload bridge

module with command $ rmmod bridge Initialize database

Start open vswitch daemon:

$ ovsdb-server /usr/local/ovs/etc/openvswitch/conf.db \--remote=punix:/usr/local/ovs/var/run/openvswitch/

db.sock \ --remote=db:Open_vSwitch,Open_vSwitch,manager_options \ --private-key=db:Open_vSwitch,SSL,private_key \ --certificate=db:Open_vSwitch,SSL,certificate \

--bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \

--pidfile –detach$ ovs-vsctl --no-wait init$ ovs-vswitchd --pidfile --detach

Page 10: Install ovs on local pc

3 How to use OVS with KVM(1/6) We will to use kvm to emulator a system

network: Install kvm:$ apt-get install kvm uml-utilities virt-manager

qemu-kvm Model system for this case study:

Page 11: Install ovs on local pc

3 How to use OVS with KVM(2/6) Create bridge br0 and add eth0 to br0 with script:

#!/bin/shenable_bridge(){

ovs-vsctl add-br br0 ovs-vsctl add-port br0 eth0 ifconfig eth0 0 ifconfig br0 192.168.1.25 netmask 255.255.255.0 route add default gw 192.168.1.1 br0

}disable_bridge(){

ovs-vsctl del-port br0 eth0 #restore config eth0 reboot

}case $1 in

up) enable_bridge ;;

down) disable_bridge ;;

*) echo "USAGE: {up|down}" ;;

esac

Page 12: Install ovs on local pc

3 How to use OVS witch KVM(3/6) Create bridge br0 and add eth0 to br0 with script:

Create 2 scripts bring up the kvm tap interface into br0.$ vi /etc/ovs-ifup #!/bin/sh switch='br0' /sbin/ifconfig $1 0.0.0.0 up ovs-vsctl add-port ${switch} $1$ chmod a+x /etc/ovs-ifup

$ vi /etc/ovs-ifdown #!/bin/sh switch='br0' /sbin/ifconfig $1 0.0.0.0 down ovs-vsctl del-port ${switch} $1$ chmod a+x /etc/ovs-ifdown

- Save script as ovs_network$ chmod a+x ovs_network$ ./ovs_network up

Page 13: Install ovs on local pc

3. How to use OVS with KVM(4/6) Start VM1, VM2

$ kvm -m 512 -net nic,macaddr=00:11:22:CC:CC:10 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -cdrom ubuntu-12.04.3-desktop-i386.iso

$ kvm -m 512 -net nic,macaddr=22:22:22:00:CC:10 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -cdrom ubuntu-12.04.3-desktop-i386.isoIf you get this kvm: -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown: Device ‘tap’ could not be initializedJust delete the tap0. Need to dig into a work around cleaner than scripts.$ ovs-vsctl del-port tap0

Page 14: Install ovs on local pc

3. How to use OVS with KVM(5/6) Result:

Page 15: Install ovs on local pc

3 How to use OVS with KVM(6/6) Show configuration of system with ovs-vsctl

command:

Reference:

http://networkstatic.net/installing-open-vswitch-with-kvm/http://networkstatic.net/getting-started-ovsdb/

Page 16: Install ovs on local pc

Thank you!