为 Configuration Manager 配置 SQL Server Always On 可用性组Configure a SQL Server Always On availability group for Configuration Manager

适用范围: Configuration Manager (Current Branch)Applies to: Configuration Manager (current branch)

使用本文中的信息配置和管理用于 Configuration Manager 站点数据库的 SQL Server Always On 可用性组。Use the information in this article to configure and manage a SQL Server Always On availability group for the Configuration Manager site database. 在开始之前,请先熟悉准备使用可用性组的信息。Before you start, be familiar with the information to Prepare to use an availability group. 此外,熟悉包括使用可用性组和相关过程的 SQL Server 文档。Also be familiar with SQL Server documentation that covers the use of availability groups and related procedures.

创建和配置可用性组Create and configure an availability group

使用此过程为 Configuration Manager 创建可用性组。Use this procedure to create an availability group for Configuration Manager. 然后,将站点数据库的副本移到该可用性组。Then move a copy of the site database to that availability group.

  1. 使用以下命令可停止 Configuration Manager 站点:Use the following command to stop the Configuration Manager site:

    preinst.exe /stopsite

    有关详细信息,请参阅层次结构维护工具For more information, see Hierarchy maintenance tool.

  2. 将站点数据库的备份模型从“简单”**** 更改为“完整”****:Change the backup model for the site database from SIMPLE to FULL:

    ALTER DATABASE [CM_xxx] SET RECOVERY FULL;
    

    可用性组仅支持“完整”备份模型。Availability groups only support the FULL backup model. 有关详细信息,请参阅查看或更改数据库的恢复模式For more information, see View or change the recovery model of a database.

  3. 使用 SQL Server 创建站点数据库的完整备份。Use SQL Server to create a full backup of your site database. 选择以下选项之一:Choose one of the following options:

    • 将成为可用性组的成员:如果将此服务器用作可用性组的初始主要副本成员,则不需要将站点数据库副本还原到这个或组中的另一个服务器。Will be member of your availability group: If you use this server as the initial primary replica member of the availability group, you don't need to restore a copy of the site database to this server or another in the group. 数据库已在主要副本上就位。The database is already in place on the primary replica. SQL Server 在下一步中将数据库复制到次要副本。SQL Server replicates the database to the secondary replicas during a later step.

    • 不是可用性组的成员:将站点数据库的副本还原到将托管组的主要副本的服务器。Will not be a member of the availability group: Restore a copy of the site database to the server that will host the primary replica of the group.

    有关详细信息,请参阅 SQL Server 文档中的以下文章:For more information, see the following articles in the SQL Server documentation:

    备注

    如果计划从可用性组移动到现有副本上的独立组,请先从可用性组中删除数据库。If you plan to move from an availability group to standalone on an existing replica, first remove the database from the availability group.

  4. 在将托管组的初始主要副本的服务器上,使用新建可用性组向导创建可用性组。On the server that will host the initial primary replica of the group, use the New availability group wizard to create the availability group. 在向导中:In the wizard:

    • 在“选择数据库”**** 页上,为你的 Configuration Manager 站点选择数据库。On the Select Database page, select the database for your Configuration Manager site.

    • 在“添加副本”**** 页面,配置以下内容:On the Specify Replicas page, configure:

      • 副本: 指定将托管次要副本的服务器。Replicas: Specify the servers that will host secondary replicas.

      • 侦听程序: 将“侦听程序 DNS 名称”指定为完整的 DNS 名称,例如 <listener_server>.fabrikam.comListener: Specify the Listener DNS Name as a full DNS name, for example <listener_server>.fabrikam.com. 将 Configuration Manager 配置为使用可用性组中的数据库时,将使用此名称。When you configure Configuration Manager to use the database in the availability group, it uses this name.

    • 在“选择初始数据同步”**** 页面,选择“完整”****。On the Select Initial Data Synchronization page, select Full. 该向导创建可用性组后,向导将备份主数据库和事务日志。After the wizard creates the availability group, the wizard backs up the primary database and transaction log. 然后在托管次要副本的每个服务器上还原它们。Then the wizard restores them on each server that hosts a secondary replica.

      备注

      如果不使用此步骤,请将站点数据库的副本还原到将托管次要副本的每个服务器。If you don't use this step, restore a copy of the site database to each server that hosts a secondary replica. 然后将该数据库手动加入组。Then manually join that database to the group.

  5. 检查每个副本上的配置:Check the configuration on each replica:

    1. 确保站点服务器的计算机帐户是每个可用性组成员计算机上的本地管理员**** 组的成员。Make sure the computer account of the site server is a member of the local Administrators group on each computer that's a member of the availability group.

    2. 运行验证脚本,以确认正确配置了每个副本上的站点数据库。Run the verification script to confirm that the site database on each replica is correctly configured.

    3. 如果有必要在次要副本上设置配置,则先将主要副本手动故障转移到次要副本,然后再继续。If it's necessary to set configurations on secondary replicas, before you continue, manually fail over the primary replica to the secondary replica. 只能配置主要副本的数据库。You can only configure the database of a primary replica. 有关详细信息,请参阅 SQL Server 文档中的执行可用性组的计划手动故障转移For more information, see Perform a planned manual failover of an availability group in the SQL Server documentation.

  6. 所有副本都满足要求后,可用性组即可与 Configuration Manager 一起使用。After all replicas meet the requirements, the availability group is ready to be used with Configuration Manager.

配置站点以使用可用性组Configure a site to use the availability group

安装新站点时,在创建并配置可用性组后,指示安装程序使用可用性组侦听器的 FQDN。When installing a new site, after you have created and configured the availability group, direct setup to use the FQDN of the availability group listener. 如果使用的是自定义端口和命名实例,请在安装向导中将实例名称留空,并使用“侦听器的 FQDN,端口号”格式。If you used a custom port and named instance, leave the instance name empty in the setup wizard and use the format FQDN of listener, port number. 例如,对于不使用默认端口 1433 的命名实例,请使用 listener.contoso.com, 1445For example, use listener.contoso.com, 1445 for a named instance that doesn't use the default port of 1433.

如果已将现有站点数据库移到你创建并配置的可用性组,请按照以下说明使用 Configuration Manager 站点维护更改配置:If you moved an existing site database to an availability group you created and configured, use Configuration Manager site maintenance to change the configuration with the below instructions:

  1. 从 Configuration Manager 站点安装文件夹 \BIN\X64\setup.exe 运行 Configuration Manager 安装程序。Run Configuration Manager Setup: \BIN\X64\setup.exe from the Configuration Manager site installation folder.

  2. 在“入门”**** 页上,选择“执行站点维护或重置此站点”****,然后选择“下一步”****。On the Getting Started page, select Perform site maintenance or reset this site, and then select Next.

  3. 选择“修改 SQL Server 配置”****,然后选择“下一步”****。Select Modify SQL Server configuration, and then select Next.

  4. 为站点数据库重新配置以下设置:Reconfigure the following settings for the site database:

    • SQL Server 名称:输入可用性组侦听程序的虚拟名称。SQL Server name: Enter the virtual name for the availability group listener. 在创建可用性组时配置了侦听程序。You configured the listener when you created the availability group. 虚拟名称应为完整的 DNS 名称,如 <Listener_Server>.fabrikam.comThe virtual name should be a full DNS name, like <Listener_Server>.fabrikam.com.

    • 实例: 若要为可用性组的侦听程序指定默认实例,此值必须为空。Instance: To specify the default instance for the listener of the availability group, this value must be blank. 如果当前站点数据库在命名实例上运行,则会清除当前命名实例。If the current site database runs on a named instance, clear the current named instance.

    • 数据库: 保留所显示的名称。Database: Leave the name as it appears. 这是当前站点数据库的名称。This name is the current site database.

  5. 为新的数据库位置提供此信息后,使用常规过程和配置完成安装。After you provide the information for the new database location, complete setup with your normal process and configurations.

同步副本成员Synchronous replica members

当站点数据库在可用性组中托管时,请使用以下过程添加或删除同步的副本成员。When your site database is hosted in an availability group, use the following procedures to add or remove synchronous replica members. 有关支持的类型和副本数的详细信息,请参阅可用性组配置For more information about the supported type and number of replicas, see Availability group configurations.

添加或删除同步副本成员Add or remove a synchronous replica member

运行 Configuration Manager 安装程序以添加或删除同步副本成员。Run Configuration Manager setup to add or remove a synchronous replica member. 以下步骤演示如何添加:The following steps show how to add:

  1. 使用 SQL Server 过程添加次要副本。Add a secondary replica using the SQL Server procedures.

    1. 将次要副本添加到 Always On 可用性组Add a secondary replica to an Always On availability group.

    2. 在 SQL Server Management Studio 中监视状态。Watch the status in SQL Server Management Studio. 等待可用性组完全恢复正常运行。Wait for the availability group to return to full health.

  2. 运行 Configuration Manager 安装程序,然后选择修改站点的选项。Run Configuration Manager setup, and select the option to modify the site.

  3. 将可用性组侦听程序名称指定为数据库名称。Specify the availability group listener name as the database name. 如果侦听程序使用非标准网络端口,也请指定该端口。If the listener uses a non-standard network port, specify that as well. 此操作会使安装程序确保每个节点都已正确配置。This action causes setup to make sure each node is appropriately configured. 它还会启动数据库恢复过程。It also starts a database recovery process.

