Azure VM 上的 SQL Server 常见问题解答Frequently asked questions for SQL Server on Azure VMs

适用于: Azure VM 上的 SQL Server

本文提供有关在 Windows Azure 虚拟机 (VM) 上运行 SQL Server 时出现的一些最常见问题的解答。This article provides answers to some of the most common questions about running SQL Server on Windows Azure Virtual Machines (VMs).

如果本文未解决你的 Azure 问题,请访问 MSDN 和 CSDN 上的 Azure 论坛。If your Azure issue is not addressed in this article, visit the Azure forums on MSDN and CSDN. 可以在这些论坛上发布问题。You can post your issue in these forums. 还可提交 Azure 支持请求。You also can submit an Azure support request. 若要提交支持请求,请在 Azure 支持页上提交。To submit a support request, on the Azure support page.


  1. 有哪些 SQL Server 虚拟机库映像可用?What SQL Server virtual machine gallery images are available?

    Azure 为所有 Windows 和 Linux 版本中的所有受支持 SQL Server 主要发行版维护虚拟机映像。Azure maintains virtual machine images for all supported major releases of SQL Server on all editions for both Windows and Linux. 有关详细信息,请参阅 Windows VM 映像Linux VM 映像的完整列表。For more information, see the complete list of Windows VM images and Linux VM images.

  2. 现有的 SQL Server 虚拟机库映像是否会更新?Are existing SQL Server virtual machine gallery images updated?

    每隔两个月,都会使用最新的 Windows 和 Linux 更新对虚拟机库中的 SQL Server 映像进行更新。Every two months, SQL Server images in the virtual machine gallery are updated with the latest Windows and Linux updates. 对于 Windows 映像,这包括 Windows 更新中标记为重要的任何更新,以及重要的 SQL Server 安全更新和 Service Pack。For Windows images, this includes any updates that are marked important in Windows Update, including important SQL Server security updates and service packs. 对于 Linux 映像,这包括最新的系统更新。For Linux images, this includes the latest system updates. Linux 和 Windows 的 SQL Server 累积更新以不同的方式进行处理。SQL Server cumulative updates are handled differently for Linux and Windows. 对于 Linux,SQL Server 累积更新也包含在刷新中。For Linux, SQL Server cumulative updates are also included in the refresh. 但目前,Windows VM 不会连同 SQL Server 或 Windows Server 累积更新一起更新。But at this time, Windows VMs are not updated with SQL Server or Windows Server cumulative updates.

  3. 是否可以从库中删除 SQL Server 虚拟机映像?Can SQL Server virtual machine images get removed from the gallery?

    是的。Yes. Azure 只为每个主要版本维护一个映像。Azure only maintains one image per major version and edition. 例如,发布新的 SQL Server Service Pack 时,Azure 会将新映像添加到该 Service Pack 的库。For example, when a new SQL Server service pack is released, Azure adds a new image to the gallery for that service pack. 先前 Service Pack 的 SQL Server 映像将立即从 Azure 门户中删除。The SQL Server image for the previous service pack is immediately removed from the Azure portal. 但是,在接下来的三个月,仍可以通过 PowerShell 预配该映像。However, it is still available for provisioning from PowerShell for the next three months. 三个月之后,先前的 Service Pack 映像不再可用。After three months, the previous service pack image is no longer available. 如果 SQL Server 版本由于生命周期结束而不受支持,则也会应用此删除策略。This removal policy would also apply if a SQL Server version becomes unsupported when it reaches the end of its lifecycle.

  4. 是否可以部署 Azure 门户中不可见的较旧的 SQL Server 映像?Is it possible to deploy an older image of SQL Server that is not visible in the Azure portal?

    是的,使用 PowerShell。Yes, by using PowerShell. 有关使用 PowerShell 部署 SQL Server VM 的详细信息,请参阅如何使用 Azure PowerShell 预配 SQL Server 虚拟机For more information about deploying SQL Server VMs using PowerShell, see How to provision SQL Server virtual machines with Azure PowerShell.

  1. 如何使 Azure VM 上的 SQL Server 通用化并使用它部署新 VM?How do I generalize SQL Server on Azure VM and use it to deploy new VMs?

    可以部署 Windows Server VM(不安装 SQL Server),并使用 SQL sysprep 进程和 SQL Server 安装媒体将 Azure VM (Windows) 上的 SQL Server 通用化。You can deploy a Windows Server VM (without SQL Server installed on it) and use the SQL sysprep process to generalize SQL Server on Azure VM (Windows) with the SQL Server installation media. 如果客户有软件保障,则可以从批量许可中心获取其安装介质。Customers who have Software Assurance can obtain their installation media from the Volume Licensing Center. 没有软件保障的客户可以使用具有所需版本的 Azure 市场 SQL Server VM 映像中的安装介质。Customers who don't have Software Assurance can use the setup media from an Azure Marketplace SQL Server VM image that has the desired edition.

    另外,也可使用 Azure 市场中的 SQL Server 映像之一来将 Azure VM 上的 SQL Server 通用化。Alternatively, use one of the SQL Server images from Azure Marketplace to generalize SQL Server on Azure VM. 请注意,在创建你自己的映像之前,必须在源映像中删除以下注册表项。Note that you must delete the following registry key in the source image before creating your own image. 如果不这样做,可能会导致 SQL Server 安装程序的启动文件夹扩展以及/或者 SQL IaaS 扩展处于故障状态。Failure to do so can result in the bloating of the SQL Server setup bootstrap folder and/or SQL IaaS extension in failed state.

    注册表项路径:Registry Key path:

  2. 是否可以使用我自己的 VHD 来部署 SQL Server VM?Can I use my own VHD to deploy a SQL Server VM?

    可以,但必须向 SQL IaaS 代理扩展注册每个 SQL Server VM,以便在门户中管理 SQL Server VM,以及利用自动修补和自动备份等功能。Yes, but you must then register each SQL Server VM with the SQL IaaS Agent extension to manage your SQL Server VM in the portal, as well as utilize features such as automated patching and automatic backups.

  3. 是否可以设置虚拟机库中未显示的配置(例如 Windows 2008 R2 + SQL Server 2012)?Is it possible to set up configurations not shown in the virtual machine gallery (for example Windows 2008 R2 + SQL Server 2012)?

    否。No. 对于包含 SQL Server 的虚拟机图库映像,必须通过 Azure 门户或 PowerShell 选择提供的某个映像。For virtual machine gallery images that include SQL Server, you must select one of the provided images either through the Azure portal or via PowerShell. 但是,可以部署一个 Windows VM 并在其中自行安装 SQL Server。However, you have the ability to deploy a Windows VM and self-install SQL Server to it. 然后必须向 SQL IaaS 代理扩展注册 SQL Server VM,以便在 Azure 门户中管理 SQL Server VM,以及利用自动修补和自动备份等功能。You must then register your SQL Server VM with the SQL IaaS Agent extension to manage your SQL Server VM in the Azure portal, as well as utilize features such as automated patching and automatic backups.


  1. 如何创建装有 SQL Server 的 Azure 虚拟机?How do I create an Azure virtual machine with SQL Server?

    最简单的方法是创建包含 SQL Server 的虚拟机。The easiest method is to create a virtual machine that includes SQL Server. 有关注册 Azure 并从门户创建 SQL Server VM 的教程,请参阅在 Azure 门户中预配 SQL Server 虚拟机For a tutorial on signing up for Azure and creating a SQL Server VM from the portal, see Provision a SQL Server virtual machine in the Azure portal. 可选择使用按秒付费 SQL Server 许可的虚拟机映像,或者可以使用允许自带 SQL Server 许可证的映像。You can select a virtual machine image that uses pay-per-second SQL Server licensing, or you can use an image that allows you to bring your own SQL Server license. 此外,你也可以选用免费许可版(开发人员版或速成版),或通过重新使用本地许可证在 VM 上手动安装 SQL Server。You also have the option of manually installing SQL Server on a VM with either a freely licensed edition (Developer or Express) or by reusing an on-premises license. 请务必向 SQL IaaS 代理扩展注册 SQL Server VM,以便在 Azure 门户中管理 SQL Server VM,以及利用自动修补和自动备份等功能。Be sure to register your SQL Server VM with the SQL IaaS Agent extension to manage your SQL Server VM in the portal, as well as utilize features such as automated patching and automatic backups. 如果自带许可,必须在 Azure 上通过软件保障实现许可证移动性If you bring your own license, you must have License Mobility through Software Assurance on Azure. 有关详细信息,请参阅 SQL Server Azure VM 定价指南For more information, see Pricing guidance for SQL Server Azure VMs.

  2. 如何将本地 SQL Server 数据库迁移到云中?How can I migrate my on-premises SQL Server database to the cloud?

    首先,请创建装有 SQL Server 实例的 Azure 虚拟机。First create an Azure virtual machine with a SQL Server instance. 然后将本地数据库迁转到该实例。Then migrate your on-premises databases to that instance. 有关数据迁移策略,请参阅 将 SQL Server 数据库迁移到 Azure VM 中的 SQL ServerFor data migration strategies, see Migrate a SQL Server database to SQL Server in an Azure VM.


  1. 如何在 Azure VM 上安装 SQL Server 的许可版本?How can I install my licensed copy of SQL Server on an Azure VM?

    可通过两种方式来执行此操作。There are two ways to do this. 企业协议 (EA) 客户可以预配支持许可证的虚拟机映像之一,也称为自带许可 (BYOL)。If you're an Enterprise Agreement (EA) customer, you can provision one of the virtual machine images that supports licenses, which is also known as bring-your-own-license (BYOL). 或者,可将 SQL Server 安装媒体复制到 Windows Server VM,然后在 VM 上安装 SQL Server。Or you can copy the SQL Server installation media to a Windows Server VM, and then install SQL Server on the VM. 请务必更新 Azure 门户中“设置”边栏的 SQL Server 配置,以便能够使用门户管理、自动备份和自动修补等功能。Be sure to update the SQL Server configureation of Setting sidebar in Azure portal for features such as portal management, automated backup and automated patching.

  1. 是否可以在使用经典模型部署的 SQL Server VM 上切换许可模型?Is it possible to switch licensing models on a SQL Server VM deployed using classic model?

    否。No. 不支持在经典 VM 上更改许可模型。Changing licensing models is not supported on a classic VM. 可将 VM 迁移到 Azure 资源管理器模型,并将其注册到 SQL Server VM 资源提供程序。You may migrate your VM to the Azure Resource Manager model and register with the SQL Server VM resource provider. 将 VM 注册到 SQL Server VM 资源提供程序后,即可在 VM 上更改许可模型。Once the VM is registered with the SQL Server VM resource provider, licensing model changes will be available on the VM.

  1. 如果 Azure VM 仅供备用/故障转移,是否必须支持该 VM 上的 SQL Server 许可费?Do I have to pay to license SQL Server on an Azure VM if it is only being used for standby/failover?

    若要获得备用辅助可用性组或故障转移群集实例的免费被动许可证,必须满足产品许可条款中所述的以下所有条件:To have a free passive license for a standby secondary availability group or failover clustered instance, you must meet all of the following criteria as outlined by the Product Licensing Terms:

    1. 已通过软件保障获得许可移动性You have license mobility through Software Assurance.
    2. 被动 SQL Server 实例不会为客户端提供 SQL Server 数据,也不会运行活动的 SQL Server 工作负荷。The passive SQL Server instance does not serve SQL Server data to clients or run active SQL Server workloads. 它只用于与主服务器同步,或者使被动数据库保持热备用状态。It is only used to synchronize with the primary server and otherwise maintain the passive database in a warm standby state. 如果它正在提供数据(例如,向运行活动 SQL Server 工作负载的客户端报告,或执行未在产品条款中指定的任何工作),则它必须是付费许可的 SQL Server 实例。If it is serving data, such as reports to clients running active SQL Server workloads, or performing any work other than what is specified in the product terms, it must be a paid licensed SQL Server instance. 允许对辅助实例执行以下活动:数据库一致性检查或 CheckDB、完整备份、事务日志备份,以及资源使用情况数据监视。The following activity is permitted on the secondary instance: database consistency checks or CheckDB, full backups, transaction log backups, and monitoring resource usage data. 还可以在每隔 90 天运行一次灾难恢复测试的短暂时段内,同时运行主实例和相应的灾难恢复实例。You may also run the primary and corresponding disaster recovery instance simultaneously for brief periods of disaster recovery testing every 90 days.
    3. 活动的 SQL Server 许可证已涵盖在软件保障中,仅允许 一个 被动辅助 SQL Server 实例,允许的计算量不能超过已许可的活动服务器。The active SQL Server license is covered by Software Assurance and allows for one passive secondary SQL Server instance, with up to the same amount of compute as the licensed active server, only.


  1. 是否可以在同一 VM 上安装另一个 SQL Server 实例?是否可以更改默认实例的已安装功能?Can I install a second instance of SQL Server on the same VM? Can I change installed features of the default instance?

    是的。Yes. SQL Server 安装介质位于 C 驱动器上的某个文件夹中。The SQL Server installation media is located in a folder on the C drive. 可从该位置运行 Setup.exe 以添加新的 SQL Server 实例,或更改计算机上 SQL Server 的其他已安装功能。Run Setup.exe from that location to add new SQL Server instances or to change other installed features of SQL Server on the machine. 请注意,某些功能(例如自动备份、自动修补和 Azure Key Vault 集成)仅对默认实例或配置正确的命名实例起作用(请参阅问题 3)。Note that some features, such as Automated Backup, Automated Patching, and Azure Key Vault Integration, only operate against the default instance, or a named instance that was configured properly (See Question 3).

  2. 是否可以卸载 SQL Server 的默认实例?Can I uninstall the default instance of SQL Server?

    可以,但需注意以下事项。Yes, but there are some considerations. 首先,根据 VM 的许可模型,与 SQL Server 相关的计费可能会继续发生。First, SQL Server-associated billing may continue to occur depending on the license model for the VM. 其次,如前面的解答中所述,某些功能依赖于 SQL Server IaaS 代理扩展Second, as stated in the previous answer, there are features that rely on the SQL Server IaaS Agent Extension. 如果卸载默认实例但未同时删除 IaaS 扩展,该扩展会继续查找默认实例并可能生成事件日志错误。If you uninstall the default instance without removing the IaaS extension also, the extension continues to look for the default instance and may generate event log errors. 这些错误来自以下两个源:Microsoft SQL Server 凭据管理和 Microsoft SQL Server IaaS 代理 。These errors are from the following two sources: Microsoft SQL Server Credential Management and Microsoft SQL Server IaaS Agent. 其中一个错误可能类似于以下内容:One of the errors might be similar to the following:

    建立与 SQL Server 的连接时,出现网络相关或特定于实例的错误。A network-related or instance-specific error occurred while establishing a connection to SQL Server. 找不到或无法访问服务器。The server was not found or was not accessible.

    如果决定卸载默认实例,还要卸载 SQL Server IaaS 代理扩展If you do decide to uninstall the default instance, also uninstall the SQL Server IaaS Agent Extension as well.

  3. 是否可从 SQL Server VM 中完全删除 SQL Server?Can I remove SQL Server completely from a SQL Server VM?

    是的,但仍将按照 SQL Server Azure VM 的定价指南收取 SQL Server VM 费用。Yes, but you will continue to be charged for your SQL Server VM as described in Pricing guidance for SQL Server Azure VMs. 如果不再需要 SQL Server,可以部署新的虚拟机并将数据和应用程序迁移到新的虚拟机。If you no longer need SQL Server, you can deploy a new virtual machine and migrate the data and applications to the new virtual machine. 然后可以删除 SQL Server 虚拟机。Then you can remove the SQL Server virtual machine.

