Azure 中的 Linux 虚拟机Linux virtual machines in Azure

Azure 虚拟机 (VM) 是 Azure 提供的多种可缩放按需分配计算资源之一。Azure Virtual Machines (VM) is one of several types of on-demand, scalable computing resources that Azure offers. 通常情况下,如果需要以更大的力度(相对于其他控制选项)控制计算环境,则应选择 VM。Typically, you choose a VM when you need more control over the computing environment than the other choices offer. 本文介绍创建 VM 之前的注意事项,以及 VM 的创建方法和管理方式。This article gives you information about what you should consider before you create a VM, how you create it, and how you manage it.

使用 Azure VM 可以灵活进行虚拟化,而无需购买和维护运行 VM 的物理硬件。An Azure VM gives you the flexibility of virtualization without having to buy and maintain the physical hardware that runs it. 不过,仍然需要通过执行任务来维护 VM,例如,配置、修补和安装在 VM 上运行的软件。However, you still need to maintain the VM by performing tasks, such as configuring, patching, and installing the software that runs on it.

可通过多种方式使用 Azure 虚拟机。Azure virtual machines can be used in various ways. 下面是一些示例:Some examples are:

  • 开发和测试 – 在 Azure VM 上,可以快速轻松地创建具有特定配置的计算机来满足编程和应用程序测试的需要。Development and test - Azure VMs offer a quick and easy way to create a computer with specific configurations required to code and test an application.
  • 云中的应用程序 – 由于应用程序的需求会不断变化,在 Azure 中的 VM 上运行应用程序可能会节省成本。Applications in the cloud - Because demand for your application can fluctuate, it might make economic sense to run it on a VM in Azure. 使用 VM 时,需要支付额外的费用;关闭 VM 时,则无需付费。You pay for extra VMs when you need them and shut them down when you don't.
  • 扩展的数据中心 – Azure 虚拟网络中的虚拟机可以轻松连接到组织的网络。Extended datacenter - Virtual machines in an Azure virtual network can easily be connected to your organization's network.

可以根据需要,将应用程序使用的 VM 纵向和横向扩展为任意数目。The number of VMs that your application uses can scale up and out to whatever is required to meet your needs.

在创建 VM 之前需要考虑哪些因素?What do I need to think about before creating a VM?

在 Azure 中构建应用程序基础结构时,始终要考虑多个设计注意事项。There are always a multitude of design considerations when you build out an application infrastructure in Azure. 在开始之前,必须考虑到 VM 的以下重要方面:These aspects of a VM are important to think about before you start:

位置Locations

在 Azure 中创建的所有资源分布在中国的多个地理区域All resources created in Azure are distributed across multiple geographical regions around China. 创建 VM 时,区域通常称为 位置Usually, the region is called location when you create a VM. 位置指定 VM 虚拟硬盘的存储位置。For a VM, the location specifies where the virtual hard disks are stored.

下表显示了获取可用位置列表的一些方法。This table shows some of the ways you can get a list of available locations.

方法Method 说明Description
Azure 门户Azure portal 创建 VM 时,可从列表中选择位置。Select a location from the list when you create a VM.
Azure PowerShellAzure PowerShell 使用 Get-AzLocation 命令。Use the Get-AzLocation command.
REST APIREST API 使用列出位置操作。Use the List locations operation.
Azure CLIAzure CLI 使用 az account list-locations 操作。Use the az account list-locations operation.

可用性Availability

Azure 宣布了行业领先的单实例虚拟机服务级别协议:可用性达到 99.9%(前提是为所有磁盘使用高级存储部署 VM)。Azure announced an industry leading single instance virtual machine Service Level Agreement of 99.9% provided you deploy the VM with premium storage for all disks. 为了使部署符合标准 99.95% 的 VM 服务级别协议,仍需要在可用性集中部署两个或更多个运行工作负荷的 VM。In order for your deployment to qualify for the standard 99.95% VM Service Level Agreement, you still need to deploy two or more VMs running your workload inside of an availability set. 可用性集可确保 VM 分布在 Azure 数据中心内的多个容错域,并使用不同的维护时段部署到主机。An availability set ensures that your VMs are distributed across multiple fault domains in the Azure data centers as well as deployed onto hosts with different maintenance windows. 完整 Azure SLA 说明了 Azure 作为整体的保证可用性。The full Azure SLA explains the guaranteed availability of Azure as a whole.

VM 大小VM Size

VM 的大小由所要运行的工作负荷决定。The size of the VM that you use is determined by the workload that you want to run. 然后,选择的大小决定了处理能力、内存和存储容量等因素。The size that you choose then determines factors such as processing power, memory, and storage capacity. Azure 提供各种大小来支持多种类型的用途。Azure offers a wide variety of sizes to support many types of uses.

