启用写入加速器Enable Write Accelerator

写入加速器是 M 系列虚拟机 (VM) 的磁盘功能,且只能与 Azure 托管磁盘一起在高级存储上使用。Write Accelerator is a disk capability for M-Series Virtual Machines (VMs) on Premium Storage with Azure Managed Disks exclusively. 顾名思义,该功能的目的是改善对 Azure 高级存储的写入操作的 I/O 延迟。As the name states, the purpose of the functionality is to improve the I/O latency of writes against Azure Premium Storage. 写入加速器非常适合需要更新日志文件,并以高性能方式将现代数据库保存到磁盘的情况。Write Accelerator is ideally suited where log file updates are required to persist to disk in a highly performant manner for modern databases.

通常公有云中的 M 系列 VM 可提供写入加速器。Write Accelerator is generally available for M-series VMs in the Public Cloud.

使用写入加速器进行规划Planning for using Write Accelerator

应该对包含事务日志或 DBMS 重做日志的卷使用写入加速器。Write Accelerator should be used for the volumes that contain the transaction log or redo logs of a DBMS. 建议不要对 DBMS 数据卷使用写入加速器,因为此功能已针对日志磁盘进行了优化。It is not recommended to use Write Accelerator for the data volumes of a DBMS as the feature has been optimized to be used against log disks.

只能配合 Azure 托管磁盘使用写入加速器。Write Accelerator only works in conjunction with Azure managed disks.

重要

对 VM 的操作系统磁盘启用写入加速器会重新启动该 VM。Enabling Write Accelerator for the operating system disk of the VM will reboot the VM.

若要针对不属于基于多个磁盘构建的,且使用 Windows 磁盘或卷管理器、Windows 存储空间、Windows 横向扩展文件服务器 (SOFS)、Linux LVM 或 MDADM 的现有 Azure 磁盘启用写入加速器,需要关闭访问该 Azure 磁盘的工作负荷。To enable Write Accelerator to an existing Azure disk that is NOT part of a volume build out of multiple disks with Windows disk or volume managers, Windows Storage Spaces, Windows Scale-out file server (SOFS), Linux LVM, or MDADM, the workload accessing the Azure disk needs to be shut down. 必须关闭使用 Azure 磁盘的数据库应用程序。Database applications using the Azure disk MUST be shut down.

若要针对基于多个 Azure 高级存储磁盘构建的现有卷,或者使用 Windows 磁盘或卷管理器、Windows 存储空间、Windows 横向扩展文件服务器 (SOFS)、Linux LVM 或 MDADM 的条带化卷启用或禁用写入加速器,必须通过单独的步骤,对构成该卷的所有磁盘启用或禁用写入加速器。If you want to enable or disable Write Accelerator for an existing volume that is built out of multiple Azure Premium Storage disks and striped using Windows disk or volume managers, Windows Storage Spaces, Windows Scale-out file server (SOFS), Linux LVM or MDADM, all disks building the volume must be enabled or disabled for Write Accelerator in separate steps. 在此类配置中启用或禁用写入加速器之前,请关闭 Azure VMBefore enabling or disabling Write Accelerator in such a configuration, shut down the Azure VM.

对于 SAP 相关的 VM 配置,应该不需要为 OS 磁盘启用写入加速器。Enabling Write Accelerator for OS disks should not be necessary for SAP-related VM configurations.

使用写入加速器时的限制Restrictions when using Write Accelerator

对 Azure 磁盘/VHD 使用写入加速器时,需遵循以下限制:When using Write Accelerator for an Azure disk/VHD, these restrictions apply:

  • 必须将高级磁盘缓存设置为“无”或“只读”。The Premium disk caching must be set to 'None' or 'Read Only'. 不支持其他所有缓存模式。All other caching modes are not supported.
  • 启用了写入加速器的磁盘当前不支持快照。Snapshot are not currently supported for Write Accelerator-enabled disks. 在备份期间,Azure 备份服务会自动排除连接到 VM 且启用了写入加速器的磁盘。During backup, the Azure Backup service automatically excludes Write Accelerator-enabled disks attached to the VM.
  • 仅较小的 I/O (<=512 KiB) 大小会采用加速路径。Only smaller I/O sizes (<=512 KiB) are taking the accelerated path. 在以下工作负荷情形下,I/O 写入到磁盘的更改不会采用加速路径:数据大容量加载或者数据在持久保存到存储之前,不同 DBMS 的事务日志缓冲区已较大程度上填满。In workload situations where data is getting bulk loaded or where the transaction log buffers of the different DBMS are filled to a larger degree before getting persisted to the storage, chances are that the I/O written to disk is not taking the accelerated path.

