使用可用性组向导 (SQL Server Management Studio)Use the Availability Group Wizard (SQL Server Management Studio)

适用对象: yesSQL ServeryesAzure SQL 数据库noAzure SQL 数据仓库no并行数据仓库APPLIES TO: yesSQL Server noAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

本主题说明如何使用 SQL Server Management StudioSQL Server Management Studio 中的“新建可用性组向导”在 SQL Server 2017SQL Server 2017 中创建和配置 AlwaysOn 可用性组 。This topic describes how to use the New Availability Group Wizard in SQL Server Management StudioSQL Server Management Studio to create and configure an Always On availability group in SQL Server 2017SQL Server 2017. “可用性组” 定义一组用户数据库,这些用户数据库将以支持故障转移的单个单元和一组故障转移伙伴(称作“可用性副本” )的形式进行故障转移。An availability group defines a set of user databases that will fail over as a single unit and a set of failover partners, known as availability replicas, that support failover.

备注

有关可用性组的简介,请参阅 AlwaysOn 可用性组概述 (SQL Server)中通过 PowerShell 创建和配置 AlwaysOn 可用性组。For an introduction to availability groups, see Overview of Always On Availability Groups (SQL Server).

开始之前Before You Begin

我们强烈建议您首先阅读此部分,再尝试创建您的第一个可用性组。We strongly recommend that you read this section before attempting to create your first availability group.

先决条件、限制和建议Prerequisites, Restrictions, and Recommendations

在大多数情况下,可以使用新建可用性组向导来完成创建和配置可用性组所需的所有任务。In most cases, you can use the New Availability Group Wizard to complete all of the tasks require to create and configure an availability group. 但是,您可能需要手动完成一些任务。However, you might need to complete some of the tasks manually.

  • 如果计划使用 Windows Server 故障转移群集 (WSFC) 群集类型托管可用性组,请先验证托管可用性副本的 SQL ServerSQL Server 的实例是否驻留在同一 WSFC 内的不同群集服务器(或节点)上。If you are using a Windows Server Failover Cluster (WSFC) cluster type to host availability group, verify that the instances of SQL ServerSQL Server that host the availability replicas rside on different cluster servers (or nodes) within the same WSFC. 此外,还请验证每个服务器实例是否都满足所有其他 AlwaysOn 可用性组Always On availability groups 先决条件。Also, verify that each of the server instances meets all other AlwaysOn 可用性组Always On availability groups prerequisites. 有关详细信息,我们强烈建议你参阅 针对 AlwaysOn 可用性组的先决条件、限制和建议 (SQL Server)For more information, we strongly recommend that you read Prerequisites, Restrictions, and Recommendations for Always On Availability Groups (SQL Server).

  • 如果您选择承载可用性副本的服务器实例正在以域用户帐户运行并且尚不具有数据库镜像端点,则此向导可以创建该端点并将 CONNECT 权限授予服务器实例的服务帐户。If a server instance that you select to host an availability replica is running under a domain user account and does not yet have a database mirroring endpoint, the wizard can create the endpoint and grant CONNECT permission to the server instance service account. 但是,如果 SQL ServerSQL Server 服务正在以内置帐户(例如 Local System、Local Service 或 Network Service)或非域帐户运行,您必须使用证书来进行端点身份验证,并且该向导将无法在服务器实例上创建数据库镜像端点。However, if the SQL ServerSQL Server service is running as a built-in account, such as Local System, Local Service, or Network Service, or a nondomain account, you must use certificates for endpoint authentication, and the wizard will be unable to create a database mirroring endpoint on the server instance. 在此情况下,我们建议您首先手动创建数据库镜像端点,然后启动新建可用性组向导。In this case, we recommend that you create the database mirroring endpoints manually before you launch the New Availability Group Wizard.

    使用数据库镜像端点证书:To use certificates for a database mirroring endpoint:

    CREATE ENDPOINT (Transact-SQL)CREATE ENDPOINT (Transact-SQL)

    使用数据库镜像终结点证书 (Transact-SQL)Use Certificates for a Database Mirroring Endpoint (Transact-SQL)

  • SQL Server 故障转移群集实例 (FCI) 不支持通过可用性组来自动进行故障转移,因此,只能为手动故障转移配置任何由 FCI 承载的可用性副本。SQL Server Failover Cluster Instances (FCIs) do not support automatic failover by availability groups, so any availability replica that is hosted by an FCI can only be configured for manual failover.

  • 向导执行完全初始数据同步的先决条件Prerequisites for the wizard to perform full initial data synchronization

    • 在承载可用性组的副本的每个服务器实例上,所有数据库文件路径都必须完全相同。All the database-file paths must be identical on every server instance that hosts a replica for the availability group.

    • 没有任何主数据库名称可存在于承载辅助副本的任何服务器实例上。No primary database name can exist on any server instance that hosts a secondary replica. 这意味着尚没有任何新的辅助数据库可以存在。This means that none of the new secondary databases can exist yet.

    • 为了使该向导创建并访问备份,需要指定网络共享。You will need to specify a network share in order for the wizard to create and access backups. 对于主副本,用于启动 数据库引擎Database Engine 的帐户必须对网络共享具有读写文件系统权限。For the primary replica, the account used to start the 数据库引擎Database Engine must have read and write file-system permissions on a network share. 对于辅助副本,该帐户必须具有对网络共享区的读权限。For secondary replicas, the account must have read permission on the network share.

      重要

      日志备份将是您的日志备份链的一部分。The log backups will be part of your log backup chain. 适当地存储日志备份文件。Store the log backup files appropriately.

    如果您无法使用该向导执行完全初始数据同步,则需要手动准备您的辅助数据库。If you are unable to use the wizard to perform full initial data synchronization, you need to prepare your secondary databases manually. 您可以在运行该向导之前或之后进行准备。You can do this before or after running the wizard. 有关详细信息,请参阅 为可用性组手动准备辅助数据库 (SQL Server)中创建和配置 AlwaysOn 可用性组。For more information, see Manually Prepare a Secondary Database for an Availability Group (SQL Server).

