OpenFlow学习之Mininet安装

Mininet教程


摘要:
       这里给出了Mininet在ubuntu 12.04 KVM (qemu 1.0)的环境下测试


提前准备:宿主机ubuntu + 虚拟机KVM(官方给出的镜像是vmdk vmware格式,教程中给出了vmdk到KVM镜像qcow2装换)
操作系统:ubuntu server amd64


安装完成后设置宿主机网络为
ubuntu@node2:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.12
gateway 192.168.1.1
netmask 255.255.255.0


auto eth1
iface eth1 inet manual

auto br0
iface br0 inet static
      address 192.168.1.18
      gateway 192.168.1.1
      netmask 255.255.255.0
      bridge_ports eth1
      bridge_stp on
      bridge_maxwait 0


重启网络服务,出现 br0网桥,这里假设有双网卡。单网卡也可以见后文。
然后安装  KVM 
apt-get install -y kvm libvirt-bin
添加用户到libvirtd组
useradd $USER libvirtd


virsh net-destroy virtbr0 && virsh net-undefine virbr0
然后重启libvirt-bin
service libvirt-bin restart



对于单网卡使用KVM桥接方式的的用户


brctl addbr br0
ifup br0
ifconfig br0 promisc
ifconfig br0 192.168.1.100 netmask 255.55.255.0 dev br0
 
就可以使用KVM桥接方式网桥br0

 


下载 mininet vmware镜像
 
wget 
https://github.com/downloads/mininet/mininet/mininet-2.0.0-113012-amd64-ovf.zip


转化镜像 vmware 格式到 kvm支持的格式 
 
如果使用的是vmware  workstation 略过


使用KVM 并且  qemu-img 版本1.0 报错


qemu-img convert -O qcow2 mininet-vm-disk1.vmdk mininet-vm-disk1.qcow2
报错

ubuntu@node2:~/vmimg/mininet-ovf$ qemu-img convert -O qcow2 mininet-vm-disk1.vmdk mininet-vm-disk1.qcow2
qemu-img: error while reading sector 131072: Invalid argument
ubuntu@node2:~/vmimg/mininet-ovf$ qemu-img convert -f vmdk -O qcow2 mininet-vm-disk1.vmdk mininet-vm-disk1.qcow2
qemu-img: error while reading sector 131072: Invalid argument
ubuntu@node2:~/vmimg/mininet-ovf$


conversion of a VMDK image with qemu-img failed with “error while reading sector 131072: Invalid argument”解决办法http://serverfault.com/questions/429478/conversion-of-a-vmdk-image-with-qemu-img-failed-with-error-while-reading-sector
原因是qemu的版本太低需要大于1. x


cd /tmp
apt-get install apt-get install libglib2.0-dev
wget
http://wiki.qemu.org/download/qemu-1.2.0.tar.bz2
tar xf qemu-1.2.0.tar.bz2

cd qemu-1.2.0 && ./configure && make -j16 (时间较长)


在/etc/libvirt/qemu/下创建mininet.xml(xml文件格式定义KVM镜像配置具体google "qemu syntax")

sudo cat mininet.xml
[sudo] password for ubuntu:


  mininet
  3245e642-05dc-bd23-6d0e-e7582dc00660
  4194304
  4194304
  4
 
    hvm
   
 

 
   
   
   
 

 
    Westmere
    Intel
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
 

 
  destroy
  restart
  restart
 
    /usr/bin/kvm
   
     
     
     
     


   
   
     
     
     
     

   
   
     
   

   
     
   

   
   
   
     

   
   

你可能感兴趣的:(虚拟化)