Open vswitch: Installation and Use of ovs

Source: Internet
Author: User
Tags openvswitch

Pass

git clone git://openvswitch.org/openvswitch

Download the ovs code to the local machine and run boot. sh. If you are prompted that the Autoconf version is too low, you can find the latest Autoconf M4 or other RPM packages for installation or update through Yum update, or you can install the next newer package by yourself, e.g. http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz

Configure -- With-Linux =/lib/modules/'uname-R'/build

Make

Make install is installed in/usr/local by default.

Install ovs below. It is recommended to write a script to the startup script for the following steps.

Rmmod bridge # Remove the bridge module. We should replace it with openvswitch. Ko.

Insmod datapath/openvswitch. Ko # core module of ovs, used with ovs-vswitchd

Mkdir-P/usr/local/etc/openvswitch

Create an ovsdb Database

Ovsdb-tool create/usr/local/etc/openvswitch/CONF. DB vswitchd/vswitch. ovsschema # You can change the database schema later, e.g. ovsdb-tool convert/usr/local/etc/openvswitch/CONF. db xxxx. schema

Start 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 -- pidfile -- detach -- log-File

Start vswitchd daemon

You need to specify a mechanism for communication with ovsdb-server. The default value is UNIX:/usr/local/var/run/openswitch/DB. Sock.

Ovs-vsctl -- no-Wait init

Ovs-vswitchd -- pidfile -- detach Unix:/usr/local/var/run/openvswitch/DB. Sock -- log-file -- verbose

(-- Verbose generates the debug log)

We can use ovs-appctl to manage the daemon, e.g.

Ovs-appctl-T ovsdb-server exit, ovs-appctl-T ovsdb-server/reconnect

Ovs-appctl-T ovs-vswitchd exit, ovs-appctl-T ovs-vswitchd QoS/show, ovs-appctl-T ovs-vswitchd FDB/flush br0, ovs-appctl-T ovs-vswitchd FDB/show br0

Below is the configuration similar to bridge.

Ovs-vsctl add-Br br0

Ovs-vsctl add-port br0 eth0

Ifconfig eth0 0 up

Ifconfig br0 x. x netmask x. x up

Route add default GW x. x

You can use ovs-vsctl show br0 to view

Bridge "br0"
Port "br0"
Interface "br0"
Type: Internal
Port "eth0"
Interface "eth0"

Note: If you want to use brctl (for example, many xen scripts depend on brctl), you need to start ovsbrcompatd. First, insmod brcompatd. Ko, and then run ovs-brcompatd -- detach -- pidfile.

------------------------------------------------- Gorgeous split line --------------------------------------------------

Start a virtual machine to verify ovs. Prepare a KVM environment. rhel6 supports KVM very well. lsmod | grep KVM. If you find KVM, kvm_intel (kvm_amd) two modules are supported. You also need to install some packages

Yum install libvirt *

Yum install virt-Manager

Yum install Python-embedded Inst

To start libmongod, you also need to install

Yum install avahi *

/Etc/init. d/messagebus start

/Etc/init. d/avahi-daemon start

/Etc/init. d/lib1_d start

Chkconfig messagebus on

Chkconfig avahi-daemon on

Chkconfig libmongod on

The following uses virt-install to install a ubuntu11 KVM Virtual Machine

Qemu-IMG create-F qcow2 ubuntu11 30g # create a qcow2 empty disk through qemu-img

Virt-install -- connect qemu: /// System -- hvm -- virt-type KVM -- name ubuntu11_test1 -- Ram 8192 -- vcpus = 4 -- Disk Path =/disk2/KVM/ubuntu11/ubuntu11, format = qcow2 -- CDROM =/disk1/ISO/ubuntu-11.10-desktop-amd64.iso -- nonetworks -- vnclisten = x. x. x. X -- vncport = 6900
-- VNC

Connect to ovs after creating a KVM Virtual Machine

Note: To support openvswitch, libvirt must be upgraded to version 0.9.11 or later. Currently, libvirt on rhel6 is of version 0.9.10. We download source RPM of fedora16 to build

Download from the http://libvirt.org/sources/libvirt-0.9.13-1.fc16.src.rpm, the build process depends on many other packages, please do it yourself

Modify ubuntu11.xml below to add the network Section

<Interface type = 'bridge '>
<MAC address = '54: 52: 00: 83: 03: 17'/>
<Source bridge = 'br0'/>
<Virtualport type = 'openvswitch'>
</Virtualport>
<Model type = 'virtio '/>
</Interface>

Note that the MAC address of the KVM virtual machine starts with 54: 52: 00, and then virsh create ubuntu11.xml is created successfully.

----------------------------------------- Gorgeous split line -----------------------------------------------

Next we will configure a gre tunnel to verify

I use two physical machines, one with KVM + ovs and the other with xen + ovs. First, create GRE Tunnel

Ovs-vsctl add-Br br1 # create a gre port in this bridge

Ovs-vsctl add-port br1 gre1 -- set interface gre1 type = GRE options: remote_ip = x. x. x. X # This X. x. x. X is the address of another physical machine.

Ovs-vsctl add-port br1 vnetxxx # connect the VM port to the bridge

After the two physical machines are configured, let's look at the FDB table of the bridge.

# Ovs-appctl FDB/show br1
Port VLAN Mac age
1 0 00: 16: 3E: 91: E2: B9 0
2 0 54: 52: 00: 83: 03: 17 0

The MAC addresses of both VMS are learned .. Ping each other below.

BTW, using the traditional GRE tunnel method, has a severe performance reduction. If it is multipath, it cannot be supported. for building a multi-tenant virtual network, we need more advanced technical solutions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.