Configuration Manager 安装程序使用 SQL Server 数据库移动操作,并确保节点已正确配置。Configuration Manager setup uses the SQL Server database move operation, and makes sure the nodes are correctly configured.

异步副本Asynchronous replicas

可以使用与 Configuration Manager 配合使用的可用性组中的异步副本。You can use an asynchronous replica in the availability group that you use with Configuration Manager. 无需运行配置同步副本所需的配置脚本,因为站点数据库不支持异步副本。You don't need to run the configuration scripts required to configure a synchronous replica, because an asynchronous replica isn't supported for the site database.

配置异步提交副本Configure an asynchronous commit replica

有关详细信息,请参阅将次要副本添加到可用性组For more information, see Add a secondary replica to an availability group.

使用异步副本恢复站点Use the asynchronous replica to recover your site

使用异步副本恢复站点数据库。Use the asynchronous replica to recover your site database.

  1. 停止活动的主站点,以防止对站点数据库的额外写入。Stop the active primary site to prevent additional writes to the site database. 要停止站点,请使用层次结构维护工具preinst.exe /stopsiteTo stop the site, use the Hierarchy maintenance tool: preinst.exe /stopsite

  2. 停止站点后,使用异步副本替代手动恢复的数据库After you stop the site, use the asynchronous replica instead of a manually recovered database.

停止使用可用性组Stop using an availability group

不再需要在可用性组中托管站点数据库时,请使用以下过程。Use the following procedure when you no longer want to host your site database in an availability group. 通过此过程,你会将站点数据库移回 SQL Server 的单个实例。With this process, you'll move the site database back to a single instance of SQL Server.

  1. 使用以下命令停止 Configuration Manager 站点:preinst.exe /stopsiteStop the Configuration Manager site by using the following command: preinst.exe /stopsite. 有关详细信息,请参阅层次结构维护工具For more information, see Hierarchy maintenance tool.

  2. 使用 SQL Server 创建主要副本中站点数据库的完整备份。Use SQL Server to create a full backup of your site database from the primary replica. 有关详细信息,请参阅创建完整数据库备份For more information, see Create a full database backup.

  3. 使用 SQL Server 将站点数据库备份还原到将托管站点数据库的服务器。Use SQL Server to restore the site database backup to the server that will host the site database. 有关详细信息,请参阅使用 SSMS 还原数据库备份For more information, see Restore a database backup using SSMS.

    备注

    如果可用性组的主要副本服务器将托管站点数据库的单个实例,则跳过此步骤。If the primary replica server for the availability group will host the single instance of the site database, skip this step.

  4. 在将托管站点数据库的服务器上,将站点数据库备份模型从“完整”**** 更改为“简单”****。On the server that will host the site database, change the backup model for the site database from FULL to SIMPLE. 有关详细信息,请参阅查看或更改数据库的恢复模式For more information, see View or change the recovery model of a database.

  5. 从 Configuration Manager 站点安装文件夹 \BIN\X64\setup.exe 运行 Configuration Manager 安装程序。Run Configuration Manager Setup: \BIN\X64\setup.exe from the Configuration Manager site installation folder.

  6. 在“入门”**** 页上,选择“执行站点维护或重置此站点”****,然后选择“下一步”****。On the Getting Started page, select Perform site maintenance or reset this site, and then select Next.

  7. 选择“修改 SQL Server 配置”****,然后选择“下一步”****。Select Modify SQL Server configuration, and then select Next.

  8. 为站点数据库重新配置以下设置:Reconfigure the following settings for the site database:

    • SQL Server 名称: 输入现在托管站点数据库的服务器的名称。SQL Server name: Enter the name of the server that now hosts the site database.

    • 实例: 指定托管站点数据库的命名实例。Instance: Specify the named instance that hosts the site database. 如果数据库位于默认实例上,则将此字段留空。If the database is on the default instance, leave this field blank.

    • 数据库: 保留所显示的名称。Database: Leave the name as it appears. 这是当前站点数据库的名称。This name is the current site database.

  9. 为新的数据库位置提供此信息后,使用常规过程和配置完成安装。After you provide the information for the new database location, complete setup with your normal process and configurations. 安装完成后,站点将重启并开始使用新的数据库位置。When setup completes, the site restarts, and begins to use the new database location.

  10. 若要清理原为可用性组成员的服务器,请按照删除可用性组中的指导进行操作。To clean up the servers that were members of the availability group, follow the guidance in Remove an availability group.