openvswitch-vxlan-(libvirt虚拟机) 配置实例
来源:互联网 发布:数据库的货位编号编写 编辑:程序博客网 时间:2024/05/29 12:59
一 :测试环境介绍:
host1: ubuntu13.04
(uanme -r ) 3.8.0-16-generic
cat /etc/network/interfaces
auto eth0
iface eth0 inet static
address 10.100.5.241
netmask 255.255.0.0
broadcast 10.100.255.255
gateway 10.100.0.254
dns-nameservers 10.1.0.3
host2:
ubuntu13.04
(uanme -r ) 3.8.0-16-generic
cat /etc/network/interfaces
auto eth0
iface eth0 inet static
address 10.100.5.247
netmask 255.255.0.0
network 10.100.0.0
broadcast 10.100.255.255
gateway 10.100.0.254
dns-nameservers 10.1.0.3
( 二 至五步骤host1 和host2 操作相同。字体有颜色的地方两台机器不同之处)
二: 编译安装openvwitch和libvirt 源码:
1 编译安装openvswitch:
(参考: http://networkstatic.net/configuring-vxlan-and-gre-tunnels-on-openvswitch/ )
apt-get update
apt-get install -y git automake autoconf gcc uml-utilities libtool build-essential git pkg-config linux-headers-`uname -r`
wget http://openvswitch.org/releases/openvswitch-1.10.0.tar.gz
tar zxvf openvswitch-1.10.0.tar.gz
cd openvswitch-1.10.0
./boot.sh
./configure --with-linux=/lib/modules/`uname -r`/build
make && make install
make modules_install
insmod datapath/linux/openvswitch.ko
mkdir -p /usr/local/etc/openvswitch
ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
ovsdb-server -v --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 \
--pidfile --detach --log-file
ovs-vsctl --no-wait init
ovs-vswitchd --pidfile --detach
ovs-vsctl show
2 编译安装并启动libvirt
( 参考: http://blog.csdn.net/u011740215/article/details/10064527 )
三: 配置网桥并设置VXLAN:
ovs-vsctl add-br br0
ovs-vsctl add-port br0 eth0
ifconfig eth0 0 && ifconfig br0 10.100.5.241 netmask 255.255.0.0
route add default gw 10.100.0.254 br0
ovs-vsctl add-port br0 vx0 -- set interface vx0 type=vxlan options:remote_ip=10.100.5.247
(备注: 其中10.100.5.241为eth0 的ip ,255.255.0.0为原来的子网掩码。10.100.0.254为原来的网关。上述命令将eth0 设置为0,并把原来的ip 付给桥br0中的端口,: br0 .注意,当建立起一个网桥以后,就会自动在此网桥下建立起一个和桥名字一样的端口。10.100.5.247为host2的eth0 ip )
四: 安装qemu相关的内核模块和包
dpkg -l | grep qemu
ii ipxe-qemu 1.0.0+git-4.d6b0b76-0ubuntu2 all Virtual package to support use of kvm-ipxe with qemu
ii qemu-common 1.4.0+dfsg-1expubuntu4 all dummy transitional package from qemu-common to qemu-keymaps
ii qemu-keymaps 1.4.0+dfsg-1expubuntu4 all QEMU keyboard maps
ii qemu-kvm 1.4.0+dfsg-1expubuntu4 amd64 QEMU Full virtualization on x86 hardware (transitional package)
ii qemu-system-common 1.4.0+dfsg-1expubuntu4 amd64 QEMU full system emulation binaries (common files)
ii qemu-system-x86 1.4.0+dfsg-1expubuntu4 amd64 QEMU full system emulation binaries (x86)
ii qemu-utils 1.4.0+dfsg-1expubuntu4 amd64 QEMU utilities
insmod kvm
五: 编写xml文件,并定义和启动虚拟机:
1 编写xml文档,命名为1.xml
<domain type='qemu' id='1'>
<name>vm21</name>
<uuid>d80b5017-d0a1-4daf-9058-74922b4cf0b8</uuid>
<memory unit='KiB'>2536000</memory>
<currentMemory unit='KiB'>1553600</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc-1.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/root/xml/disk.img'/>
<target dev='vda' bus='virtio'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
<disk type='file' device='cdrom'>
<source file='/root/xml/CentOS-6.4-x86_64-minimal.iso'/>
<target dev='hdc'/>
<readonly/>
</disk>
<controller type='usb' index='0'>
<alias name='usb0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<interface type='bridge'>
<mac address='fa:16:3e:70:8f:f7'/>
<source bridge='br0'/>
<model type='virtio'/>
<virtualport type='openvswitch'/>
<driver name='qemu'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<source path='/dev/pts/1'/>
<target port='1'/>
<alias name='serial1'/>
</serial>
<input type='tablet' bus='usb'>
<alias name='input0'/>
</input>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='5900' autoport='yes' listen='0.0.0.0' keymap='en-us'>
<listen type='address' address='0.0.0.0'/>
</graphics>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<alias name='video0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<alias name='balloon0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
</devices>
<seclabel type='dynamic' model='apparmor' relabel='yes'>
<label>libvirt-d80b5017-d0a1-4daf-9058-74922b4cf0b8</label>
<imagelabel>libvirt-d80b5017-d0a1-4daf-9058-74922b4cf0b8</imagelabel>
</seclabel>
</domain>
注意其中的:
a <domain type='qemu' id='1'>
domain 的类型详见libvirt xml的相关解释
b <name>vm21</name>
<uuid>d80b5017-d0a1-4daf-9058-74922b4cf0b8</uuid>
每个虚拟机的唯一标示
c <memory unit='KiB'>2536000</memory>
memory分配的很小,会导致接下来的安装系统过程出错。
d <type arch='x86_64' machine='pc-1.0'>hvm</type>
e <emulator>/usr/bin/qemu-system-x86_64</emulator>
f <source file='/root/xml/disk.img'/>
系统被安装在的位置, 需要使用命令 qemu-img create -f qcow2 disk.img 5G 创建。(参考:http://wiki.centos.org/HowTos/KVM )
g <disk type='file' device='cdrom'>
<source file='/root/xml/CentOS-6.4-x86_64-minimal.iso'/>
使得能够总镜像安装系统。CentOS-6.4-x86_64-minimal.iso 镜像需要在制定的目录下。
h <graphics type='vnc' port='5900' autoport='yes' listen='0.0.0.0' keymap='en-us'>
<listen type='address' address='0.0.0.0'/>
</graphics>
设置vnc连接的端口和ip. 使得能够通过VNC 连接到虚拟机。 eg: 10.100.5.247:5900.注意每个新虚拟机vnc的端口应该不同。eg;5901,5902......
i <interface type='bridge'>
<mac address='fa:16:3e:70:8f:f7'/>
<source bridge='br0'/>
<model type='virtio'/>
<virtualport type='openvswitch'/>
<driver name='qemu'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
设置网络连接方式,桥接。每个新虚拟机的mac 应该唯一。
2 定义域并启动虚拟机
virsh define 1.xml
virsh start vm21
- (出现下面的错误,可能需要重起机器。原因未知。
- error: Failed to create domain from ubuntu.xml
- error: unknown OS type hvm
此时便可通过vnc连接到正在安装的虚拟机,eg 10.100.5.241:5900
六:虚拟机设置以及vxlan测试
1 通过vnc连接到host1, 设置host1 上的虚拟机vm21的ip 如下:
BOOTTTROPO="static"
DNS1="10.1.0.3"
GATEWAY="10.100.0.254"
IPADDR="10.100.5.242"NETMASK="255.255.0.0"
ONBOOT="yes"
2 通过vnc连接到host2, 设置host2 上的虚拟机vm22的ip 如下:
BOOTTTROPO="static"
DNS1="10.1.0.3"
GATEWAY="10.100.0.254"
IPADDR="10.100.5.248"NETMASK="255.255.0.0"
ONBOOT="yes"
- openvswitch-vxlan-(libvirt虚拟机) 配置实例
- openvswitch-vlan-(libvirt虚拟机) 配置实例
- 在 openvswitch 上配置 VXLAN
- Libvirt虚拟机网络配置
- libvirt 虚拟机迁移配置
- openvswitch配置vxlan隧道ping不通的解决办法
- OpenvSwitch VxLAN实验
- 配置openvswitch kvm虚拟机环境
- libvirt使用openvswitch
- libvirt+OpenvSwitch实验
- 搭建基于openvswitch vxlan协议的多主机KVM虚拟机连接环境
- Neutron总结-openvswitch+vxlan网络
- libvirt 虚拟机 网络(三)
- libvirt虚拟机配置文件的 配置参数
- Configuring VXLAN and GRE Tunnels on OpenvSwitch
- Docker+OpenvSwitch走进VxLAN的世界
- Docker+OpenvSwitch走进VxLAN的世界
- Docker+OpenvSwitch走进VxLAN的世界
- linux编译程序注意及简要mkfile
- 1000以内的偶数和.3
- 论坛里看到的一篇文章,觉得很有用。
- 牛人的blog
- ORACLE 11G DATAGUARD保护模式设置详解
- openvswitch-vxlan-(libvirt虚拟机) 配置实例
- 第十周项目1-2
- ECSHOP忘记管理员密码怎么办?简单快速恢复密码方法 解决方法
- 计算y的值
- while循环求1000内的偶数和
- virtualbox增加ubuntu系统虚拟磁盘空间
- imp 导入乱码问题
- Android:Layout_weight的深刻理解
- 你所不了解的静态路由特点及配置