通过运行“启用数据库延伸向导”开始Get started by running the Enable Database for Stretch Wizard

本主题适用于:yesSQL Server(仅从 2016 开始的 Windows)noAzure SQL 数据库noAzure SQL 数据仓库no并行数据仓库THIS TOPIC APPLIES TO: yesSQL Server (Windows only starting with 2016)noAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

若要为 Stretch Database 配置数据库,请运行“启用数据库延伸向导”。To configure a database for Stretch Database, run the Enable Database for Stretch Wizard. 本文介绍了需要在该向导中输入的信息和做出的选择。This article describes the info that you have to enter and the choices that you have to make in the wizard.

若要了解 Stretch Database,请参阅 Stretch DatabaseTo learn more about Stretch Database, see Stretch Database.

备注

之后如果要禁用 Stretch Database,请记住,禁用表或数据库的 Stretch Database 不会删除远程对象。Later, if you disable Stretch Database, remember that disabling Stretch Database for a table or for a database does not delete the remote object. 如果希望删除远程表或远程数据库,则需要使用 Azure 管理门户进行删除。If you want to delete the remote table or the remote database, you have to drop it by using the Azure management portal. 远程对象会继续产生 Azure 成本,直到手动删除它们。The remote objects continue to incur Azure costs until you delete them manually.

启动向导Launch the wizard

  1. 在 SQL Server Management Studio 的对象资源管理器中,选择你想在其上启用 Stretch 的数据库。In SQL Server Management Studio, in Object Explorer, select the database on which you want to enable Stretch.

  2. 右键单击并选择“任务”,再选择“Stretch”,然后选择“启用”以启动向导。Right-click and select Tasks, and then select Stretch, and then select Enable to launch the wizard.

简介Introduction

查看向导和必备组件的用途。Review the purpose of the wizard and the prerequisites.

重要的先决条件包括以下内容。The important prerequisites include the following.

  • 必须是管理员才能更改数据库设置。You have to be an administrator to change database settings.
  • 必须有 Microsoft Azure 订阅。You have to have a Microsoft Azure subscription.
  • 你的 SQL Server 必须能够使用远程 Azure 服务器进行通信。Your SQL Server has to be able to communicate with the remote Azure server.

    Stretch Database 向导的“简介”页Introduction page of Stretch Database wizard

选择表Select tables

选择想要为其启用 Stretch 的表。Select the tables that you want to enable for Stretch.

具有大量行的表显示于已排序列表的顶端。Tables with lots of rows appear at the top of the sorted list. 向导显示表的列表之前,它会对当前不受 Stretch Database 支持的数据类型对其进行分析。Before the Wizard displays the list of tables, it analyzes them for data types that are not currently supported by Stretch Database.

Stretch Database 向导的“选择表”页Select tables page of Stretch Database wizard

“列”Column DescriptionDescription
(无标题)(no title) 选中此列中的复选框以为所选的表启用 Stretch。Check the check box in this column to enable the selected table for Stretch.
名称Name 指定数据库中表的名称。Specifies the name of the table in the database.
(无标题)(no title) 此列中的符号可能代表一条警告,不会阻止你为 Stretch 启用所选表。A symbol in this column may represent a warning that doesn't prevent you from enabling the selected table for Stretch. 还有可能代表一个阻止问题,将阻止你为 Stretch 启用所选表 - 例如因为该表使用了不支持的数据类型。It may also represent a blocking issue that prevents you from enabling the selected table for Stretch - for example, because the table uses an unsupported data type. 将鼠标悬停符号上,以在工具提示中显示详细信息。Hover over the symbol to display more info in a tooltip. 有关详细信息,请参阅 Stretch Database 限制For more info, see Limitations for Stretch Database.
已拉伸Stretched 指示该表是否已为 Stretch 启用。Indicates whether the table is already enabled for Stretch.
迁移Migrate 你可以迁移整个表(整个表),或在表中现有的列上指定一个筛选器。You can migrate an entire table (Entire Table) or you can specify a filter on an existing column in the table. 若想要使用不同的筛选器函数来选择要迁移的行,请运行 ALTER TABLE 语句以在退出向导后指定筛选器函数。If you want to use a different filter function to select rows to migrate, run the ALTER TABLE statement to specify the filter function after you exit the wizard. 有关筛选器函数的详细信息,请参阅通过使用筛选器函数选择要迁移的行For more info about the filter function, see Select rows to migrate by using a filter function. 有关如何应用函数的详细信息,请参阅为表启用 Stretch DatabaseALTER TABLE (Transact-SQL)For more info about how to apply the function, see Enable Stretch Database for a table or ALTER TABLE (Transact-SQL).
Rows 指定表中的行数。Specifies the number of rows in the table.
大小(KB)Size (KB) 指定表的大小(以 KB 为单位)。Specifies the size of the table in KB.

