在 SharePoint Server 中管理索引组件

适用于:yes-img-132013 yes-img-162016 yes-img-192019 yes-img-seSubscription Edition no-img-sopSharePoint in Microsoft 365

参考本文中的过程和示例的前提是,已安装 SharePoint Server 和 Search Service 应用程序且存在现有搜索拓扑,同时 SharePoint Server 搜索索引中包含项目。 如果 SharePoint Server 和 Search Service 应用程序是新安装的,且 SharePoint Server 搜索索引是空的,请按在 SharePoint Server 中更改默认搜索拓扑中概述的过程执行操作,从而扩展搜索拓扑。

本文中的过程适用于索引组件。 有关如何管理分析处理组件、内容处理组件、爬网组件、搜索管理组件和查询处理组件的信息,请参阅在 SharePoint Server 中管理搜索组件

可使用索引组件 PowerShell cmdlet (New-SPEnterpriseSearchIndexComponent) 管理索引分区和索引副本。 搜索拓扑中的每个索引组件均表示一个索引副本。

可将搜索索引分为多个离散分区(称为" 索引分区 ")。 每个索引分区均以文件集的形式存储在本地磁盘上。 若要 扩展 搜索索引,请添加一个新的索引分区。

若要实现 SharePoint Server 搜索索引的 容错 功能,可将现有索引分区的索引副本添加到搜索拓扑。 每个索引副本都包含相同的信息。

开始之前

开始操作之前,请查看以下先决条件。

  • 已安装 SharePoint Server,并且已创建具有搜索拓扑的 Search Service 应用程序。

  • 执行本文中的过程的用户帐户是 Farm Administrators 组的成员。

  • 你已规划目标搜索拓扑,并已计划要在其上托管索引分区和索引副本的服务器。

  • SharePoint Server 已安装到要承载索引组件的所有服务器上。 您可在现有部署中创建新的应用程序服务器或定义应用程序服务器。 已将这些服务器添加到服务器场,并且您是所有这些服务器的管理员。

将索引副本添加到现有索引分区

您将索引副本添加到搜索拓扑以便实现现有索引分区的容错功能。 您将索引副本置于单独的服务器上的单独的故障域中。 在添加索引副本时,您将新的索引组件添加到搜索拓扑中并将该组件与要为其创建副本的索引分区关联。

重要

[!重要说明] 此过程使用 Microsoft PowerShell。 您可在服务器场中的任何服务器上运行 Microsoft PowerShell 命令。 但是,您应对此过程中的所有 Microsoft PowerShell 命令使用同一 SharePoint 命令行管理程序,以便在各个命令之间共享 Microsoft PowerShell 对象引用。

添加索引副本

  1. 确认执行此过程的用户帐户是 服务器场管理员 组的成员。

  2. 在场中的一个服务器上启动 SharePoint 命令行管理程序。

  3. 在要在其上创建索引副本的服务器上启动搜索服务实例并创建对搜索服务实例 ID 的引用。在 Microsoft PowerShell 命令提示符处,键入以下命令:

    $<host n > = Get-SPEnterpriseSearchServiceInstance -Identity "<Server name>"
    Start-SPEnterpriseSearchServiceInstance -Identity $<host n >
    

    其中:

    • $<host n> 指定搜索服务实例的 PowerShell 对象引用。

    • <服务器名称> 指定想要对其添加索引组件的服务器。 输入必须是有效的 GUID,格式 12345678-90ab-cdef-1234-567890bcdefgh为 ;服务器的有效名称 (例如 myserver1 ) ;或有效 SearchServiceInstance 对象的实例。

    例如:

    $hostA = Get-SPEnterpriseSearchServiceInstance -Identity "myserver1"
    Start-SPEnterpriseSearchServiceInstance -Identity $hostA
    
  4. Wait until the search service instance is running. At the Microsoft PowerShell command prompt, type the following command until the command returns the status Online:

    Get-SPEnterpriseSearchServiceInstance -Identity $<host n >
    
  5. 克隆活动搜索拓扑。 在 Microsoft PowerShell 命令提示符处,键入以下命令:

    $ssa = Get-SPEnterpriseSearchServiceApplication
    $active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
    $clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone -SearchTopology $active
    
  6. 添加一个新的索引组件并将该组件与一个分区关联。 在 Windows PowerShell 命令提示符处,键入以下命令:

    New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance <host n > -IndexPartition <Index partition number>
    

    其中:

    • $clone 是要更改的克隆拓扑。

    • $<host n> 是对要向其添加索引副本的服务器上正在运行的搜索服务实例的 PowerShell 对象引用。

    • <Index partition number> 是要为其创建副本的现有索引分区的编号。 例如,若要创建索引分区 0 的索引副本,请选择"0"作为参数值。

    例如:

    New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance $hostA -IndexPartition 0
    
  7. 激活克隆拓扑。 在 Microsoft PowerShell 命令提示符处,键入以下命令:

    Set-SPEnterpriseSearchTopology -Identity $clone
    
  8. 确认您的新拓扑处于活动状态且已添加表示新索引副本的索引组件。 在 Microsoft PowerShell 命令提示符处,键入以下命令:

    Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa
    
  9. Monitor the distribution of the existing index to the new replica. The added index replica will have the state Degraded until the distribution is finished. At the Microsoft PowerShell command prompt, type the following command(s):

    Get-SPEnterpriseSearchStatus -SearchApplication $ssa -Text
    

    Repeat this command until all search components, including the new index component, output the state Active. 对于大型搜索索引,这可能需要花费几个小时的时间。