写入加速器在每个 VM 中支持的 Azure 高级存储 VHD 数目有限制。There are limits of Azure Premium Storage VHDs per VM that can be supported by Write Accelerator. 当前限制为:The current limits are:

VM SKUVM SKU 写入加速器磁盘数Number of Write Accelerator disks 每个 VM 的写入加速器磁盘 IOPSWrite Accelerator Disk IOPS per VM
M128ms, M128sM128ms, M128s 1616 2000020000
M64ms、M64ls、M64sM64ms, M64ls, M64s 88 1000010000
M32ms、M32ls、M32ts、M32sM32ms, M32ls, M32ts, M32s 44 50005000
M16ms、M16sM16ms, M16s 22 25002500
M8ms、M8sM8ms, M8s 11 12501250

IOPS 限制是针对每个 VM 而不是每个磁盘 。The IOPS limits are per VM and not per disk. 对于每个 VM,所有写入加速器磁盘具有相同的 IOPS 限制。All Write Accelerator disks share the same IOPS limit per VM. 附加的磁盘不能超过 VM 的写入加速器 IOPS 限制。Attached disks cannot exceed the write accelerator IOPS limit for a VM. 例如,即使附加的磁盘可执行 30,000 IOPS,但对于 M416ms_v2,系统不允许磁盘超过 20,000 IOPS。For an example, even though the attached disks can do 30,000 IOPS, the system does not allow the disks to go above 20,000 IOPS for M416ms_v2.

在特定磁盘上启用写入加速器Enabling Write Accelerator on a specific disk

以下几个部分介绍如何在 Azure 高级存储 VHD 上启用写入加速器。The next few sections will describe how Write Accelerator can be enabled on Azure Premium Storage VHDs.

先决条件Prerequisites

目前,使用写入加速器必须满足以下先决条件:The following prerequisites apply to the usage of Write Accelerator at this point in time:

  • 要向其应用 Azure 写入加速器的磁盘需是高级存储上的 Azure 托管磁盘The disks you want to apply Azure Write Accelerator against need to be Azure managed disks on Premium Storage.
  • 必须使用 M 系列 VMYou must be using an M-series VM

使用 Azure PowerShell 启用 Azure 写入加速器Enabling Azure Write Accelerator using Azure PowerShell

Azure PowerShell 模块 5.5.0 和更高版本对相关的 cmdlet 做了更改,以便能够针对特定的 Azure 高级存储磁盘启用或禁用写入加速器。The Azure Power Shell module from version 5.5.0 include the changes to the relevant cmdlets to enable or disable Write Accelerator for specific Azure Premium Storage disks. 为了启用或部署写入加速器支持的磁盘,以下 PowerShell 命令已发生更改,并已扩展为接受写入加速器的参数。In order to enable or deploy disks supported by Write Accelerator, the following Power Shell commands got changed, and extended to accept a parameter for Write Accelerator.

已将新的开关参数 -WriteAccelerator 添加到以下 cmdlet:A new switch parameter, -WriteAccelerator has been added to the following cmdlets:

不指定该参数会将属性设置为 false,并且会部署不受写入加速器支持的磁盘。Not giving the parameter sets the property to false and will deploy disks that have no support by Write Accelerator.

已将新的开关参数 -OsDiskWriteAccelerator 添加到以下 cmdlet:A new switch parameter, -OsDiskWriteAccelerator was added to the following cmdlets:

默认情况下,不指定该参数会将属性设置为 false,并且会返回不利用写入加速器的磁盘。Not specifying the parameter sets the property to false by default, returning disks that don't leverage Write Accelerator.

已将新的可选布尔参数(不可为 null) -OsDiskWriteAccelerator 添加到以下 cmdlet:A new optional Boolean (non-nullable) parameter, -OsDiskWriteAccelerator was added to the following cmdlets:

指定 $true 或 $false 可以控制磁盘对 Azure 写入加速器的支持。Specify either $true or $false to control support of Azure Write Accelerator with the disks.

示例命令如下所示:Examples of commands could look like:

New-AzVMConfig | Set-AzVMOsDisk | Add-AzVMDataDisk -Name "datadisk1" | Add-AzVMDataDisk -Name "logdisk1" -WriteAccelerator | New-AzVM

Get-AzVM | Update-AzVM -OsDiskWriteAccelerator $true