Azure 根据 VM 的大小和操作系统按小时进行收费Azure charges an hourly price based on the VM's size and operating system. 对于不足一小时的部分,Azure 仅根据使用的分钟数计费。For partial hours, Azure charges only for the minutes used. 存储将另行定价和收费。Storage is priced and charged separately.

VM 限制VM Limits

订阅附带默认的配额限制,在为项目部署大量 VM 时,这些限制可能会造成影响。Your subscription has default quota limits in place that could impact the deployment of many VMs for your project. 每个订阅的当前限制是每区域 20 个 VM。The current limit on a per subscription basis is 20 VMs per region. 可以开具支持票证来请求提高限制Limits can be raised by filing a support ticket requesting an increase

托管磁盘Managed Disks

托管磁盘为用户在后台处理 Azure 存储帐户的创建和管理,确保用户无需担心存储帐户的可伸缩性限制。Managed Disks handles Azure Storage account creation and management in the background for you, and ensures that you do not have to worry about the scalability limits of the storage account. 只需指定磁盘大小和性能层(标准或高级),Azure 就会自动创建和管理磁盘。You specify the disk size and the performance tier (Standard or Premium), and Azure creates and manages the disk. 在添加磁盘或者扩展和缩减 VM 时,无需考虑所用的存储。As you add disks or scale the VM up and down, you don't have to worry about the storage being used. 如果要创建新的 VM,请使用 Azure CLI 或 Azure 门户,通过托管 OS 和数据磁盘创建 VM。If you're creating new VMs, use the Azure CLI or the Azure portal to create VMs with Managed OS and data disks. 如果 VM 具有非托管磁盘,则可以将 VM 转换为由托管磁盘支持If you have VMs with unmanaged disks, you can convert your VMs to be backed with Managed Disks.

用户还可以按 Azure 区域在一个存储帐户中管理自定义映像,并使用这些映像在同一订阅中创建数百台 VM。You can also manage your custom images in one storage account per Azure region, and use them to create hundreds of VMs in the same subscription. 有关托管磁盘的详细信息,请参阅托管磁盘概述For more information about Managed Disks, see the Managed Disks Overview.

分发Distributions

Azure 支持运行由多家合作伙伴提供和维护的众多热门 Linux 分发版。Azure supports running a number of popular Linux distributions provided and maintained by a number of partners. 可以在 Azure 市场中找到 CentOS、SUSE Linux Enterprise、Debian、Ubuntu、CoreOS 和 FreeBSD 等分发版。You can find distributions such as CentOS, SUSE Linux Enterprise, Debian, Ubuntu, CoreOS, FreeBSD, and more in the Azure Marketplace. Azure 积极与各大 Linux 社区合作以便为 Azure 认可的 Linux 发行版列表添加更多成员。Azure actively works with various Linux communities to add even more flavors to the Azure endorsed Linux Distros list.

如果首选的 Linux 分发版目前不在库中,可以通过在 Azure 中创建和上传 Linux VHD 来“自带 Linux”VM。If your preferred Linux distro of choice is not currently present in the gallery, you can "Bring your own Linux" VM by creating and uploading a Linux VHD in Azure.

Azure 与合作伙伴紧密合作,以确保及时更新可用映像并针对 Azure 运行时进行优化。Azure works closely with partners to ensure the images available are updated and optimized for an Azure runtime. 有关 Azure 合作伙伴的详细信息,请参阅以下链接:For more information on Azure partners, see the following links:

Cloud-initCloud-init

若要实现适当的 DevOps 区域性,所有基础结构都必须是代码。To achieve a proper DevOps culture, all infrastructure must be code. 当所有基础结构都存在于代码中时,便可以轻松重新创建它。When all the infrastructure lives in code it can easily be recreated. Azure 可与所有主要自动化工具(如 Ansible、SaltStack 和 Puppet)配合使用。Azure works with all the major automation tooling like Ansible, SaltStack, and Puppet. Azure 也有自己的自动化工具:Azure also has its own tooling for automation:

Azure 在支持它的大多数 Linux 发行版中支持 cloud-initAzure supports for cloud-init across most Linux Distros that support it. 我们正在积极地与我们认可的 Linux 发行版合作伙伴合作,以便在 Azure 市场中提供已启用 cloud-init 的映像。We are actively working with our endorsed Linux distro partners in order to have cloud-init enabled images available in the Azure marketplace. 这些映像可使 cloud-init 部署和配置无缝地应用于 VM 和虚拟机规模集。These images will make your cloud-init deployments and configurations work seamlessly with VMs and virtual machine scale sets.

存储Storage

网络Networking

后续步骤Next steps

创建第一个 VM!Create your first VM!