云计算虚拟化三部曲(2):存储虚拟化的原理与实现
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">大家好,我是IT售前工程师Bernie.</p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">前面一篇文章中我们讨论了计算资源的虚拟化,本篇文章我们重点讨论下存储资源的虚拟化原理与过程,欢迎阅读。</p>
<div style="text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/113ba63809c8428a866960f524bf0787~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1704568384&x-signature=CESv5edLd%2BP%2FkOXRSrbssNgcwP8%3D" style="width: 100%; margin-bottom: 20px;"></div>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">对于云计算来说,我们通常讲的存储资源不仅仅包括像硬盘这样的存储形式,还包括其他多种形式的存储空间,以及IO性能。一言以蔽之:VM可能用到的所有的存储设备都可以认为云计算的存储资源。</p>
<h1 style="text-align: left; margin-bottom: 10px;">存储资源分类</h1>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">基于上述逻辑,我们做一个简单的分类。常用到的存储资源可以分为3大类:本地存储空间、共享存储空间和分布式存储空间。</p>
<div style="text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/b753bfd5aee84ac796866d2f07cf68b7~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1704568384&x-signature=AUIsfKAS%2F2xxxZAvv9g5YfQAao0%3D" style="width: 100%; margin-bottom: 20px;"></div>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">除了存储资源以外,IO性能也是一个重要的指标,也是可以被VM经常争抢的资源。</p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">比如:某个硬盘的IOPS(存储的每秒读写速度性能)是200,那么当host OS上同时运行了5个虚拟机VM时,存储的读写性能如何分配?</p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">这里需要特别说明一点:因为不同存储设备的IO性能不尽相同,所以这里说的是IOPS是基于某个VM而言的,即:某个虚拟机可能会使用到的存储资源。而非整个资源池的维度,不一定是整个集群的整体存储资源总和。</p>
<div style="text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/7be491d85a70488fb20f7711e18edf24~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1704568384&x-signature=LAnz6NlLKyB%2BMs9e9pqHx0V55U0%3D" style="width: 100%; margin-bottom: 20px;"></div>
<h1 style="text-align: left; margin-bottom: 10px;">VM如何申请存储资源</h1>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">讲完了存储资源的分类,接下来我们说一下虚拟机VM是如何申请存储资源的,即存储资源的分配原理。</p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">我们以vmware虚拟机为例,虚拟机也是一个镜像文件,它也是以资源的形式存储在某个存储空间内,虚拟机以VMFS的文件系统来格式化磁盘。当某个VM想要使用存储设备时,它会给存储设备在本地规划一个虚拟的空间,用以存储数据。</p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">这个虚拟的空间的后缀名是.vmdk,每个虚拟机都会生成一个或多个vmdk文件(虚拟磁盘),来存储文件和数据。</p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">如下图所示,4个虚拟机想使用磁盘时,遵循“先到先得”的逻辑。只要有存储空间,谁先申请先给谁。</p>
<div style="text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/fa0d96cce47f433ea88ba40502cda93a~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1704568384&x-signature=ErSFjyurmjDhdZRCXguQ3Bp33UA%3D" style="width: 100%; margin-bottom: 20px;"></div>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">这里需要特殊说明:一个虚拟机到底是占用多少的存储空间,实际上还可以再分为三种情况。</p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;"><span style="color: green;"><span style="color: green;">精简置备</span></span></p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;"><strong style="color: blue;">概念:</strong>按需占用空间。比如VM设置的硬盘是200G,实际占用了100G,那实际占用的物理存储的100G。</p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;"><strong style="color: blue;">优缺点:</strong>精简置备的方式,可以极致地空间节省,多个VM可以复用存储资源。但是,由于申请用到的时候临时申请空间,有可能导致磁盘上限被突破,被写爆!体验差一些。</p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;"><span style="color: green;"><span style="color: green;">厚置备延迟置零</span></span></p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;"><strong style="color: blue;">概念:</strong>在VM创建的时候就做存储预留。比如VM设置的硬盘是300G,创建VM时直接从硬盘上划分出300G该VM独占,不管其实际有没有用这么多.</p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;"><strong style="color: blue;">优缺点:</strong>不会存在空间被写爆的情况,,但是存在空间利用率低的情况、也不允许超分。</p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;"><span style="color: green;"><span style="color: green;">厚置备快速置零</span></span></p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;"><strong style="color: blue;">概念:</strong>在虚拟机创建时,就预留全部硬盘空间,并且会置零这个空间内所有的数据。</p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;"><strong style="color: blue;">优缺点:</strong>不会存在空间被写爆的情况,由于前面将空间置零了,所以首次创建时候速度会比较慢。</p>
<div style="text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/810a485e3dbb40038c12b0841bbccb49~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1704568384&x-signature=av47gvEVPNUu1nHGFT8rFaznMls%3D" style="width: 100%; margin-bottom: 20px;"></div>
<h1 style="text-align: left; margin-bottom: 10px;">存储资源如何回收</h1>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">当VM使用完毕,虚拟机销毁时,它所对应的存储资源的回收机制是什么样子的呢?实际上,存储空间的回收跟内存的回收原理是相似的。</p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">起初,一个虚拟机VM上有一个1G的大文件需要删除,虚拟磁盘vmdk是没有办法直接将这个文件物理删除的,也就是说这个1G的内存空间是没有被真正回收的!这就导致存储空间只能越用越少。</p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">所以,我们得想一点办法实现真正的回收。在VMFS6.0以后实现了自动的回收(之前是手动回收的)。</p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">自动回收的机制原理大概是:<strong style="color: blue;">对于已经逻辑删除的空间VMM会置零,虚拟化层会周期性检测置零的文件,然后再回收。</strong>过程如下</p>
<div style="text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/b9b512f03f514696ae06d747ceb19f22~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1704568384&x-signature=re3p%2FiR1b64WDeRSa%2FrjQhAcAxM%3D" style="width: 100%; margin-bottom: 20px;"></div>
<h1 style="text-align: left; margin-bottom: 10px;">总结</h1>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">以上是云计算中存储虚拟化的全部分享,后续将发文进一步探讨存<strong style="color: blue;">网络虚拟化</strong>的相关内容。关于CPU和内存等计算资源虚拟化,有兴趣的小伙伴可以在合集《Bernie说云计算》进行查看。</p>
<p style="font-size: 18px; line-height: 40px; text-align: left; margin-bottom: 30px;">我是IT售前工程师Bernie,欢迎关注!下期见~</p>
页:
[1]