How can I install and configure KVM and OpenvSwitch on the Linux release?

Source: Internet
Author: User
Tags openvswitch
In today's multi-tenant data center environment, virtualization technology is expanding from traditional virtual machine management program-based server virtualization to network virtualization. In this environment, software-based virtual switches are usually deployed on servers together with virtual machine management programs, and KVM is connected in a multi-tenant data center environment, virtualization technology is expanding from traditional virtual machine management program-based server virtualization to network virtualization. In this environment, software-based virtual switches are usually deployed on servers together with virtual machine management programs, which concatenates the traffic transmitted between different virtual machines.

In this tutorial, I will demonstrate how to install and configure KVM and Open vSwitch (OVS) on Ubuntu or Debian ). KVM and Open vSwitch are the most popular Open-source virtual machine management programs and virtual switches in today's data centers.

Install Open vSwitch on Ubuntu or Debian

Although OVS appears in Ubuntu or Debian as a package, I still use the source code to build OVS, which will have the latest features and revisions.

First, install the dependencies used to build OVS.

 
 
  1. ___FCKpd___0nbsp;sudo apt-get install build-essential libssl-dev linux-headers-$(uname -r) 

Build OVS using source code, as shown below. Follow these steps to build the OVS kernel module and OVS User space tool.

 
 
  1. ___FCKpd___1nbsp;wget http://openvswitch.org/releases/openvswitch-1.9.3.tar.gz 
  2. ___FCKpd___1nbsp;tar xvfvz openvswitch-1.9.3.tar.gz 
  3. ___FCKpd___1nbsp;cd openvswitch-1.9.3 
  4. ___FCKpd___1nbsp;./configure --with-linux=/lib/modules/`uname -r`/build 
  5. ___FCKpd___1nbsp;make 

Next, install the OVS User space component under/usr/local/share:

 
 
  1. ___FCKpd___2nbsp;sudo make install 

The next step is to test the OVS kernel module (before this module is installed ). Therefore, first install the kernel module in the kernel.

 
 
  1. ___FCKpd___3nbsp;sudo insmod ./datapath/linux/openvswitch.ko 

It is confirmed that the OVS kernel module has been successfully loaded.

 
 
  1. ___FCKpd___4nbsp;lsmod | grep openvswitch 
  2. openvswitch            97934  0 

Once you confirm that openvswitch. ko has been successfully loaded into the kernel, continue to install the kernel module, as shown below.

 
 
  1. ___FCKpd___5nbsp;sudo make modules_install 

Configure and start Open vSwitch

Create a framework OVS configuration database.

 
 
  1. ___FCKpd___6nbsp;sudo mkdir /etc/openvswitch 
  2. ___FCKpd___6nbsp;sudo ovsdb-tool create /etc/openvswitch/conf.db ./vswit 
  3. chd/vswitch.ovsschema 

Start the OVS database server.

 
 
  1. ___FCKpd___7nbsp;sudo ovsdb-server --remote=punix:/usr/local/var/run/ope 
  2. nvswitch/db.sock - remote=db:Open_vSwitch,manager_options 
  3. --pidfile --detach 

OVS configures database initialization.

 
 
  1. ___FCKpd___8nbsp;sudo ovs-vsctl --no-wait init 

Finally, start the OVS daemon.

 
 
  1. ___FCKpd___9nbsp;sudo ovs-vswitchd --pidfile --detach 

Install KVM on Ubuntu or Debian

Use the apt-get command to install KVM and necessary user space tools.

 
 
  1. ___FCKpd___10nbsp;sudo apt-get install qemu-kvm libvirt-bin bridge-utils 
  2. virt-manager 

Add a common non-root user (such as alice) to the libmongod group so that the user can start the virtual machine without the root user permission.

 
 
  1. ___FCKpd___11nbsp;sudo adduser alice libvirtd 

Log out and log on again as this user to make changes to group members take effect.

Run the following command. If you see a list of empty virtual machines, this means that KVM has been successfully set.

 
 
  1. ___FCKpd___12nbsp;virsh -c qemu:///system list 
  2. Id    Name        State 

Configure Open vSwitch for KVM

Now it is time to create an OVS Bridge startup script, so that OVS can be automatically configured when the VM is started or terminated.

Install dependencies (user-mode Linux utilities) that are used to process the Linux bridge mode.

 
 
  1. ___FCKpd___13nbsp;sudo apt-get install uml-utilities 

Create a bridge startup script, as shown below.

 
 
  1. ___FCKpd___14nbsp;sudo vi /etc/openvswitch/ovs-ifup 
  2. #!/bin/sh 
  3. switch='br0' 
  4. /sbin/ifconfig $1 0.0.0.0 up 
  5. ovs-vsctl add-port ${switch} $1 
  6. ___FCKpd___14nbsp;sudo vi /etc/openvswitch/ovs-ifdown 
  7. #!/bin/sh 
  8. switch='br0' 
  9. /sbin/ifconfig $1 0.0.0.0 down 
  10. ovs-vsctl del-port ${switch} $1 
  11. ___FCKpd___14nbsp;sudo chmod +x /etc/openvswitch/ovs-if* 

Then, create a default Bridge br0 and add a physical network interface through which the virtual machine will contact the external network. In this tutorial, I assume that this type of network interface is eth5.

 
 
  1. ___FCKpd___15nbsp;sudo ovs-vsctl add-br br0 
  2. ___FCKpd___15nbsp;sudo ovs-vsctl add-port br0 eth5 

Start a VM with KVM

Now you can prepare to start the guest virtual machine.

I assume that you have prepared a guest virtual machine image, such as a ubuntu-client.img ). Run the following command to start the guest virtual machine.

 
 
  1. ___FCKpd___16nbsp;sudo kvm -m 1024 -net nic,macaddr=11:11:11:EE:EE:EE -ne 
  2. t tap,script=/etc/openvswitch/ovs-ifup,downscript=/etc/op 
  3. envswitch/ovs-ifdown -vnc :1 -drive file=/home/dev/images 
  4. /ubuntu-client.img,boot=on 

This creates and starts a guest virtual machine. Once the guest virtual machine is started, its virtual interface is automatically added to OVS Bridge br0.

You can use the ovs-vsctl command to verify the OVS status, as shown below.

This is the remote desktop session of the started virtual machine.

Link: http://xmodulo.com/2014/01/install-configure-kvm-open-vswitch-ubuntu-debian.html

Related Article

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.