New-AzVmssConfig | Set-AzVmssStorageProfile -OsDiskWriteAccelerator | Add-AzVmssDataDisk -Name "datadisk1" -WriteAccelerator:$false | Add-AzVmssDataDisk -Name "logdisk1" -WriteAccelerator | New-AzVmss

Get-AzVmss | Update-AzVmss -OsDiskWriteAccelerator:$false

以下部分了演示了两个主要场景的脚本编写方式。Two main scenarios can be scripted as shown in the following sections.

使用 PowerShell 添加写入加速器支持的新磁盘Adding a new disk supported by Write Accelerator using PowerShell

可以使用此脚本将新磁盘添加到 VM。You can use this script to add a new disk to your VM. 使用此脚本创建的磁盘将使用写入加速器。The disk created with this script uses Write Accelerator.

myVMmyWAVMslog001、磁盘大小和磁盘的 LunID 替换为适用于特定部署的值。Replace myVM, myWAVMs, log001, size of the disk, and LunID of the disk with values appropriate for your specific deployment.

# Specify your VM Name
$vmName="myVM"
#Specify your Resource Group
$rgName = "myWAVMs"
#data disk name
$datadiskname = "log001"
#LUN Id
$lunid=8
#size
$size=1023
#Pulls the VM info for later
$vm=Get-AzVM -ResourceGroupName $rgname -Name $vmname
#add a new VM data disk
Add-AzVMDataDisk -CreateOption empty -DiskSizeInGB $size -Name $vmname-$datadiskname -VM $vm -Caching None -WriteAccelerator:$true -lun $lunid
#Updates the VM with the disk config - does not require a reboot
Update-AzVM -ResourceGroupName $rgname -VM $vm

使用 PowerShell 在现有 Azure 磁盘上启用写入加速器Enabling Write Accelerator on an existing Azure disk using PowerShell

可以使用以下脚本在现有磁盘上启用写入加速器。You can use this script to enable Write Accelerator on an existing disk. myVMmyWAVMstest-log001 替换为适用于特定部署的值。Replace myVM, myWAVMs, and test-log001 with values appropriate for your specific deployment. 该脚本会将写入加速器添加到 $newstatus 值设置为“$true”的现有磁盘。The script adds Write Accelerator to an existing disk where the value for $newstatus is set to '$true'. 使用 $false 值会在给定的磁盘上禁用写入加速器。Using the value '$false' will disable Write Accelerator on a given disk.

#Specify your VM Name
$vmName="myVM"
#Specify your Resource Group
$rgName = "myWAVMs"
#data disk name
$datadiskname = "test-log001" 
#new Write Accelerator status ($true for enabled, $false for disabled) 
$newstatus = $true
#Pulls the VM info for later
$vm=Get-AzVM -ResourceGroupName $rgname -Name $vmname
#add a new VM data disk
Set-AzVMDataDisk -VM $vm -Name $datadiskname -Caching None -WriteAccelerator:$newstatus
#Updates the VM with the disk config - does not require a reboot
Update-AzVM -ResourceGroupName $rgname -VM $vm

备注

执行上述脚本会分离指定的磁盘,针对该磁盘启用写入加速器,然后重新附加该磁盘Executing the script above will detach the disk specified, enable Write Accelerator against the disk, and then attach the disk again

使用 Azure 门户启用写入加速器Enabling Write Accelerator using the Azure portal

可以通过指定磁盘缓存设置的门户启用写入加速器:You can enable Write Accelerator via the portal where you specify your disk caching settings:

Azure 门户中的写入加速器

使用 Azure CLI 启用写入加速器Enabling Write Accelerator using the Azure CLI

可以使用 Azure CLI 来启用写入加速器。You can use the Azure CLI to enable Write Accelerator.

若要在现有磁盘上启用写入加速器,请使用 az vm update;若要将 diskName、VMName 和 ResourceGroup 替换为自己的值,可使用以下示例:az vm update -g group1 -n vm1 -write-accelerator 1=trueTo enable Write Accelerator on an existing disk, use az vm update, you may use the following examples if you replace the diskName, VMName, and ResourceGroup with your own values: az vm update -g group1 -n vm1 -write-accelerator 1=true

若要附加启用了写入加速器的磁盘,请使用 az vm disk attach;若要替换为自己的值,可使用以下示例:az vm disk attach -g group1 -vm-name vm1 -disk d1 --enable-write-acceleratorTo attach a disk with Write Accelerator enabled use az vm disk attach, you may use the following example if you substitute in your own values: az vm disk attach -g group1 -vm-name vm1 -disk d1 --enable-write-accelerator