添加新索引分区

在添加新索引分区时,必须对搜索索引重新分区。 此重新分区可能需要几个小时的时间才能完成,具体取决于搜索索引的大小。

若要添加索引分区并对搜索索引重新分区,可将新索引组件添加到搜索拓扑,然后将此索引组件与新索引分区编号关联。 添加索引分区并对搜索索引重新分区应作为一个单独的过程启动,而不应在对索引拓扑进行其他更改时启动。

您必须向新索引分区添加与现有分区中的索引副本数相同的索引副本。

在将新索引分区添加到搜索拓扑并开始对搜索索引重新分区之前,请执行以下操作:

  • 备份 Search Service 应用程序和现有搜索索引。 请参阅在 SharePoint Server 中备份 Search Service 应用程序

  • 确保当前活动拓扑运行正常。 在管理中心的“搜索管理”页中查看搜索拓扑的状态,或运行 Microsoft PowerShell cmdlet Get-SPEnterpriseSearchStatus

  • 确保要添加索引分区的服务器上有足够多的可用磁盘空间。

警告

[!重要说明] Search Service 应用程序在索引重新分区期间将暂停且无法对内容进行爬网或建立索引。 此外,用户将无法运行查询。

添加索引分区

  1. 确认执行此过程的用户帐户是 服务器场管理员 组的成员。

  2. 在场中的一个服务器上启动 SharePoint 命令行管理程序。

  3. 在要在其上添加新索引分区的索引副本的所有服务器上启动搜索服务实例。 创建对要在此过程的后续步骤中使用的搜索服务实例的 PowerShell 对象引用。 对于每台服务器,在 Microsoft PowerShell 命令提示符处,键入以下命令:

    $<host n > = Get-SPEnterpriseSearchServiceInstance -Identity "<Server name>"
    Start-SPEnterpriseSearchServiceInstance -Identity $<host n >
    

    其中:

    • <host n> 指定搜索服务实例的 PowerShell 对象引用。

    • <服务器名称> 指定想要对其添加索引组件的服务器。 输入必须是有效的 GUID,格式 12345678-90ab-cdef-1234-567890bcdefgh为 ;服务器的有效名称 (例如 myserver1 ) ;或有效 SearchServiceInstance 对象的实例。

    例如:

    $hostC = Get-SPEnterpriseSearchServiceInstance -Identity "myserver3"
    Start-SPEnterpriseSearchServiceInstance -Identity $hostC
    $hostD = Get-SPEnterpriseSearchServiceInstance -Identity "myserver4"
    Start-SPEnterpriseSearchServiceInstance -Identity $hostD
    
  4. Wait until the search service instances are running. For each server, at the Microsoft PowerShell command prompt, type the following command until the command returns the status Online:

    Get-SPEnterpriseSearchServiceInstance -Identity $<host n >
    
  5. 克隆活动搜索拓扑。 在 Microsoft PowerShell 命令提示符处,键入以下命令:

    $ssa = Get-SPEnterpriseSearchServiceApplication
    $active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
    $clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone -SearchTopology $active
    

    命令会创建一个克隆搜索拓扑,该拓扑可使用 $clone 引用,并返回有关克隆拓扑的信息。 记下克隆的拓扑的拓扑 ID,以应对必须取消重新分区过程的情况。

  6. 通过添加一个或多个索引组件来添加新索引分区,然后将这些组件与新索引分区关联。 建议您为新索引分区创建与现有分区的索引副本数相同的索引副本。 对于每个新的索引组件,在 Windows PowerShell 命令提示符处,键入以下命令:

    New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance <host n > -IndexPartition <Index partition number>
    

    其中:

    • $clone 是要更改的克隆拓扑。

    • $<host n> 指定搜索服务实例的 PowerShell 对象引用。

    • <Index partition number> 是要创建的索引分区的编号。 默认情况下,您有一个索引分区,该分区称为索引分区 0。 如果您需要创建新的索引分区,请输入 IndexPartition 参数值"1",紧接着输入"2",再输入"3",依此类推。

    例如,如果您 Host A 和 Host B 上有一个具有索引副本的现有索引分区 0,您希望在 Host C 和 Host D 上添加一个具有索引副本的新索引分区:

    New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance $hostC -IndexPartition 1
    New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance $hostD -IndexPartition 1
    
  7. 验证 Search Service 应用程序是否正在运行。 在 Microsoft PowerShell 命令提示符处,键入以下命令:

    $ssa.IsPaused() -ne 0
    
    • 如果命令返回 False ,则 Search Service 应用程序正在运行。 继续执行步骤 9。

    • 如果此命令返回 True ,则说明 Search Service 应用程序已暂停。 继续执行步骤 8。

  8. 如果 Search Service 应用程序已暂停,请查明原因以及是否必须等待任何操作完成才能继续执行步骤 9。 有关详细信息,请参阅在 SharePoint Server 中管理暂停的 Search Service 应用程序

  9. 开始激活克隆拓扑。 这将开始激活包含与新索引分区关联的新索引副本的拓扑。 这将开始索引重新分区过程。

    重要

    [!重要说明] Search Service 应用程序在索引重新分区期间将暂停且无法对内容进行爬网或建立索引。 此外,用户将无法运行查询。 您将无法访问在其上运行激活命令的 Windows PowerShell 控制台。

    注意

    [!注意] 管理中心内的"搜索管理"页不会显示为进行索引重新分区而暂停的 Search Service 应用程序。 但是,由于在您为重新分区而暂停 Search Service 应用程序时所有查询处理组件都被挂起,因此,"搜索管理"页将在此过程中显示查询处理组件的错误。

    在 Windows PowerShell 命令提示符处,键入以下命令:

    $ssa.PauseForIndexRepartitioning()
    Set-SPEnterpriseSearchTopology -Identity $clone
    
  10. 监视索引重新分区过程的进度。 您只能监视针对现有拓扑的主索引组件的索引分区过程的进度。 以下步骤说明如何查找主索引组件。

    注意

    [!注意] 在拓扑激活(包括索引重新分区过程)完成之前,您无法在现有 SharePoint 命令行管理程序 中运行任何命令。 请在另一个 SharePoint 命令行管理程序 中运行以下命令。

    • 启动第二个 SharePoint 命令行管理程序。

    • 查找每个现有索引分区的主索引副本。 在第二个 SharePoint 命令行管理程序 的 Windows PowerShell 命令提示符处,键入以下命令:

    $ssa = Get-SPEnterpriseSearchServiceApplication
    Get-SPEnterpriseSearchStatus -SearchApplication $ssa -Text
    

    该命令返回索引组件及其属性的列表。 记下主索引组件的名称。 这些是具有属性 Primary: True 的索引组件。

    例如,输出可能类似于以下内容。 在此示例中,IndexComponent2 是主索引组件:

    Name      : IndexComponent1
    State     : Active
    Primary   : False
    Partition : 0
    Host      : MyMachine1
    Name      : Cell:IndexComponent1-SPd32cdffb08a2I.0.0
    State     : Active
    Primary   : False
    Partition : 0
    Name      : IndexComponent2
    State     : Active
    Primary   : True
    Partition : 0
    Host      : MyMachine2
    Name      : Cell:IndexComponent2-SPd32cdffb08a2I.1.0
    State     : Active
    Primary   : True
    Partition : 0
    
  11. 对于每个主索引组件,监视索引重新分区进度。 在第二个 SharePoint 命令行管理程序 的 Windows PowerShell 命令提示符处,键入以下命令:

    Get-SPEnterpriseSearchStatus -SearchApplication $ssa -Healthreport -Component <Index component name> | ? { ($_.name -match "repart") -or ( $_.name -match "splitting") } | ft -AutoSize Name, Message
    

    其中:

    • <Index component name> 是要监视其进度的主索引组件的名称,例如 IndexComponent2

    监视每个主索引组件的命令的输出。 命令的输出包含有关索引重新分区的进度信息。

    在索引重新分区过程的初始阶段,输出将类似于以下内容:

    Name                                              Message
    ----                                              -------
    repartition_component_state[SP...]                Pending
    

    索引分区在索引重新分区过程的主要阶段将被拆分。 在此阶段,输出将类似于以下内容:

    Name                                              Message
    ----                                              -------
    index splitting: current fusion progress[SP...]   <Percentage value>
    index splitting: splitting state [SP...]          Index splitter running fusion, building: <Folder>
    repartition_component_state [SP...]               Splitting
    

    输出中的百分比值表示重新分区过程的大致进度。

    对所有主索引组件重复此命令,直到命令的输出不再返回任何值。 这意味着索引重新分区过程已完成,并且重新分区的索引现在将复制并通过服务器进行分发。 这可能需要花费几个小时的时间。

  12. 监控将索引分发给新索引副本的过程的进度。 为此,请确认您的新拓扑处于活动状态且所有搜索组件正常运行。 在第二个 SharePoint 命令行管理程序 的 Windows PowerShell 命令提示符处,键入以下命令:

    Get-SPEnterpriseSearchStatus -SearchApplication $ssa | ft -AutoSize Name, State, Details
    

    During the distribution of the index to the new index replicas, the added index replicas will return the state Degraded. The distribution is finished when all index components return the state Active in the output. This could take several hours.

    注意

    The query processing components are suspended because you have paused the Search service application for index repartitioning. In the output, the query processing components will be listed with the state Unknown.

  13. 在用于启动拓扑激活过程的 SharePoint 命令行管理程序中,验证搜索拓扑激活命令是否已完成。

  14. (可选)在重新分区之前,在托管索引组件(表示主索引副本或任何其他索引副本)的所有服务器上重新启动 SharePoint 搜索主机控制器服务。

    执行此步骤可在对搜索索引重新分区后获得正确的文档计数并释放内存。 如果您决定不执行此步骤,将经过几天时间和一些索引迭代后,才能使内存使用量逐渐减少并使文档计数(按照由 PowerShell cmdlet 和在"管理中心"中的"搜索管理"页面中返回的数量)正确。

    注意

    为避免查询中断,请确保在重新启动 SharePoint 搜索主机控制器服务前至少有一个索引组件为每个索引分区返回状态"正在运行"。

    重要

    请不要使用 SharePoint Server 管理中心网站上的"服务器上的服务"页来重启此服务。

    • 若要重新启动 SharePoint 搜索主机控制器,请在承载现有索引分区的索引组件的每台服务器上打开命令提示符窗口。

    • 若要停止 SharePoint 搜索主机控制器,请键入以下命令: net stop spsearchhostcontroller

    • 若要重新启动 SharePoint 搜索主机控制器,请键入以下命令: net start spsearchhostcontroller

  15. 恢复 Search Service 应用程序。 在 Windows PowerShell 命令提示符处,键入以下命令:

    $ssa.ResumeAfterIndexRepartitioning()
    