SecuritySecurity

权限Permissions

需要 sysadmin 固定服务器角色的成员资格,以及 CREATE AVAILABILITY GROUP 服务器权限、ALTER ANY AVAILABILITY GROUP 权限或 CONTROL SERVER 权限。Requires membership in the sysadmin fixed server role and either CREATE AVAILABILITY GROUP server permission, ALTER ANY AVAILABILITY GROUP permission, or CONTROL SERVER permission.

如果要允许可用性组向导管理数据库镜像端点,还需要 CONTROL ON ENDPOINT 权限。Also requires CONTROL ON ENDPOINT permission if you want to allow Availability Group Wizard to manage the database mirroring endpoint.

使用新建可用性组向导Using the New Availability Group Wizard

  1. 在对象资源管理器中,连接到承载主副本的服务器实例。In Object Explorer, connect to the server instance that hosts the primary replica.

  2. 依次展开“Always On 高可用性” 节点和“可用性组” 节点。Expand the Always On High Availability node and the Availability Groups node.

  3. 若要启动新建可用性组向导,请选择 “新建可用性组向导” 命令。To launch the New Availability Group Wizard, select the New Availability Group Wizard command.

  4. 首次运行该向导时, “简介” 页将出现。The first time you run this wizard, an Introduction page appears. 若要在将来跳过此页,可单击 “不再显示此页”To bypass this page in the future, you can click Do not show this page again. 在阅读了此页后,单击 “下一步”After reading this page, click Next.

  5. 在“指定可用性组选项”页上的“可用性组名称”字段中,输入新可用性组的名称 。On the Specify Availability Group Options page, enter the name of the new availability group in the Availability group name field. 此名称必须是在群集和域中唯一有效的 SQL ServerSQL Server 标识符。This name must be a valid SQL ServerSQL Server identifier that is unique on the cluster and in your domain as a whole. 可用性组名称的最大长度为 128 个字符。The maximum length for an availability group name is 128 characters. ee

  6. 接下来,指定群集类型。Next, specify the cluster type. 可能的群集类型取决于 SQL ServerSQL Server 版本和操作系统。The possible cluster types depend on the SQL ServerSQL Server version and operating system. 选择“WSFC”、“EXTERNAL”或“NONE” 。Choose either WSFC, EXTERNAL, or NONE. 有关详细信息,请参阅“指定可用性组名称”页For details see Specify Availability Group Name Page

  7. “选择数据库” 页上,网格中列出所连接的服务器实例上有资格成为“可用性数据库” 的用户数据库。On the Select Databases page, the grid lists user databases on the connected server instance that are eligible to become the availability databases. 选择一个或多个列出的数据库以参与新的可用性组。Select one or more of the listed databases to participate in the new availability group. 这些数据库最初将成为初始“主数据库” 。These databases will initially be the initial primary databases.

    对于每个列出的数据库, “大小” 列显示数据库大小(如果已知)。For each listed database, the Size column displays the database size, if known. “状态” 列指示给定的数据库是否满足可用性数据库的先决条件The Status column indicates whether a given database meets the prerequisitesfor availability databases. 如果未满足这些先决条件,会有简短的状态说明指出该数据库不合格的原因;例如,可能是因为它不使用完整恢复模式。It the prerequisites are not met, a brief status description indicates the reason that the database is ineligible; for example, if it does not use the full recovery model. 有关详细信息,请单击该状态说明。For more information, click the status description.

    如果数据库经过更改已经合格,请单击 “刷新” 以更新数据库网格。If you change a database to make it eligible, click Refresh to update the databases grid.

    如果数据库包含数据库主密钥,则请在“密码”列中输入数据库主密钥的密码。 If the database contains a database master key, enter the password for the database master key in the Password column.

  8. “指定副本” 页上,为新的可用性组指定和配置一个或多个副本。On the Specify Replicas page, specify and configure one or more replicas for the new availability group. 此页包含四个选项卡。This page contains four tabs. 下表介绍了这些选项卡。The following table introduces these tabs. 有关详细信息,请参阅“指定副本”页(新建可用性组向导:添加副本向导)主题。For more information, see the Specify Replicas Page (New Availability Group Wizard: Add Replica Wizard) topic.

    选项卡Tab 简短说明Brief Description
    副本Replicas 使用此选项卡可以指定将承载辅助副本的每个 SQL ServerSQL Server 实例。Use this tab to specify each instance of SQL ServerSQL Server that will host a secondary replica. 请注意,您当前连接的服务器实例必须承载主副本。Note that the server instance to which you are currently connected must host the primary replica.
    端点Endpoints 使用此选项卡可以验证任何现有数据库镜像端点,此外,如果在其服务帐户使用 Windows 身份验证的服务器实例上缺少该端点,则会自动创建该端点。Use this tab to verify any existing database mirroring endpoints and also, if this endpoint is lacking on a server instance whose service accounts use Windows Authentication, to create the endpoint automatically.

    注意:如果任何服务器实例基于非域用户帐户运行,则你需要首先对你的服务器实例进行手动更改,然后才能在向导中继续执行。Note: If any server instance is running under a non-domain user account, you need to do make a manual change to your server instance before you can proceed in the wizard. 有关详细信息,请参阅本主题前面的 先决条件For more information, see Prerequisites, earlier in this topic.
    备份首选项Backup Preferences 使用此选项卡可以整体为可用性组指定您的备份首选项,并为各个可用性副本指定备份优先级。Use this tab to specify your backup preference for the availability group as a whole and your backup priorities for the individual availability replicas.
    侦听器Listener 使用此选项卡可以创建可用性组侦听器。Use this tab to create an availability group listener. 默认情况下,该向导不创建侦听器。By default, the wizard does not create a listener.
  9. “选择初始数据同步” 页上,选择如何创建新的辅助数据库并将其联接到可用性组。On the Select Initial Data Synchronization page, choose how you want your new secondary databases to be created and joined to the availability group. 选择下列选项之一:Choose one of the following options:

    • 自动种子设定Automatic seeding

      SQL Server 自动为此组中的每个数据库创建次要副本。SQL Server automatically creates the secondary replicas for every database in the group. 自动种子设定要求数据和日志文件路径在参与此组的每个 SQL Server 实例上均相同。Automatic seeding requires that the data and log file paths are the same on every SQL Server instance participating in the group. 可在 SQL Server 2016 (13.x)SQL Server 2016 (13.x) 及更高版本中使用。Available on SQL Server 2016 (13.x)SQL Server 2016 (13.x) and later. 请参阅自动初始化 AlwaysOn 可用性组See Automatically initialize Always On Availability group.

    • 完整的数据库和日志备份Full database and log backup

      如果你的环境满足自动启动初始数据同步的要求,则选择此选项(有关详细信息,请参阅本主题前面的 先决条件、限制和建议)。Select this option if your environment meets the requirements for automatically starting initial data synchronization (for more information, see Prerequisites, Restrictions, and Recommendations, earlier in this topic).

      如果选择 “完全” ,则在创建可用性组后,向导会将每个主数据库及其事务日志备份到网络共享,并在每个承载辅助副本的服务器实例上还原备份。If you select Full, after creating the availability group, the wizard will back up every primary database and its transaction log to a network share and restore the backups on every server instance that hosts an secondary replica. 然后,该向导将每个辅助数据库联接到可用性组。The wizard will then join every secondary database to the availability group.

      在“指定可由所有副本访问的共享网络位置” 字段中,指定承载副本的所有服务器都具有读写访问权限的备份共享。In the Specify a shared network location accessible by all replicas: field, specify a backup share to which all of the server instance that host replicas have read-write access. 有关详细信息,请参阅本主题前面的 先决条件For more information, see Prerequisites, earlier in this topic. 在验证步骤中,向导将执行测试,确保所提供的网络位置有效,测试将在名为“BackupLocDb_”加 Guid 的主要副本上创建数据库,并对所提供的网络位置执行备份,然后在次要副本上进行还原。In the validation step, the wizard will perform a test to make sure the provided network location is valid, the test will create a database on the primary replica named "BackupLocDb_" followed by a Guid and perform backup to the provided network location, then restore it on the secondary replicas. 在向导未能删除此数据库及其备份历史记录和备份文件情况下,将之删除是安全的操作。It is safe to delete this database along with its backup history and backup file in case the wizard failed to delete them.

    • 仅联接Join only

      如果在将承载辅助副本的服务器实例上手动准备了辅助数据库,则可以选择此选项。If you have manually prepared secondary databases on the server instances that will host the secondary replicas, you can select this option. 该向导将每个现有辅助数据库联接到可用性组。The wizard will join the existing secondary databases to the availability group.

    • 跳过初始数据同步Skip initial data synchronization

      如果要使用您自己的数据库和主数据库的日志备份,请选择此选项。Select this option if you want to use your own database and log backups of your primary databases. 有关详细信息,请参阅本主题后面的 启动 AlwaysOn 辅助数据库的数据移动 (SQL Server)For more information, see Start Data Movement on an Always On Secondary Database (SQL Server).

  10. “验证” 页验证在此向导中指定的值是否满足新建可用性组向导的要求。The Validation page verifies whether the values you specified in this Wizard meet the requirements of the New Availability Group Wizard. 若要进行更改,请单击 “上一页” 以返回前面的向导页,更改一个或多个值。To make a change, click Previous to return to an earlier wizard page to change one or more values. 单击 “下一步” 返回到 “验证” 页,然后单击 “重新运行验证”The click Next to return to the Validation page, and click Re-run Validation.

  11. “摘要” 页上,查看您为新的可用性组进行的选择。On the Summary page, review your choices for the new availability group. 若要进行更改,请单击 “上一步” 以返回到相应页。To make a change, click Previous to return to the relevant page. 在进行更改后,单击 “下一步” 以返回到 “摘要” 页。After making the change, click Next to return to the Summary page.

    重要

    如果将要承载新的可用性副本的服务器实例的 SQL ServerSQL Server 服务帐户未作为登录名存在,则新建可用性组向导需要创建一个登录名。When the SQL ServerSQL Server service account of a server instance that will host a new availability replica does not already exist as a login, the New Availability Group Wizard needs to create the login. “摘要” 页上,该向导将显示要创建的登录名的信息。On the Summary page, the wizard displays the information for the login that is to be created. 如果单击 “完成” ,则该向导将为 SQL Server 服务帐户创建该登录名,并授予该登录名 CONNECT 权限。If you click Finish, the wizard creates this login for the SQL Server service account and grants the login CONNECT permission.

    如果您满意所做的选择,可以选择单击 “脚本” 以创建向导将执行的步骤的脚本。If you are satisfied with your selections, optionally click Script to create a script of the steps the wizard will execute. 然后,若要创建和配置新的可用性组,请单击 “完成”Then, to create and configure the new availability group, click Finish.

  12. “进度” 页将显示创建可用性组的各步骤(配置端点、创建可用性组和将辅助副本联接到该组)的进度。The Progress page displays the progress of the steps for creating the availability group (configuring endpoints, creating the availability group, and joining the secondary replica to the group).

  13. 在这些步骤完成后, “结果” 页将显示各步骤的结果。When these steps complete, the Results page displays the result of each step. 如果所有这些步骤都成功,则新的可用性组得到了完全配置。If all these steps succeed, the new availability group is completely configured. 如果任何步骤导致错误,您可能需要手动完成配置或对失败的步骤使用向导。If any of the steps result in an error, you might need to manually complete the configuration or use a wizard for the failed step. 有关给定错误的原因的信息,请单击 “结果” 列中关联的“错误”链接。For information about the cause of a given error, click the associated "Error" link in the Result column.

    完成向导后,单击 “关闭” 以退出安装向导。When the wizard completes, click Close to exit.