选择性地提供行筛选器Optionally provide a row filter

若想要提供筛选器函数来选择要迁移的行,请在“选择表”页执行以下操作。If you want to provide a filter function to select rows to migrate, do the following things on the Select tables page.

  1. 在“选择你想要拉伸的表”列表中,在表的行中单击“整个表”。In the Select the tables you want to stretch list, click Entire Table in the row for the table. 将打开“选择要拉伸的行”对话框。The Select rows to stretch dialog box opens.

    定义基于日期的筛选器谓词Define a date-based filter predicate

  2. 在“选择要拉伸的行”对话框中,选择“选择行”。In the Select rows to stretch dialog box, select Choose Rows.

  3. 在“名称字段”中,为筛选器函数提供一个名称。In the Name field, provide a name for the filter function.

  4. Where 子句中,选择表中的某列,然后选择一个运算符并提供一个值。For the Where clause, pick a column from the table, pick an operator, and provide a value.

  5. 单击“检查”以测试函数。Click Check to test the function. 如果函数从表中返回结果 - 即如果存在满足条件的待迁移的行 - 该测试会报告“成功”。If the function returns results from the table - that is, if there are rows to migrate that satisfy the condition - the test reports Success.

备注

显示筛选器查询的文本框为只读。The textbox that displays the filter query is read-only. 无法在文本框中编辑查询。You can't edit the query in the textbox.

  1. 单击“完成”,返回到“选择表”页。Click Done to return to the Select tables page.

仅在完成该向导时,才会在 SQL Server 中创建筛选器函数。The filter function is created in SQL Server only when you finish the wizard. 届时你可以返回到“选择表”页更改或重命名该筛选器函数。Until then, you can return to the Select tables page to change or rename the filter function.

定义筛选器谓词后的“选择表”页Select Tables page after defining a filter predicate

如果想要使用不同类型的筛选器函数来选择要迁移的行,请执行以下操作之一。If you want to use a different type of filter function to select rows to migrate, do one of the following things.

配置 AzureConfigure Azure

  1. 使用 Microsoft 帐户登录到 Microsoft Azure。Sign in to Microsoft Azure with a Microsoft account.

    登录到 Azure - Stretch Database 向导Sign in to Azure - Stretch Database wizard

  2. 为 Stretch Database 选择要使用的现有 Azure 订阅。Select the existing Azure subscription to use for Stretch Database.

备注

若要在数据库上启用 Stretch,则必须具有正在使用的订阅的管理员权限。To enable Stretch on a database you must have administrator rights to the subscription you are using. Stretch Database 向导将只显示用户具有管理员权限的订阅。Stretch Database wizard will only show subscriptions where the user has administrator rights.

  1. 为 Stretch Database 选择要使用的 Azure 区域。Select the Azure region to use for Stretch Database.

    • 如果创建一个新服务器,则该服务器将在此区域进行创建。If you create a new server, the server is created in this region.
    • 如果你在所选区域中有现有的服务器,则当你选择“现有服务器”时,向导会将其列出。If you have existing servers in the selected region, the wizard lists them when you choose Existing server.

      为了尽量减少延迟,请选择 SQL Server 所在的 Azure 区域。To minimize latency, pick the Azure region in which your SQL Server is located. 有关区域的详细信息,请参阅 Azure 区域For more info about regions, see Azure Regions.

  2. 指定是希望使用现有服务器还是新建 Azure 服务器。Specify whether you want to use an existing server or create a new Azure server.

    如果 SQL Server 上的 Active Directory 与 Azure Active Directory 联合,则可以选择使用 SQL Server 的联合服务帐户与远程 Azure 服务器进行通信。If the Active Directory on your SQL Server is federated with Azure Active Directory, you can optionally use a federated service account for SQL Server to communicate with the remote Azure server. 有关此选项要求的详细信息,请参阅 ALTER DATABASE SET 选项 (Transact-SQL)For more info about the requirements for this option, see ALTER DATABASE SET Options (Transact-SQL).

    • 新建服务器Create new server

      1. 创建服务器管理员的登录名和密码。Create a login and password for the server administrator.

      2. 或者,使用 SQL Server 的联合服务帐户与远程 Azure 服务器进行通信。Optionally, use a federated service account for SQL Server to communicate with the remote Azure server.

        新建 Azure 服务器 - Stretch Database 向导Create new Azure server - Stretch Database wizard

    • 现有服务器Existing server

      1. 选择现有的 Azure 服务器。Select the existing Azure server.

      2. 选择身份验证方法。Select the authentication method.

        • 如果选择“SQL Server 身份验证”,请提供管理员登录名和密码。If you select SQL Server Authentication, provide the administrator login and password.

        • 选择“Active Directory 集成身份验证” ,以使用 SQL Server 的联合服务帐户与远程 Azure 服务器进行通信。Select Active Directory Integrated Authentication to use a federated service account for SQL Server to communicate with the remote Azure server. 如果所选服务器未与 Azure Active Directory 集成,则此选项不会出现。If the selected server is not integrated with Azure Active Directory, this option doesn't appear.

        选择现有 Azure 服务器 - Stretch Database 向导Select existing Azure server - Stretch Database wizard