取消重新分区过程

如果你必须取消正在进行的重新分区过程,请使用以下过程。

取消重新分区过程

  1. 在运行拓扑激活命令的服务器上启动新的 SharePoint 命令行管理程序。

  2. 检索激活拓扑 ID。在 Windows PowerShell 命令提示符处,键入以下命令:

    $activating = Get-SPEnterpriseSearchTopology -Identity <Id of the activating topology> -SearchApplication $ssa
    

    其中:

    • <Id of the activating topology> 是您在克隆搜索拓扑时记下的克隆拓扑的标识 (GUID)。
  3. 取消拓扑激活。 在 Windows PowerShell 命令提示符处,键入以下命令:

    $activating.CancelTopologyActivation()
    

删除索引组件

如果一个索引分区有多个活动索引副本,您可以通过执行在 SharePoint Server 中管理搜索组件一文中的 删除搜索组件 过程来删除索引副本。

您无法使用此过程删除索引分区的上一个索引副本。 如果您必须删除搜索拓扑中的所有索引副本,则必须删除并重新创建 Search Service 应用程序,然后创建具有更少数量的索引分区的全新搜索拓扑。

移动索引组件

若要将索引副本从一台服务器移至另一台服务器,建议您在删除旧索引组件之前向搜索拓扑添加新索引组件。

移动索引组件

  1. 向要将索引副本移动到的服务器添加新索引组件。 克隆搜索拓扑,添加新索引副本,等待索引复制到新索引副本并激活搜索拓扑。 请参阅将索引副本添加到现有索引分区

  2. Wait until the new index replica is ready to serve queries. 在管理中心的“搜索管理”页中查看搜索拓扑的状态,或运行 Windows PowerShell cmdlet Get-SPEnterpriseSearchStatus。 Before you proceed, the index replica that you have added must be Active.

  3. 再次克隆搜索拓扑。

  4. 通过删除索引组件来删除多余的索引副本。 请参阅在 SharePoint Server 中管理搜索组件一文中的 删除搜索组件 过程。

  5. 再次激活搜索拓扑。

这将确保在移动索引副本时搜索索引具有容错功能。