苹果6pns 有没有苹果微信分身身

RHEV upgrade saga: RHEL KVM and the Open vSwitch
(Other stories by )
A customer of mine recently switched from VMware Server to KVM, but they wanted better networking, which required installing and operating the Open vSwitch. Since they are using RHEL 5 we had to do some magic to install open vswitch.
Please enable Javascript in your browser, before you post the comment! Now Javascript is disabled.
Talkback[s]&温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
IT运维 网络管理
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
&四、我们来创建实例(Guest)linuxtest。
1)创建文件名linuxtest.qcow2的磁盘镜像文件,文件格式为qcow2,磁盘大小为73G
[root@localhost ~]# qemu-img create -f qcow2 /home/kvm/images/linuxtest.qcow2 73G
Formatting '/home/kvm/images/linuxtest.qcow2', fmt=qcow2 size= encryption=off cluster_size=65536
##=======================================================
[root@localhost ~]# qemu-img info /home/kvm/images/linuxtest.qcow2
image: /home/kvm/images/linuxtest.qcow2
file format: qcow2
virtual size: 73G ( bytes)
disk size: 136K
cluster_size: 65536
##=========================================================
2)内存4G,4核CPU ,73G硬盘安装centos 6.4& 64位系统
[root@localhost ~]#virt-install --connect qemu:///system \
--name linuxtest \
--ram 4096 \
--vcpus=4 \
--disk path=/home/kvm/images/linuxtest.qcow2,device=disk,format=qcow2,bus=virtio,cache=none,size=73 \
--location='/centos/6.4/os/x86_64/' \
--os-type=linux \
--network bridge=br0,model=virtio,model=e1000 \
--hvm --os-variant=rhel6 \
--graphics vnc,listen=0.0.0.0,port=5903 \
--virt-type=kvm \
--noautoconsole
4)virtio半虚拟化驱动来提高性能(微软操作系统的IO性能)
下面安装Windows server 2003 Enterprise
tar zxvf virtio-win-0.1-52.tar.gz
安装系统的时候记得按F6从软驱加载驱动
内存4G,4核CPU ,15G硬盘安装windows server 2003系统
[root@localhost ~]# virt-install --connect qemu:///system \
--name win3test \
--ram 4096 \
--vcpus=4 \
--disk path=/home/kvm/images/win3test.qcow2,device=disk,format=qcow2,bus=virtio,cache=none,size=15 \
--cdrom /home/iso/WIN_2003.iso --os-type=windows \
--disk path=/home/iso/virtio-WIN2003-x86.vfd,device=floppy,perms=rw \
--network bridge=br0,model=virtio,model=e1000 \
--hvm --os-variant=win2k3 \
--graphics vnc,listen=0.0.0.0,port=5902 \
--virt-type=kvm \
--noautoconsole
##===================================
&##win3test.xml如下
[root@localhost ~]# cat /etc/libvirt/qemu/win3test.xml
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
& virsh edit win3test
or other application using the libvirt API.
&domain type='kvm'&
& &name&win3test&/name&
& &uuid&9fda-2aa7-050a-ed&/uuid&
& &memory unit='KiB'&4194304&/memory&
& &currentMemory unit='KiB'&4194304&/currentMemory&
& &vcpu placement='static'&4&/vcpu&
&&& &type arch='x86_64' machine='rhel6.4.0'&hvm&/type&
&&& &boot dev='hd'/&
& &features&
&&& &acpi/&
&&& &apic/&
&&& &pae/&
& &/features&
& &clock offset='localtime'&
&&& &timer name='rtc' tickpolicy='catchup'/&
& &/clock&
& &on_poweroff&destroy&/on_poweroff&
& &on_reboot&restart&/on_reboot&
& &on_crash&restart&/on_crash&
& &devices&
&&& &emulator&/usr/libexec/qemu-kvm&/emulator&
&&& &disk type='file' device='disk'&
&&&&& &driver name='qemu' type='qcow2' cache='none'/&
&&&&& &source file='/home/kvm/images/win3test.qcow2'/&
&&&&& &target dev='vda' bus='virtio'/&
&&&&& &address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/&
&&& &/disk&
&&& &disk type='file' device='floppy'&
&&&&& &driver name='qemu' type='raw' cache='none'/&
&&& &&&source file='/home/iso/virtio-WIN2003-x86.vfd'/&
&&&&& &target dev='fda' bus='fdc'/&
&&&&& &address type='drive' controller='0' bus='0' target='0' unit='0'/&
&&& &/disk&
&&& &disk type='file' device='cdrom'&
&&&&& &driver name='qemu' type='raw'/&
&&&&& &source file='/home/iso/WIN_2003.iso'/&
&&&&& &target dev='hdc' bus='ide'/&
&&&&& &readonly/&
&&&&& &address type='drive' controller='0' bus='1' target='0' unit='0'/&
&&& &/disk&
&&& &controller type='usb' index='0'&
&&&&& &address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/&
&&& &/controller&
&&& &controller type='fdc' index='0'/&
&&& &controller type='ide' index='0'&
&&&&& &address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/&
&&& &/controller&
&&& &interface type='bridge'&
&&&&& &mac address='52:54:00:cc:a1:bd'/&
&&&&& &source bridge='br0'/&
&&&&& &model type='e1000'/&
&&&&& &address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/&
&&& &/interface&
&&& &serial type='pty'&
&&&&& &target port='0'/&
&&& &/serial&
&&& &console type='pty'&
&&&&& &target type='serial' port='0'/&
&&& &/console&
&&& &input type='tablet' bus='usb'/&
&&& &input type='mouse' bus='ps2'/&
&&& &graphics type='vnc' port='5902' autoport='no' listen='0.0.0.0'&
&&&&& &listen type='address' address='0.0.0.0'/&
&&& &/graphics&
&&& &video&
&&&&& &model type='vga' vram='9216' heads='1'/&
&&&&& &address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/&
&&& &/video&
&&& &memballoon model='virtio'&
&&&&& &address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/&
&&& &/memballoon&
& &/devices&
##=============================
##红色部分为软驱,稍后要卸载(做模版的时候)
##先关机分离软驱
[root@localhost ~]# virsh -c qemu:///system destroy win3test
[root@localhost ~]# virsh detach-disk win3test fda --persistent
成功分离磁盘
4)克隆备份虚拟机
a)克隆windows server 2003模板
[root@localhost ~]#virt-clone --original win3test --name 03template --file /home/kvm/images/03template.qcow2
[root@localhost ~]#virt-clone \
--original win3test \
--name 2003template \
--file /home/kvm/images/2003template.qcow2
##编辑配置03template.xml修改vnc端口修改为5905
[root@localhost ~]# vi /etc/libvirt/qemu/03template.xml
##1)添加分离磁盘===========================
##启动(Guest)win3test
[root@localhost ~]# virsh -c qemu:///system start win3test
##创建磁盘格式raw,添加磁盘 vdb
[root@localhost ~]#qemu-img create -f raw /home/kvm/images/vm-add.img 1G
##成功热加载vdb硬盘,硬盘在系统上能正常使用
[root@localhost ~]#virsh attach-disk win3test /home/kvm/images/vm-add.img vdb \
--cache none –persistent
##分离磁盘vdb
[root@localhost iso]# virsh detach-disk win3test vdb --persistent
##======================================
##======================================
##关闭(guest)win3test
[root@localhost ~]# virsh -c qemu:///system destroy win3test
##添加IDE硬盘,文件格式qcow2(系统开启来后无法使用新增磁盘,应该是BUG)
[root@localhost ~]# qemu-img create -f qcow2 /home/kvm/images/vm-add.qcow2 1G
[root@localhost ~]# virsh attach-disk win3test /home/kvm/images/vm-add.qcow2 hde \
--cache none --persistent --subdriver qcow2
##分离IDE磁盘关,闭系统后操作
[root@localhost iso]# virsh detach-disk win3test hde --persistent
##======================================
##======================================
##(guest)win3test关机状态的时候能成功添加,但是启动报错,应该是BUG
[root@localhost ~]#virsh attach-disk win3test /home/kvm/images/vm-add.qcow2 vdb \
--address pci:.0 --persistent \
--driver qemu --subdriver qcow2 --sourcetype file
virsh # start win3test
错误:开始域 win3test 失败
错误:internal error Process exited while reading console log output: char device redirected to /dev/pts/0
qemu-kvm: -drive file=/home/kvm/images/vm-add.qcow2,if=none,id=drive-virtio-disk1,format=qcow2: could not open disk image /home/kvm/images/vm-add.qcow2: Invalid argument
##分离vdb磁盘
[root@localhost iso]# virsh detach-disk win3test vdb --persistent
##======================================
##======================================
##(guest)win3test开机状态添加磁盘成功,但是磁盘无法读写。因为磁盘文件为qcow2
[root@localhost ~]#virsh attach-disk win3test /home/kvm/images/vm-add.qcow2 vdb \
--persistent
##分离磁盘
[root@localhost ~]# virsh detach-disk win3test vdb --persistent
成功分离磁盘
##======================================
##2)添加分离软驱=============================
##添加fda软盘(guest)win3test关机后操作
[root@localhost ~]#virsh attach-disk win3test /home/iso/virtio-WIN2003-x86.vfd fda \
--type floppy –persistent
##分离fda软驱
[root@localhost ~]#virsh detach-disk win3test fda --persistent
成功分离磁盘
##======================================
##3)添加分离光驱=============================
##添加分离光驱(guest)win3test关机后操作
[root@localhost~]# virsh detach-disk win3test hdc --persistent
成功分离磁盘
##加载光驱
[root@localhost ~]#virsh attach-disk win3test /home/iso/WIN_2003.iso hdc \
--type cdrom –persistent
##======================================
##换iso镜像文件
[root@localhost ~]#virsh change-media win3test hdc /home/iso/virtio-win-0.1-52.iso
succeeded to complete action update on media
##弹出镜像文件
[root@localhost ~]#virsh change-media win3test hdc --eject
b)克隆Centos 6.2系统模板
virt-clone \
--original linuxtest \
--name Centostemplate \
--file /home/kvm/images/Centostemplate.qcow2
##列表guest系统
[root@localhost ~]#virsh -c qemu:///system list --all
&Id&&& 名称&&&&&&&&&&&&&&&&&&&&&&&& 状态
----------------------------------------------------
&-&&&& linuxtest&&&&&&&&&&&&&&&&&&&&& 关闭
&-&&&& win3test&&&&&&&&&&&&&&&&&&&&&& 关闭
[root@localhost ~]#virt-clone \
& --original linuxtest \
& --name Centostemplate \
& --file /home/kvm/images/Centostemplate.qcow2
正在克隆 linuxtest.qcow2&&&&&&&&&&&&&&&&&&&&&&&&&&&& | 2.0 GB&&&& 00:05&&&&
Clone 'Centostemplate' created successfully.
##编辑xml修改vnc端口修改为5904
[root@localhost ~]#virsh -c qemu:///system edit Centostemplate
[root@localhost ~]#cat /etc/libvirt/qemu/Centostemplate.xml
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
& virsh edit Centostemplate
or other application using the libvirt API.
&domain type='kvm'&
& &name&Centostemplate&/name&
& &uuid&8b5f02f2-ee18-376a-ffff64c06&/uuid&
& &memory unit='KiB'&4194304&/memory&
& &currentMemory unit='KiB'&4194304&/currentMemory&
& &vcpu placement='static'&4&/vcpu&
&&& &type arch='x86_64' machine='rhel6.4.0'&hvm&/type&
&&& &boot dev='hd'/&
& &features&
&&& &acpi/&
&&& &apic/&
&&& &pae/&
& &/features&
& &clock offset='utc'/&
& &on_poweroff&destroy&/on_poweroff&
& &on_reboot&restart&/on_reboot&
& &on_crash&restart&/on_crash&
& &devices&
&&& &emulator&/usr/libexec/qemu-kvm&/emulator&
&&& &disk type='file' device='disk'&
&&&&& &driver name='qemu' type='qcow2' cache='none'/&
&&&&& &source file='/home/kvm/images/Centostemplate.qcow2'/&
&&&&& &target dev='vda' bus='virtio'/&
&&&&& &address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/&
&&& &/disk&
&&& &controller type='usb' index='0'&
&&&&& &address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/&
&&& &/controller&
&&& &interface type='bridge'&
&&&&& &mac address='52:54:00:47:13:79'/&
&&&&& &source bridge='br0'/&
&&&&& &model type='e1000'/&
&&&&& &address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/&
&&& &/interface&
&&& &serial type='pty'&
&&&&& &target port='0'/&
&&& &/serial&
&&& &console type='pty'&
&&&&& &target type='serial' port='0'/&
&&& &/console&
&&& &input type='tablet' bus='usb'/&
&&& &input type='mouse' bus='ps2'/&
&&& &graphics type='vnc' port='5904' autoport='no' listen='0.0.0.0'&
&&&&& &listen type='address' address='0.0.0.0'/&
&&& &/graphics&
&&& &video&
&&&&& &model type='cirrus' vram='9216' heads='1'/&
&&&&& &address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/&
&&& &/video&
&&& &memballoon model='virtio'&
&&&&& &address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/&
&&& &/memballoon&
& &/devices&
##===================================
##启动Centostemplate
[root@localhost ~]# virsh -c qemu:///system start Centostemplate
[root@localhost ~]# virsh -c qemu:///system list --all
&Id&&& 名称&&&&&&&&&&&&&&&&&&&&&&&& 状态
----------------------------------------------------
&22&&& Centostemplate&&&&&&&&&&&&&&&& running
&-&&&& linuxtest&&&&&&&&&&&&&&&&&&&&& 关闭
&-&&&& win3test&&&&&&&&&&&&&&&&&&&&&& 关闭
##用VNC连接
##登陆进系统删除网卡的MAC和70-persistent-net.rules然后重启机器(这样网卡不会冲突能启动)
[root@localhost ~]# rm /etc/udev/rules.d/70-persistent-net.rules
##关闭(Guest) Centostemplate
[root@localhost ~]#virsh -c qemu:///system destroy Centostemplate
##删除(Guest) Centostemplate
[root@localhost ~]#virsh -c qemu:///system undefined Centostemplate
##关于网桥,查看mac地址
[root@localhost ~]#brctl showmacs br0
##网桥设置mac生存期
[root@localhost ~]#brctl setageing br0 30
##xml虚拟机配置文件目录
/etc/libvirt/qemu
QQ:6822089
阅读(33339)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'Centos 6.4 KVM安装和配置',
blogAbstract:'\r\nCentos 6.4 KVM安装和配置\r\n',
blogTag:'centos,6.4,kvm安装,kvm,kvm配置',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:5,
publishTime:2,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:1,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'IT运维 网络管理',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}博客访问: 155991
博文数量: 71
博客积分: 10
博客等级: 民兵
技术积分: 1952
注册时间:
文明之精神,野蛮之体魄。
IT168企业级官微
微信号:IT168qiye
系统架构师大会
微信号:SACC2013
分类: 虚拟化
在Open vSwitch 分布中编译userspace程序,需要下面软件
- A make program, e.g. GNU make. BSD make should also work.
- The GNU C compiler. We generally test with version 4.1, 4.2, or 4.3.
- pkg-config. We test with version 0.22.
- libssl, from OpenSSL, is optional but recommended if you plan to&connect the Open vSwitch to an OpenFlow controller. libssl is&required to establish confidentiality and authenticity in the&connections from an Open vSwitch to an OpenFlow controller. If&libssl is installed, then Open vSwitch will automatically build&with support for it.
在linux编译内核模块,还需要安装下面的软件。如果你不能建造或安装内核模块,你可以使用userspace-only实现。
The Open vSwitch datapath requires bridging support&(CONFIG_BRIDGE) to be built as a kernel module. (This is common&in kernels provided by Linux distributions.) The bridge module&must not be loaded or in use. If the bridge module is running&(check with "lsmod | grep bridge"), you must remove it ("rmmod&bridge") before starting the datapath.
安装Open vSwitch之前确保安装了下面的软件
- libc compatible with the libc used for build.
- libssl compatible with the libssl used for build, if OpenSSL was&used for the build.
- On Linux, the same kernel version configured as part of the build.
- For optional support of ingress policing on Linux, the "tc" program&from iproute2 (part of all major distributions and available at&http://www.linux-fo&foundation.org/en/Net:Iproute2).
apt-get install build-essential
apt-get install openssl
On Linux you should ensure that /dev/urandom exists. To support TAP&devices, you must also ensure that /dev/net/tun exists.
ls -l /dev/urandom
ls -l /dev/net/tun
安装Open vSwitch
Openvswitch包下载地址:http://openvswitch.org/download/
root@ubuntu229:~# wget http://openvswitch.org/releases/openvswitch-1.9.0.tar.gz
root@ubuntu229:~# tar -xzf openvswitch-1.9.0.tar.gz
生成内核模式的Open vSwitch时需指定的内核源码编译目录,基本步骤如下
cd openvswitch-1.9.0/
./configure --with-linux=/lib/modules/`uname -r`/build
make && make install
insmod datapath/linux/openvswitch.ko
补充一下DataPath的概念,OpenFlow就是控制和数据转发分离,而控制端,就叫做Controller Path,比如floodlight等;负责转发数据的数据转发端,就叫做DataPath,也就是支持OpenFlow的硬件或者软件交换机Switch。
配置Open vSwitch
建立OpenVSwitch配置文件和数据库
root@ubuntu229:~# mkdir -p /usr/local/etc/openvswitch
root@ubuntu229:~# ovsdb-tool create /usr/local/etc/openvswitch/conf.db /usr/local/share/openvswitch/vswitch.ovsschema
启动配置数据库
root@bogon:~# ovsdb-server
--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 --bootstrap-ca-cert=db:SSL,ca_cert
--pidfile --detach
如果你built Open vSwitch 没有加SSL 支持,省略--private-key, --certificate, and --bootstrap-ca-cert
查看启动情况
ps -ef | grep ovsdb-server
初始化数据库
root@ubuntu229:~# ovs-vsctl --no-wait init
//仅需在第一次创建数据库时运行,但是每次都运行也没问题
启动Open vSwitch daemon,连接到同样的Unix domain socket上
root@ubuntu229:~# ovs-vswitchd --pidfile --detach
成功后,会有三个进程,一个ovs_workeq进程,一个ovs-vswitchd进程,一个ovsdb-server进程
升级Open vSwitch
升级Open vSwitch的时候,也需要升级数据库架构,步骤如下
1.停止Open vSwitch daemons
kill `cd /usr/local/var/run/openvswitch && cat ovsdb-server.pid ovs-vswitchd.pid`
2.安装新的版本
方法同上,下载,解压,configure make make install
3.升级数据库
两种情况如下
如果数据库没有重要的信息,可以直接删除数据库文件,然后用ovsdb-tool命令重新创建,方法同上。
如果要保留数据库的内容,首先把它备份一下,然后使用ovsdb-tool convert命令升级,
ovsdb-tool convert /usr/local/etc/openvswitch/conf.db
/usr/local/share/openvswitch/vswitch.ovsschema
4.启动Open vSwitch daemon
阅读(5507) | 评论(0) | 转发(1) |
相关热门文章
给主人留下些什么吧!~~
请登录后评论。KVM、Open vSwitch和Linux veth小实验 - 简书
KVM、Open vSwitch和Linux veth小实验
一、环境介绍
1、事先已经安装好了3个VMs,ip地址分别为1.1.1.2~42、建立了一个ovsbr1(VMs已经连接此switch)3、建立了3个veth对,并让veth对的一头连接到ovsbr1建立veth的相关配置指令如下:
ip link add veth0 type veth peer name veth0-ovsbr1
ip link add veth1 type veth peer name veth1-ovsbr1
ip link add veth2 type veth peer name veth2-ovsbr1
ifconfig veth0 1.1.1.5/24 up
ifconfig veth1 1.1.1.6/24 up
ifconfig veth2 1.1.1.7/24 up
ifconfig veth0-ovsbr1 up
ifconfig veth1-ovsbr1 up
ifconfig veth2-ovsbr1 up
ovs-vsctl add-port ovsbr1 veth0-ovsbr1
ovs-vsctl add-port ovsbr1 veth1-ovsbr1
ovs-vsctl add-port ovsbr1 veth2-ovsbr1
配草图一张,不忍直视
接下来进入实验环节
二、连通测试
最简单的ping指令,测试VMs与veth0~2的连通情况,测试结果如下,有点类似。1、veth0 ping VMs通2、veth1 ping VMs不通3、veth2 ping VMs不通4、veth之间ping不通5、VMs可以ping通每一个veth!然后,解决方法待更新。
关于这篇文章所述问题,短时间内不打算再更新了。
很忙很忙,或许以后还有机会再拾起深度学习如何在Linux发行版上安装和配置KVM和Open vSwitch?
查看: 5350|
评论: 0|来自:
摘要: 在如今多租户模式的数据中心环境下,虚拟化技术正从传统的基于虚拟机管理程序的服务器虚拟化,扩展到网络虚拟化。在这种环境下,基于软件的虚拟交换机通常连同虚拟机管理程序一起部署在服务器上,串联起了不同虚拟机 ...
在如今多租户模式的数据中心环境下,虚拟化技术正从传统的基于虚拟机管理程序的服务器虚拟化,扩展到网络虚拟化。在这种环境下,基于软件的虚拟交换机通常连同虚拟机管理程序一起部署在服务器上,串联起了不同虚拟机之间传送的流量。我在本教程上将演示如何在Ubuntu或Debian上安装和配置KVM和Open vSwitch(OVS)。KVM和Open vSwitch分别是用于如今的数据中心中的最流行的开源虚拟机管理程序和虚拟交换机。将Open vSwitch安装在Ubuntu或Debian上虽然OVS以程序包的方式出现在Ubuntu或Debian上,但我在此还是通过源代码来构建OVS,这将拥有最新的功能特性和修正版。首先,安装用于构建OVS的依赖项。$&sudo&apt-get&install&build-essential&libssl-dev&linux-headers-$(uname&-r)&通过源代码来构建OVS,如下所示。下列步骤将构建OVS内核模块以及OVS用户空间工具。$&wget&http://openvswitch.org/releases/openvswitch-1.9.3.tar.gz&$&tar&xvfvz&openvswitch-1.9.3.tar.gz&$&cd&openvswitch-1.9.3&$&./configure&--with-linux=/lib/modules/`uname&-r`/build&$&make&接下来,继续在/usr/local/share/下安装OVS用户空间组件:$&sudo&make&install&下一步是,测试OVS内核模块(安装该模块之前)。为此,先在内核中装入内核模块。$&sudo&insmod&./datapath/linux/openvswitch.ko&证实OVS内核模块已成功装入。$&lsmod&|&grep&openvswitch&openvswitch&&&&&&&&&&&&97934&&0&一旦你证实openvswitch.ko已成功装入到内核中,继续安装内核模块,如下所示。$&sudo&make&modules_install&配置和启动Open vSwitch创建一个框架式OVS配置数据库。$&sudo&mkdir&/etc/openvswitch&$&sudo&ovsdb-tool&create&/etc/openvswitch/conf.db&./vswit&chd/vswitch.ovsschema&启动OVS数据库服务器。$&sudo&ovsdb-server&--remote=punix:/usr/local/var/run/ope&nvswitch/db.sock&-&remote=db:Open_vSwitch,manager_options&--pidfile&--detach&OVS配置数据库初始化。$&sudo&ovs-vsctl&--no-wait&init&最后,启动OVS守护程序。$&sudo&ovs-vswitchd&--pidfile&--detach&将KVM安装在Ubuntu或Debian上使用apt-get命令,安装KVM和必要的用户空间工具。$&sudo&apt-get&install&qemu-kvm&libvirt-bin&bridge-utils&virt-manager&将一个普通的非根用户(如alice)添加到libvirtd群组,那样该用户不需要根用户权限,就能启动虚拟机。$&sudo&adduser&alice&libvirtd&退出,重新以该用户身份登录,让群组成员的变更生效。运行下面这个命令。如果你看到空空如也的虚拟机列表,这意味着KVM已成功设置完毕。$&virsh&-c&qemu:///system&list&Id&&&&Name&&&&&&&&State&为KVM配置Open vSwitch现在是时候创建OVS网桥启动脚本了,那样启动或终止虚拟机时,OVS就能自动配置。安装依赖项(用户模式Linux实用工具),这些依赖项将用于处理Linux网桥模式。$&sudo&apt-get&install&uml-utilities&创建网桥启动脚本,如下所示。$&sudo&vi&/etc/openvswitch/ovs-ifup&#!/bin/sh&switch='br0'&/sbin/ifconfig&$1&0.0.0.0&up&ovs-vsctl&add-port&${switch}&$1&$&sudo&vi&/etc/openvswitch/ovs-ifdown&#!/bin/sh&switch='br0'&/sbin/ifconfig&$1&0.0.0.0&down&ovs-vsctl&del-port&${switch}&$1&$&sudo&chmod&+x&/etc/openvswitch/ovs-if*&然后,创建一个默认的网桥br0,并添加一个物理网络接口,虚拟机将通过这个接口与外部网络进行联系。在该教程中,我假设这类网络接口是eth5。$&sudo&ovs-vsctl&add-br&br0&$&sudo&ovs-vsctl&add-port&br0&eth5&借助KVM启动虚拟机现在你可以准备启动访客虚拟机了。我假设,你已经准备好了一个访客虚拟机映像(比如ubuntu-client.img)。使用下面这个命令,启动访客虚拟机。$&sudo&kvm&-m&1024&-net&nic,macaddr=11:11:11:EE:EE:EE&-ne&t&tap,script=/etc/openvswitch/ovs-ifup,downscript=/etc/op&envswitch/ovs-ifdown&-vnc&:1&-drive&file=/home/dev/images&/ubuntu-client.img,boot=on&这会创建并启动一个访客虚拟机;一旦访客虚拟机启动,其虚拟接口就自动添加到OVS网桥br0。你可以使用ovs-vsctl这个命令,核实OVS的状态,如下所示。这是已启动的虚拟机的远程桌面会话。原文链接:
上一篇:下一篇:
快毕业了,没工作经验,
找份工作好难啊?
赶紧去人才芯片公司磨练吧!!

我要回帖

更多关于 苹果微信分身版免费 的文章

 

随机推荐