若要禁用写入加速器,请使用 az vm update 将属性设置为 false:az vm update -g group1 -n vm1 -write-accelerator 0=false 1=falseTo disable Write Accelerator, use az vm update, setting the properties to false: az vm update -g group1 -n vm1 -write-accelerator 0=false 1=false

使用 Rest API 启用写入加速器Enabling Write Accelerator using Rest APIs

若要通过 Azure REST API 进行部署,需要安装 Azure armclient。To deploy through Azure Rest API, you need to install the Azure armclient.

安装 armclientInstall armclient

若要运行 armclient,需要通过 Chocolatey 安装它。To run armclient, you need to install it through Chocolatey. 可以通过 cmd.exe 或 PowerShell 来安装它。You can install it through cmd.exe or PowerShell. 使用提升的权限执行这些命令(“以管理员身份运行”)。Use elevated rights for these commands ("Run as Administrator").

使用 cmd.exe 运行以下命令:@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"Using cmd.exe, run the following command: @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

使用 Power Shell 运行以下命令:Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))Using Power Shell, run the following command: Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

现在,可以在 cmd.exe 或 PowerShell 中使用以下命令来安装 armclient:choco install armclientNow you can install the armclient by using the following command in either cmd.exe or PowerShell choco install armclient

获取当前的 VM 配置Getting your current VM configuration

若要更改磁盘配置的属性,首先需要获取 JSON 文件中的当前配置。To change the attributes of your disk configuration, you first need to get the current configuration in a JSON file. 可以执行以下命令来获取当前配置:armclient GET /subscriptions/<<subscription-ID<</resourceGroups/<<ResourceGroup>>/providers/Microsoft.Compute/virtualMachines/<<virtualmachinename>>?api-version=2017-12-01 > <<filename.json>>You can get the current configuration by executing the following command: armclient GET /subscriptions/<<subscription-ID<</resourceGroups/<<ResourceGroup>>/providers/Microsoft.Compute/virtualMachines/<<virtualmachinename>>?api-version=2017-12-01 > <<filename.json>>

将“<< >>”中的内容替换为自己的数据,包括 JSON 文件应使用的文件名。Replace the terms within '<< >>' with your data, including the file name the JSON file should have.

输出可能如下所示:The output could look like:

{
  "properties": {
    "vmId": "2444c93e-f8bb-4a20-af2d-1658d9dbbbcb",
    "hardwareProfile": {
      "vmSize": "Standard_M64s"
    },
    "storageProfile": {
      "imageReference": {
        "publisher": "SUSE",
        "offer": "SLES-SAP",
        "sku": "12-SP3",
        "version": "latest"
      },
      "osDisk": {
        "osType": "Linux",
        "name": "mylittlesap_OsDisk_1_754a1b8bb390468e9b4c429b81cc5f5a",
        "createOption": "FromImage",
        "caching": "ReadWrite",
        "managedDisk": {
          "storageAccountType": "Premium_LRS",
          "id": "/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/mylittlesap/providers/Microsoft.Compute/disks/mylittlesap_OsDisk_1_754a1b8bb390468e9b4c429b81cc5f5a"
        },
        "diskSizeGB": 30
      },
      "dataDisks": [
        {
          "lun": 0,
          "name": "data1",
          "createOption": "Attach",
          "caching": "None",
          "managedDisk": {
            "storageAccountType": "Premium_LRS",
            "id": "/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/mylittlesap/providers/Microsoft.Compute/disks/data1"
          },
          "diskSizeGB": 1023
        },
        {
          "lun": 1,
          "name": "log1",
          "createOption": "Attach",
          "caching": "None",
          "managedDisk": {
            "storageAccountType": "Premium_LRS",
            "id": "/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/mylittlesap/providers/Microsoft.Compute/disks/data2"
          },
          "diskSizeGB": 1023
        }
      ]
    },
    "osProfile": {
      "computerName": "mylittlesapVM",
      "adminUsername": "pl",
      "linuxConfiguration": {
        "disablePasswordAuthentication": false
      },
      "secrets": []
    },
    "networkProfile": {
      "networkInterfaces": [
        {
          "id": "/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/mylittlesap/providers/Microsoft.Network/networkInterfaces/mylittlesap518"
        }
      ]
    },
    "diagnosticsProfile": {
      "bootDiagnostics": {
        "enabled": true,
        "storageUri": "https://mylittlesapdiag895.blob.core.chinacloudapi.cn/"
      }
    },
    "provisioningState": "Succeeded"
  },
  "type": "Microsoft.Compute/virtualMachines",
  "location": "chinanorth",
  "id": "/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/mylittlesap/providers/Microsoft.Compute/virtualMachines/mylittlesapVM",
  "name": "mylittlesapVM"

接下来,更新 JSON 文件并在名为“log1”的磁盘上启用写入加速器。Next, update the JSON file and to enable Write Accelerator on the disk called 'log1'. 可以通过将此属性添加到 JSON 文件中磁盘缓存条目的后面来完成此步骤。This can be accomplished by adding this attribute into the JSON file after the cache entry of the disk.

        {
          "lun": 1,
          "name": "log1",
          "createOption": "Attach",
          "caching": "None",
          "writeAcceleratorEnabled": true,
          "managedDisk": {
            "storageAccountType": "Premium_LRS",
            "id": "/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/mylittlesap/providers/Microsoft.Compute/disks/data2"
          },
          "diskSizeGB": 1023
        }

然后使用以下命令更新现有部署:armclient PUT /subscriptions/<<subscription-ID<</resourceGroups/<<ResourceGroup>>/providers/Microsoft.Compute/virtualMachines/<<virtualmachinename>>?api-version=2017-12-01 @<<filename.json>>Then update the existing deployment with this command: armclient PUT /subscriptions/<<subscription-ID<</resourceGroups/<<ResourceGroup>>/providers/Microsoft.Compute/virtualMachines/<<virtualmachinename>>?api-version=2017-12-01 @<<filename.json>>

输出应如下所示。The output should look like the one below. 可以看到,为一个磁盘启用了写入加速器。You can see that Write Accelerator enabled for one disk.

{
  "properties": {
    "vmId": "2444c93e-f8bb-4a20-af2d-1658d9dbbbcb",
    "hardwareProfile": {
      "vmSize": "Standard_M64s"
    },
    "storageProfile": {
      "imageReference": {
        "publisher": "SUSE",
        "offer": "SLES-SAP",
        "sku": "12-SP3",
        "version": "latest"
      },
      "osDisk": {
        "osType": "Linux",
        "name": "mylittlesap_OsDisk_1_754a1b8bb390468e9b4c429b81cc5f5a",
        "createOption": "FromImage",
        "caching": "ReadWrite",
        "managedDisk": {
          "storageAccountType": "Premium_LRS",
          "id": "/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/mylittlesap/providers/Microsoft.Compute/disks/mylittlesap_OsDisk_1_754a1b8bb390468e9b4c429b81cc5f5a"
        },
        "diskSizeGB": 30
      },
      "dataDisks": [
        {
          "lun": 0,
          "name": "data1",
          "createOption": "Attach",
          "caching": "None",
          "managedDisk": {
            "storageAccountType": "Premium_LRS",
            "id": "/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/mylittlesap/providers/Microsoft.Compute/disks/data1"
          },
          "diskSizeGB": 1023
        },
        {
          "lun": 1,
          "name": "log1",
          "createOption": "Attach",
          "caching": "None",
          "writeAcceleratorEnabled": true,
          "managedDisk": {
            "storageAccountType": "Premium_LRS",
            "id": "/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/mylittlesap/providers/Microsoft.Compute/disks/data2"
          },
          "diskSizeGB": 1023
        }
      ]
    },
    "osProfile": {
      "computerName": "mylittlesapVM",
      "adminUsername": "pl",
      "linuxConfiguration": {
        "disablePasswordAuthentication": false
      },
      "secrets": []
    },
    "networkProfile": {
      "networkInterfaces": [
        {
          "id": "/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/mylittlesap/providers/Microsoft.Network/networkInterfaces/mylittlesap518"
        }
      ]
    },
    "diagnosticsProfile": {
      "bootDiagnostics": {
        "enabled": true,
        "storageUri": "https://mylittlesapdiag895.blob.core.chinacloudapi.cn/"
      }
    },
    "provisioningState": "Succeeded"
  },
  "type": "Microsoft.Compute/virtualMachines",
  "location": "chinanorth",
  "id": "/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/mylittlesap/providers/Microsoft.Compute/virtualMachines/mylittlesapVM",
  "name": "mylittlesapVM"

进行这项更改后,写入加速器应会支持该驱动器。Once you've made this change, the drive should be supported by Write Accelerator.