手机版
你好,游客 登录 注册
背景:
阅读新闻

KVM虚拟化性能优化

[日期:2013-02-18] 来源:Linux社区  作者:join12 [字体:大 中 小]
可从以下几个方面优化KVM虚拟机,提高虚拟机的性能。

1、全虚拟化使用半虚拟化驱动(virtio)

virtio是KVM的半虚拟化机制,可提高IO性能,使用virtio可心显著提高KVM性能。virtio包括磁盘驱动和网卡驱动,下面是在XML文件中的使用方法:
磁盘配置文件:
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/vm/testvm.img'/>
<target dev='vda' bus='virtio'/>
</disk>
网卡配置文件:
<interface type='bridge'>
<mac address='52:54:00:e3:b7:2d'/>
<source bridge='br0'/>
<model type='virtio'/>
<virtualport type='openvswitch'/>
</interface>
2、使用writeback缓存选项
针对客户机块设备的缓存,drive有一个子选项cache来设置缓存模式。两个主要的选项为writeback和writethrough,man手册是这样说的
By default, writethrough caching is used for all block device. This means that the host page cache will be used to read and write data but write notification will be sent to the guest only when the data has been reported as written by the storage subsystem.
Writeback caching will report data writes as completed as soon as the data is present in the host page cache. This is safe as long as you trust your host. If your host crashes or loses power, then the guest may experience data corruption.
writethrough写操作时不使用主机的缓存,只有当主机接受到存储子系统写操作通知时,宿主机才通知客户机写操作,也就是说这是同步的。而writeback则是异步的,它是当客户机有写请求时,先将数据写入宿主机缓存,而此时主机并未将数据真正写入存储系统。之后,待合适的时机主机会真正的将数据写入存储。显然writeback会更快。
这样使用writeback选项:
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='writeback'/>
<source file='/vm/testvm.img'/>
<target dev='vda' bus='virtio'/>
</disk>
linux
相关资讯       KVM  虚拟化  KVM虚拟化 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款