更新和修补Updating and patching

  1. 如何将更新和服务包应用于 SQL Server VM?How are updates and service packs applied on a SQL Server VM?

    虚拟机允许控制主机,包括应用更新的时间与方法。Virtual machines give you control over the host machine, including when and how you apply updates. 对于操作系统,可以手动应用 Windows 更新,或者启用名为自动修补的计划服务。For the operating system, you can manually apply windows updates, or you can enable a scheduling service called Automated Patching. 自动修补将安装任何标记为重要的更新,包括该类别中的 SQL Server 更新。Automated Patching installs any updates that are marked important, including SQL Server updates in that category. 必须手动安装其他可选的 SQL Server 更新。Other optional updates to SQL Server must be installed manually.

  1. 如何获取终止支持的 SQL Server 2008 和 SQL Server 2008 R2 实例的免费扩展安全更新?How can I get free extended security updates for my end of support SQL Server 2008 and SQL Server 2008 R2 instances?

    可以通过将 SQL Server 按原样迁移到 Azure 虚拟机,获取免费扩展安全更新You can get free extended security updates by moving your SQL Server as-is to an Azure virtual machine. 有关详细信息,请参阅终止支持选项For more information, see end of support options.


  1. Azure VM 是否支持 SQL Server 故障转移群集实例 (FCI)?Are SQL Server failover cluster instances (FCI) supported on Azure VMs?

    是的。Yes. 可以使用存储子系统的高级文件共享 (PFS)存储空间直通 (S2D) 安装故障转移群集实例。You can install a failover cluster instance using either premium file shares (PFS) or storage spaces direct (S2D) for the storage subsystem. 高级文件共享提供可满足许多工作负载需求的 IOPS 和吞吐量。Premium file shares provide IOPS and throughput capacities that will meet the needs of many workloads. 对于 IO 密集型工作负载,请根据托管的高级磁盘考虑使用存储空间直通。For IO-intensive workloads, consider using storage spaces direct based on manged premium disks. 或者,可使用第三方群集或存储解决方案,如 Azure 虚拟机中 SQL Server 的高可用性和灾难恢复中所述。Alternatively, you can use third-party clustering or storage solutions as described in High availability and disaster recovery for SQL Server on Azure Virtual Machines.


    目前,Azure 上的 SQL Server FCI 不支持 完整的 SQL Server IaaS 代理扩展At this time, the full SQL Server IaaS Agent Extension is not supported for SQL Server FCI on Azure. 我们建议你从参与 FCI 的 VM 中卸载 完整 扩展,并改为在 轻型 模式下安装该扩展。We recommend that you uninstall the full extension from VMs that participate in the FCI, and install the extension in lightweight mode instead. 此扩展支持自动备份和修补等功能,以及 SQL Server 的一些门户功能。This extension supports features, such as Automated Backup and Patching and some portal features for SQL Server. 卸载 完整 代理以后,这些功能将不适用于 SQL Server VM。These features will not work for SQL Server VMs after the full agent is uninstalled.

  2. SQL Server VM 与 SQL 数据库服务之间的差别是什么?What is the difference between SQL Server VMs and the SQL Database service?

    从概念上讲,在 Azure 虚拟机上运行 SQL Server 与在远程数据中心运行 SQL Server 并没什么不同。Conceptually, running SQL Server on an Azure virtual machine is not that different from running SQL Server in a remote datacenter. 相比之下,Azure SQL 数据库 可提供数据库即服务。In contrast, Azure SQL Database offers database-as-a-service. 使用 SQL 数据库时,无法访问托管数据库的计算机。With SQL Database, you do not have access to the machines that host your databases. 有关完整比较,请参阅选择云 SQL Server 选项:Azure SQL (PaaS) 数据库或 Azure VM 上的 SQL Server (IaaS)For a full comparison, see Choose a cloud SQL Server option: Azure SQL (PaaS) Database or SQL Server on Azure VMs (IaaS).

  3. 如何在 Azure VM 上安装 SQL Data Tools?How do I install SQL Data tools on my Azure VM?

    Microsoft SQL Server 数据工具 - Visual Studio 2013 商业智能下载并安装 SQL 数据工具。Download and install the SQL Data tools from Microsoft SQL Server Data Tools - Business Intelligence for Visual Studio 2013.

  4. SQL Server VM 是否支持使用 MSDTC 的分布式事务?Are distributed transactions with MSDTC supported on SQL Server VMs?

    是的。Yes. SQL Server 2016 SP2 和更高版本支持本地 DTC。Local DTC is supported for SQL Server 2016 SP2 and greater. 但是,在使用 Always On 可用性组时必须对应用程序进行测试,因为故障转移期间正在进行的事务将会失败,并且必须重试。However, applications must be tested when utilizing Always On availability groups, as transactions in-flight during a failover will fail and must be retried. 从 Windows Server 2019 开始将会推出群集 DTC。Clustered DTC is available starting with Windows Server 2019.


Windows VMWindows VMs:

Linux VMLinux VMs: