Azure的VM的设计中,Disk相关的设计是非常重要的一个内容,本文将介绍Azure上的VM的Disk相关的一些最佳实践和一些小的技巧。

一、Azure VM中Disk的存储账户设计

1. Storage类型的选择

Azure VM的Disk服务是Azure Storage中blob存储服务中的Page Blob。Azure的Storage服务的种类有:

目前,国内还只有LRS、GRS和RA-GRS三种模式。由于LRS的Ingress和Egress的吞吐量比GRS都要大(请参考下面Storage Account的limitation表格),因此如果存储账户是用做VM的Disk,除非有特殊用途,建议采用LRS的模式。

2. Storage Account的名字的设计

Storage Account Name是Storage Account的标识。具体Storage Account在后台的逻辑拓扑结构如下:

而Storage Account的负载均衡是通过Storage Account实现的。不同的Storage Account Name通过DNS解析,到不同的Storage Stamp。因此Storage Account Name的选择在某种程度上会影响Disk的性能。这主要是因为:

a. Azure存储使用分区(Partition)的方案来扩展和负载平衡。

就是说,一部分Storage Account在一个分区内,有可能多个Storage Account解析出来的IP地址都是一个,就是说这些Storage Account在一个分区内。而分区的划分是基于"键"的。而键是由Storage Account Name来决定的。如果客户选择Storage Account的名字比较相似,比如:msftpayroll, msftperformance, msftemployees,或者带时间戳的:log20160101, log20160102, log20160102,这些Storage Account有可能都被分配到同一个partition下。

b. Azure的partition是可以动态调整的。

Azure Storage有自动Balance的功能,当某一个Container的负载过高时,系统会自动进行负载的调整,实现负载均衡。但这个调整的过程中,存储的调用等的时延会增加。

c. 基于上面的讨论,建议在存储账户的设计时,就考虑这些因素。

最佳实践是:仔细检查帐户、容器、blob的命名约定。应该考虑使用散列函数给某些帐户名称前添加3位散列值。比如:s5x-msftpayroll, h79-msftperformance, n2a-msftemployees,如果企业命名规定中必须使用时间戳或数字标识,建议不要采用简单的前缀添加或后缀添加,这样有可能使所有访问集中到一个Partition上。如果采用时间,建议采用ssmmhh的模式,或在时间前加3位散列值。如果采用数字标识,建议在数字标识前加3位散列值,比如:jha-log20160101, a9g-log20160102, i76-log20160102。在linux bash里,可以通过下面的命令实现随机数:

cat /proc/sys/kernel/random/uuid | md5sum |cut -b -3
或者
echo $(date +%t%N)$RANDOM | md5sum | cut -b 1-3

3. Storage Account的高可用设计

如果创建的Storage Account主要是用于VM Disk使用的,那在Storage Account的设计中,高可用性变的至关重要。根据这几年Azure项目中碰到的问题,建议的最佳实践是:

a. VM的Disk分散到不同的Storage Account

一般会把Web、APP的VM Disk分成两组,分别放到Left和Right两个Storage Account。这样万一当有一个Storage Account出现故障时,不会影响所有的VM。另外对于DB的Disk,建议一个DB VM的Disk放到一个存储账户中,如图所示。

b. 同一层VM的Disk放到不同的Storage Account

在a中提到的部署模式下,如果客户的VM数量比较多,这样部署也存在问题:有可能会hit到Storage Account的性能上限,这时会出现VM重启或无法启动的情况,这点在后面会介绍。为了避免这种问题建议将Storage Account再细分,部署如下:

每一组VM分两个Storage Account,尽量将Disk分散部署。

4. Storage Account的容量设计

每个Storage Account都有各种指标的限制,与Disk相关的具体如下:

Resource

Default Limit

Number of storage accounts per subscription

200

TB per storage account

500 TB

Max size of a page blob

1 TB

Total Request Rate (assuming 1 KB object size) per storage account