相关任务Related Tasks

完成可用性组配置To complete availability group configuration

用于创建可用性组的其他方法Alternative ways to create an availability group

启用 AlwaysOn 可用性组To enable Always On Availability Groups

配置数据库镜像端点To configure a database mirroring endpoint

解决 AlwaysOn 可用性组配置问题To troubleshoot Always On Availability Groups configuration

相关内容Related Content

用于创建可用性组的其他方法Alternate ways to create availability groups

除了使用新建可用性组向导之外,您还可以使用 Transact-SQLTransact-SQLSQL ServerSQL Server PowerShell cmdlet。As an alternative to using the New Availability Group Wizard, you can use Transact-SQLTransact-SQL or SQL ServerSQL Server PowerShell cmdlets. 有关详细信息,请参阅 创建可用性组 (Transact-SQL)创建可用性组 (SQL Server PowerShell)中创建和配置 AlwaysOn 可用性组。For more information, see Create an Availability Group (Transact-SQL) or Create an Availability Group (SQL Server PowerShell).

另请参阅See Also

数据库镜像终结点 (SQL Server) The Database Mirroring Endpoint (SQL Server)
AlwaysOn 可用性组概述 (SQL Server) Overview of Always On Availability Groups (SQL Server)
针对 AlwaysOn 可用性组的先决条件、限制和建议 (SQL Server)Prerequisites, Restrictions, and Recommendations for Always On Availability Groups (SQL Server)