安全凭据Secure credentials

必须有一个数据库主密钥,以保护 Stretch Database 用于连接到远程数据库的凭据。You have to have a database master key to secure the credentials that Stretch Database uses to connect to the remote database.

如果数据库主密钥已存在,请对其输入密码。If a database master key already exists, enter the password for it.

Stretch Database 向导的“安全凭据”页Secure credentials page of the Stretch Database wizard

如果数据库没有现有的主密钥,请输入一个强密码以创建数据库主密钥。If the database does not have an existing master key, enter a strong password to create a database master key.

Stretch Database 向导的“安全凭据”页Secure credentials page of the Stretch Database wizard

有关数据库主密钥的详细信息,请参阅 CREATE MASTER KEY (Transact-SQL)创建数据库主密钥For more info about the database master key, see CREATE MASTER KEY (Transact-SQL) and Create a Database Master Key. 有关向导创建的凭据的详细信息,请参阅 CREATE DATABASE SCOPED CREDENTIAL (Transact-SQL)For more info about the credential that the wizard creates, see CREATE DATABASE SCOPED CREDENTIAL (Transact-SQL).

选择 IP 地址Select IP address

使用子网 IP 地址范围(推荐)或 SQL Server 的公共 IP 地址,在允许 SQL Server 与远程 Azure 服务器通信的 Azure 上创建防火墙规则。Use the subnet IP address range (recommended), or the public IP address of your SQL Server, to create a firewall rule on Azure that lets SQL Server communicate with the remote Azure server.

你在此页上提供的 IP 地址(一个或多个)将告知 Azure 服务器允许通过 Azure 防火墙传递由 SQL Server 启动的传入数据、查询和管理操作。The IP address or addresses that you provide on this page tell the Azure server to allow incoming data, queries, and management operations initiated by SQL Server to pass through the Azure firewall. 该向导不会更改 SQL Server 上的防火墙设置中的任何内容。The wizard doesn't change anything in the firewall settings on the SQL Server.

Stretch Database 向导的“选择 IP 地址”页Select IP address page of the Stretch Database wizard

摘要Summary

查看你输入的值和你在该向导中选择的选项以及 Azure 上的预估成本。Review the values that you entered and the options that you selected in the wizard and the estimated costs on Azure. 然后选择“完成” 以启用 Stretch。Then select Finish to enable Stretch.

Stretch Database 向导的“摘要”页Summary page of the Stretch Database wizard

结果Results

查看结果。Review the results.

若要监视数据迁移的状态,请参阅数据迁移的监视与故障排除 (Stretch Database)To monitor the status of data migration, see Monitor and troubleshoot data migration (Stretch Database).

Stretch Database 向导的“结果”页Results page of the Stretch Database wizard

对向导进行故障排除Troubleshooting the wizard

Stretch Database 向导失败。The Stretch Database wizard failed.
如果尚未在服务器级别启用 Stretch Database,而你在没有系统管理员权限的情况下运行向导以启用它,则向导将失败。If Stretch Database is not yet enabled at the server level, and you run the wizard without the system administrator permissions to enable it, the wizard fails. 让系统管理员在本地服务器实例上启用 Stretch Database,然后再次运行该向导。Ask the system administrator to enable Stretch Database on the local server instance, and then run the wizard again. 有关详细信息,请参阅 Prerequisite: Permission to enable Stretch Database on the serverFor more info, see Prerequisite: Permission to enable Stretch Database on the server.

后续步骤Next steps

为 Stretch Database 启用其他表。Enable additional tables for Stretch Database. 监视数据迁移并管理已启用 Stretch 的数据库和表。Monitor data migration and manage Stretch-enabled databases and tables.

另请参阅See Also

为数据库启用 Stretch Database Enable Stretch Database for a database
为表启用 Stretch DatabaseEnable Stretch Database for a table