Up to 20,000 IOPS, entities per second, or messages per second

Target throughput for single blob

Up to 60 MB per second, or up to 500 requests per second

Max ingress2 per storage account (European and Asian Regions)

5 Gbps if GRS/ZRS3 enabled, 10 Gbps for LRS

Max egress2 per storage account (European and Asian Regions)

10 Gbps if RA-GRS/GRS/ZRS3 enabled, 15 Gbps for LRS

其中每个Storage Account最大20,000个IOPS。而每个普通Disk的IOPS是500 IOPS。所以当一个Storage Account的Disk超过40个时(40*500 IOPS=20,000 IOPS),VM会出现重启或者不能启动的情况。

因此建议在每个Storage Account里的Disk的数量不要超过20个。由于Storage Account的数量相对比较大,而且没有费用产生,因此在有大量VM的情况下,建议多开Storage Account,以减少每个Storage Account中Disk的数量。

二、Azure VM中Disk挂载的一些技巧

在物理机环境下,Disk在Linux系统中的序号是以这块盘加入VM的顺序决定的。当Azure VM重新启动时,如果VM挂载了多块盘,由可能出现磁盘名称改变的情况。如果在/etc/fstab中挂载采用的是/dev/sdx的方式,有可能出现挂载错误,造成应用不能使用的情况。

解决这个问题的方法有两种:

1.采用在/etc/fstab中采用uuid进行挂载的方式

在完成fdisk和mkfs后,查看分区的uuid:

[root@hwvpntestcentos by-uuid]# pwd
/dev/disk/by-uuid
[root@hwvpntestcentos by-uuid]# ll
total
lrwxrwxrwx. root root Feb : 4357d916-ea92-49eb-b52e-250bb5ff9e15 -> ../../sdc1
lrwxrwxrwx. root root Feb : 73115bac-e4f6-4ec4-ab84-c203352ca8f6 -> ../../sdb1
lrwxrwxrwx. root root Feb : feab1e37-ed03-4d4f--4d4de8590e34 -> ../../sda1

/etc/fstab的配置如下:

# /etc/fstab
# Created by anaconda on Thu Oct ::
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(), findfs(), mount() and/or blkid() for more info
#
UUID=feab1e37-ed03-4d4f--4d4de8590e34 / xfs defaults
UUID=4357d916-ea92-49eb-b52e-250bb5ff9e15 /disk1 ext4 defaults

挂载fstab中定义的分区:

[root@hwvpntestcentos by-uuid]# mount -a
[root@hwvpntestcentos by-uuid]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 30G .3G 29G % /
devtmpfs .7G .7G % /dev
tmpfs .7G .7G % /dev/shm
tmpfs .7G 8.3M .7G % /run
tmpfs .7G .7G % /sys/fs/cgroup
/dev/sdb1 133G 61M 126G % /mnt/resource
tmpfs 345M 345M % /run/user/
/dev/sdc1 .8G 37M .2G % /disk1

2.采用lvm逻辑卷的方式挂载

lvm分三步:

pvcreate:
[root@hwvpntestcentos dev]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created
[root@hwvpntestcentos dev]# pvcreate /dev/sdd
Physical volume "/dev/sdd" successfully created
[root@hwvpntestcentos dev]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdc lvm2 --- .00g .00g
/dev/sdd lvm2 --- .00g .00g
[root@hwvpntestcentos dev]# pvdisplay
"/dev/sdc" is a new physical volume of "10.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdc
VG Name
PV Size 10.00 GiB
Allocatable NO
PE Size
Total PE
Free PE
Allocated PE
PV UUID TdVhKK-TDgM-wH52-a9Yd-fXuS-vWRf-6XpvE8
 
"/dev/sdd" is a new physical volume of "10.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdd
VG Name
PV Size 10.00 GiB
Allocatable NO
PE Size
Total PE
Free PE
Allocated PE
PV UUID vZB460-GBeB-tgtX-6HGD-BTNY-e0nO-zqnTcU

vgcreate:

[root@hwvpntestcentos dev]# vgcreate data-vg /dev/sdc /dev/sdd
Volume group "data-vg" successfully created
[root@hwvpntestcentos dev]# vgs
VG #PV #LV #SN Attr VSize VFree
data-vg wz--n- .99g .99g
[root@hwvpntestcentos dev]# vgdisplay
--- Volume group ---
VG Name data-vg
System ID
Format lvm2
Metadata Areas
Metadata Sequence No
VG Access read/write
VG Status resizable
MAX LV
Cur LV
Open LV
Max PV
Cur PV
Act PV
VG Size 19.99 GiB
PE Size 4.00 MiB
Total PE
Alloc PE / Size /
Free PE / Size / 19.99 GiB
VG UUID iCYHkh-jnPS-6YVT-ox6y-VT2s-vH2P-mCy6fZ

lvcreate:

[root@hwvpntestcentos dev]# lvcreate -i  -I  -l  -n data-lv data-vg
Logical volume "data-lv" created.
[root@hwvpntestcentos dev]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
data-lv data-vg -wi-a----- .99g
[root@hwvpntestcentos dev]# lvdisplay
--- Logical volume ---
LV Path /dev/data-vg/data-lv
LV Name data-lv
VG Name data-vg
LV UUID 39jXWa-ncvE-Qz8X-aSKg-1n4o-7uVa-1VxGQE
LV Write Access read/write
LV Creation host, time hwvpntestcentos, -- :: +
LV Status available
# open
LV Size 19.99 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device :

其中-i表示采用Raid0的方式实现磁盘的逻辑卷。此时在/dev/data-vg中存在data-lv的逻辑卷:

[root@hwvpntestcentos data-vg]# pwd
/dev/data-vg
[root@hwvpntestcentos data-vg]# ll
total
lrwxrwxrwx. root root Feb : data-lv -> ../dm-

对这个逻辑卷进行格式化:

mkfs.ext4 /dev/data-vg/data-lv

编辑/etc/fstab

# /etc/fstab
# Created by anaconda on Thu Oct ::
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(), findfs(), mount() and/or blkid() for more info
#
UUID=feab1e37-ed03-4d4f--4d4de8590e34 / xfs defaults
/dev/data-vg/data-lv /disk1 ext4 defaults

进行挂载:

[root@hwvpntestcentos data-vg]# vim /etc/fstab
[root@hwvpntestcentos data-vg]# mount -a
[root@hwvpntestcentos data-vg]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 30G .3G 29G % /
devtmpfs .7G .7G % /dev
tmpfs .7G .7G % /dev/shm
tmpfs .7G 8.3M .7G % /run
tmpfs .7G .7G % /sys/fs/cgroup
/dev/sdb1 133G 61M 126G % /mnt/resource
tmpfs 345M 345M % /run/user/
/dev/mapper/data--vg-data--lv 20G 45M 19G % /disk1

这种情况下,底层disk的磁盘再如何变化,磁盘挂载不会出现问题。

Azure VM Disk的设计与部署的更多相关文章

  1. Azure vm 扩展脚本自动部署Elasticsearch集群

    一.完整过程比较长,我仅给出Azure vm extension script 一键部署Elasticsearch集群的安装脚本,有需要的同学,可以邮件我,我给你完整的ARM Template 如果你 ...

  2. Windows Azure Virtual Machine 之用程序控制Azure VM

    我们在很多时候可能会需要用程序来控制VM的创建,删除工作. 而在这些工作之中,用程序创建一个VM将会是一个非常复杂的过程,因为他涉及到很多步骤. 具体步骤如下 1 创建一个Hosted cloud s ...

  3. Azure Managed Disk

    Azure的磁盘存储是保存在存储账户中的Page Blob.由于Azure Storage Account的各种限制,在设计VM的磁盘存储时,要符合Azure磁盘存储账户的最佳实践,请参考:http: ...

  4. Azure VM从ASM迁移到ARM(一)

    Azure的IaaS有ASM和ARM两个版本,ARM的一些优点前面已经聊过很多了.ARM有更细的管理颗粒度,更多的功能等. 如果想从ASM迁移到ARM,目前有两类方法可以实现: 1. Azure平台支 ...

  5. [转]在 Azure 云服务上设计大规模服务的最佳实践

    本文转自:http://technet.microsoft.com/zh-cn/magazine/jj717232.aspx 英文版:http://msdn.microsoft.com/library ...

  6. Azure PowerShell (9) 使用PowerShell导出订阅下所有的Azure VM的Public IP和Private IP

    <Windows Azure Platform 系列文章目录> 笔者在之前的工作中,有客户提出想一次性查看Azure订阅下的所有Azure VM的Public IP和Private IP. ...

  7. Windows Azure Virtual Machine (27) 使用psping工具,测试Azure VM网络连通性

    <Windows Azure Platform 系列文章目录> 微软Azure在设计架构的时候,从安全角度考虑,是禁用ICMP协议的.所以对于Azure VM,是无法使用ping命令的. ...

  8. Windows Azure Virtual Machine (29) 修改Azure VM 数据磁盘容量

    <Windows Azure Platform 系列文章目录> 当我们使用Windows Azure管理界面,创建Azure虚拟机的时候,默认挂载的磁盘是固定大小的 1.比如我创建1个Wi ...

  9. Windows Azure Virtual Machine (30) 修改Azure VM 的Subnet

    <Windows Azure Platform 系列文章目录> 我在使用Azure Virtual Machine虚拟机的时候,常常会结合Virtual Network虚拟网络一起使用. ...

随机推荐

  1. jQuery带闹钟的数字时钟

    在线演示 本地下载

  2. get_class_methods--返回由类的方法名组成的数组

    get_class_methods--返回由类的方法名组成的数组 array get_class_methods ( mixed $class_name ) 返回由类的方法名组成的数组. <?p ...

  3. 20145239杜文超《网络对抗》- shellcode注入&Return-to-libc攻击深入

    20145239杜文超<网络对抗>- shellcode注入&Return-to-libc攻击深入 shellcode基础知识 Shellcode是一段代码,作为数据发送给受攻击服 ...

  4. K8s API

    https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#daemonset-v1-apps http://docs.k ...

  5. python中threading多线程

    python中有两个处理多线程的模块thread和threading.其中thread提供了多线程底层支持的模块,以低级原始的发那个是来处理和控制线程,使用起来较为复杂:而threading基于thr ...

  6. 如何判断Linux服务器是否被入侵?

    被入侵服务器的症状 当服务器被没有经验攻击者或者自动攻击程序入侵了的话,他们往往会消耗 100% 的资源.他们可能消耗 CPU 资源来进行数字货币的采矿或者发送垃圾邮件,也可能消耗带宽来发动 DoS ...

  7. 【P2325】王室联邦(树的遍历+贪心)

    在肖明 #神#的推荐下,我尝试了这个题,一开始想的是暴力枚举所有的点,然后bfs层数,试着和肖明 #神#说了这种方法之后, #神#轻蔑的一笑,说这不就是一个贪心么,你只需要先建树,然后从底下向上遍历, ...

  8. dedecms 织梦列表页标题增加显示页数

    判断是否为第一页,为第一页则不显示页数的代码: {dede:pagelist listsize='0' listitem='pageno' function='html2text(@me)' runp ...

  9. Anton and School - 2 (组合数学)

    题意:给你一串只有‘(’与‘)’的字符串,问你多少对括号,括号一定是左边一半的‘(’,右边一半是‘)’ )(()()   答案是:6 题解:枚举每个‘(’,此时设左括号左边有n个‘(’,它右边有m个‘ ...

  10. iso不支持document事件

    ios safari游览器除了a.input.button等不支持document事件委托?<body>加上这个样式即可 <style> .clickable-div { cu ...