在 SharePoint Server 中管理搜尋元件Manage search components in SharePoint Server

摘要:了解如何使用 Windows PowerShell 以管理在 SharePoint Server 搜尋索引中具有內容之現有搜尋拓撲中的搜尋元件。使用這些程序擴大或縮小 Search Service 應用程式的搜尋拓撲。Summary: Learn how to use Windows PowerShell to manage search components in an existing search topology that has content in the SharePoint Server search index. Use these procedures to scale out or scale down the search topology of the Search service application.

本文中的程序和範例假設已安裝 SharePoint Server、SharePoint Server 2016 和 Search Service 應用程式,且存在現有搜尋拓撲,並在 SharePoint Server 搜尋索引中具有項目。若 SharePoint Server 和 Search Service 應用程式為新安裝,且 SharePoint Server 搜尋索引中沒有項目,請遵循<變更 SharePoint Server 中的預設搜尋拓撲>中的程序。The procedures and the examples in this article assume that SharePoint ServerSharePoint Server 2016 and the Search service application are installed, and that there is an existing search topology and items in the SharePoint Server search index. If SharePoint Server and the Search service application are newly installed and there are no items in the SharePoint Server search index, follow the procedures in Change the default search topology in SharePoint Server.

本文中的程序適用於下列搜尋元件︰The procedures in this article apply to the following search components:

  • 分析處理元件Analytics processing component

  • 內容處理元件Content processing component

  • 編目元件Crawl component

  • 搜尋管理元件Search administration component

  • 查詢處理元件Query processing component

如需管理索引元件之程序的資訊,請參閱<在 SharePoint Server 中管理索引元件>。For information about procedures to manage the index component, see Manage the index component in SharePoint Server.

開始之前Before you begin

開始之前,請先檢閱下列必要條件。Before you begin, review the following prerequisites.

  • 已安裝 SharePoint Server,並已建立具備搜尋拓撲的 Search Service 應用程式。Search Service 應用程式處於狀況良好狀態,未因任何原因而暫停。SharePoint Server is installed and a Search service application with a search topology is created. The Search service application is in a healthy state and is not paused for any reason.

  • 正在執行本文中程序的使用者帳戶是 伺服器陣列管理員 群組的成員。The user account that is performing the procedures in this article is a member of the Farm Administrators group.

  • 您已規劃目標搜尋拓樸。You have planned a target search topology.

  • 已在所有要裝載搜尋元件的伺服器上安裝 SharePoint Server。這些伺服器已新增至伺服器陣列,而您是所有這些伺服器的管理員。您可以在現有部署中建立新的應用程式伺服器或定義應用程式伺服器。SharePoint Server is installed on all the servers that you want to host search components on. The servers have been added to the farm and you are an administrator on all these servers. You can create new application servers or define application servers in an existing deployment.

重要

[!重要事項] 本文中的程序使用 Microsoft PowerShell。您可以在伺服器陣列中的任何伺服器上執行 Microsoft PowerShell 命令。不過,若您執行多重搜尋拓撲程序,則應對所有 Microsoft PowerShell 命令使用相同的 SharePoint 2016 管理命令介面,以便在命令之間共用 Microsoft PowerShell 物件參照。The procedures in this article use Microsoft PowerShell. You can run the Microsoft PowerShell commands on any server in the farm. However, if you are performing multiple search topology procedures you should use the same SharePoint 2016 Management Shell for all Microsoft PowerShell commands so that you can share Microsoft PowerShell object references between commands.

在伺服器上啟動 Search Service 執行個體Start a search service instance on a server

您必須先在伺服器上啟動 Search Service 執行個體,才能在新的伺服器上新增搜尋元件。Search Service 執行個體會啟動 Search Service 使用之所有必要的 Windows 服務 (OSearch16 和 SPSearchHostController)。Before you add search components to a new server, you must first start a search service instance on the server. The search service instance starts all the necessary Windows services that are used by the search service (OSearch16 and SPSearchHostController).

啟動 Search Service 執行個體To start a search service instance

  1. 確認執行此程序的使用者帳戶為伺服器陣列管理員群組的成員。Verify that the user account that is performing this procedure is a member of the Farm Administrators group.

  2. 在伺服器陣列中的其一伺服器上啟動 SharePoint 管理命令介面。Start a SharePoint Management Shell on one of the servers in the farm.

  3. 在 Microsoft PowerShell 命令提示字元處,輸入下列命令:At the Microsoft PowerShell command prompt, type the following command(s):

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

    其中:Where:

    • $ <主機 n> 指定 Search Service 執行個體的 PowerShell 物件參照。$ <host n> specifies the PowerShell object reference for the search service instance.

    • <伺服器名稱> 指定您要新增索引元件的伺服器。輸入必須是 12345678-90ab-cdef-1234-567890bcdefgh 格式的有效 GUID;有效的伺服器名稱 (例如 myserver1 );或有效 SearchServiceInstance 物件的執行個體。<Server name> specifies the server on which you want to add an index component. The input must be a valid GUID, in the form 12345678-90ab-cdef-1234-567890bcdefgh; a valid name of a server (for example, myserver1 ); or an instance of a valid SearchServiceInstance object.

    例如:For example:

    $hostA = Get-SPEnterpriseSearchServiceInstance -Identity "myserver1"
    $hostB = Get-SPEnterpriseSearchServiceInstance -Identity "myserver2"
    Start-SPEnterpriseSearchServiceInstance -Identity $hostA
    Start-SPEnterpriseSearchServiceInstance -Identity $hostB 
    

    您在新增搜尋元件時,使用 ($<主機 n>) 參照來指定目標伺服器。You use the references ($<host n>) to specify the target server when you add search components.

  4. 等到所有的 Search Service 執行個體都在執行。針對每個 Search Service 執行個體,在 Microsoft PowerShell 命令提示字元輸入下列命令,直到命令傳回 連線 狀態︰Wait until all the search service instances are running. For each of the search service instances, at the Microsoft PowerShell command prompt, type the following command until the command returns the status Online:

    Get-SPEnterpriseSearchServiceInstance -Identity $<host n >
    

    例如:For example:

    Get-SPEnterpriseSearchServiceInstance -Identity $hostA
    TypeName    : SharePoint Server Search
    Description : Index content and serve search queries
    Id          : 82ce8815-ecbd-4cf3-a98e-33f20bd86039
    Server      : SPServer Name=myserver1.example.com
    Service     : SearchService Name=OSearch16
    Role        : None
    Status      : Online
    

擷取使用中的搜尋拓撲Retrieve the active search topology

若要檢視 Search Service 應用程式使用中的搜尋拓撲,您必須使用 Microsoft PowerShell。To view the active search topology of the Search service application, you have to use Microsoft PowerShell.

檢視使用中的搜尋拓撲To view the active search topology

  1. 確認執行此程序的使用者帳戶為伺服器陣列管理員群組的成員。Verify that the user account that is performing this procedure is a member of the Farm Administrators group.

  2. 啟動 SharePoint 管理命令介面。若已有開啟的 SharePoint 管理命令介面,且在其中已建立可重複使用的 Microsoft PowerShell 物件參照,則使用開啟的命令介面。Start a SharePoint Management Shell. If you already have an open SharePoint Management Shell in which you have created reusable Microsoft PowerShell object references, use the open shell instead.

  3. 在 Microsoft PowerShell 命令提示字元處,輸入下列命令:At the Microsoft PowerShell command prompt, type the following command:

    $ssa = Get-SPEnterpriseSearchServiceApplication
    $active = Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa 
    $active
    

此命令會傳回使用中拓撲的相關資訊例如:TopologyId : 2d7bb046-1ad4-43a9-9984-754c4551a3ec CreationDate : 1/25/2016 3:06:00 AM State : Active ComponentCount : 6The command returns information about the active topology, for example: TopologyId : 2d7bb046-1ad4-43a9-9984-754c4551a3ec CreationDate : 1/25/2016 3:06:00 AM State : Active ComponentCount : 6

擷取搜尋元件清單Retrieve a list of search components

若要檢視使用中搜尋拓撲的搜尋元件與其屬性的清單,您必須使用 Microsoft PowerShell。其中一個搜尋元件屬性為搜尋元件識別碼。您只需要搜尋元件識別碼即可移除搜尋元件。To view a list of search components in the active search topology with their properties, you have to use Microsoft PowerShell. One of the search component properties is the search component Id. You will only need the search component Id to remove a search component.

檢視所有搜尋元件清單To view a list of all search components

  1. 確認執行此程序的使用者帳戶為伺服器陣列管理員群組的成員。Verify that the user account that is performing this procedure is a member of the Farm Administrators group.

  2. 啟動 SharePoint 管理命令介面。若已有開啟的 SharePoint 2016 管理命令介面,且在其中已建立可重複使用的 SharePoint 管理命令介面 物件參照,則使用開啟的命令介面。Start a SharePoint Management Shell. If you already have an open SharePoint 2016 Management Shell in which you have created reusable SharePoint Management Shell object references, use the open shell instead.

  3. 在 Microsoft PowerShell 命令提示字元處,輸入下列命令:At the Microsoft PowerShell command prompt, type the following command(s):

    $ssa = Get-SPEnterpriseSearchServiceApplication
    $active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
    Get-SPEnterpriseSearchComponent -SearchTopology $active
    

    該命令會以傳回使用中搜尋拓撲的搜尋元件與其屬性的清單。The command returns a list of search components in the active search topology and their properties.

複製使用中的搜尋拓撲Clone the active search topology

若要對搜尋索引已存在項目之搜尋安裝中的搜尋拓撲做出任何變更,您必須先建立新的拓撲物件。新的拓撲物件是使用中拓撲的複製,您可藉由新增或移除搜尋元件來修改這個新的拓撲物件。在變更複製的拓撲物件後,再使得該複製成為使用中拓撲。To make any changes to the search topology in a search installation that has items in the search index, you first have to create a new topology object. You modify this new topology object, a clone of the active topology, by adding or removing search components. After you have made the changes to the clone topology object, you make the clone the active topology.

複製使用中的拓撲To clone the active topology

  1. 確認執行此程序的使用者帳戶為伺服器陣列管理員群組的成員。Verify that the user account that is performing this procedure is a member of the Farm Administrators group.

  2. 啟動 SharePoint 管理命令介面。若已有開啟的 SharePoint 管理命令介面,且在其中已建立可重複使用的 Microsoft PowerShell 物件參照,則使用開啟的命令介面。Start a SharePoint Management Shell. If you already have an open SharePoint Management Shell in which you have created reusable Microsoft PowerShell object references, use the open shell instead.

  3. 在 Microsoft PowerShell 命令提示字元處,輸入下列命令:At the Microsoft PowerShell command prompt, type the following command(s):

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

    該命令會建立複製的搜尋拓撲,並參照為 $clone,讓您繼續使用相同的 SharePoint 管理命令介面來新增或移除搜尋元件,並且啟動該搜尋拓撲。The command creates a clone search topology that can be referenced with $clone if you continue to use the same SharePoint Management Shell to add or remove search components and to activate the search topology.

  4. (選用) 若要從搜尋拓撲移除搜尋元件,則必須擷取搜尋元件識別碼。在 Microsoft PowerShell 命令提示字元處,輸入下列命令:(Optional) If you have to remove search components from the search topology, you have to retrieve the search component Id. At the Microsoft PowerShell command prompt, type the following command(s):

    Get-SPEnterpriseSearchComponent -SearchTopology $clone
    

    該命令會傳回複製搜尋拓撲的搜尋元件與其屬性的清單,包含搜尋元件識別碼。The command returns a list of search components in the cloned search topology and their properties, including the search component Id.

新增搜尋元件Add a search component

您無法直接變更使用中的搜尋拓撲。此程序假設您已如複製使用中的搜尋拓撲中所述,建立複製的拓撲物件。您可針對每個搜尋元件使用下列 Microsoft PowerShell Cmdlet:You cannot change the active search topology directly. This procedure assumes that you have created a clone topology object as described in Clone the active search topology. You can use the following Microsoft PowerShell cmdlets for each search component:

  • 新 SPEnterpriseSearchAdminComponentNew-SPEnterpriseSearchAdminComponent

  • 新 SPEnterpriseSearchAnalyticsProcessingComponentNew-SPEnterpriseSearchAnalyticsProcessingComponent

  • 新 SPEnterpriseSearchContentProcessingComponentNew-SPEnterpriseSearchContentProcessingComponent

  • 新 SPEnterpriseSearchCrawlComponentNew-SPEnterpriseSearchCrawlComponent

  • 新 SPEnterpriseSearchQueryProcessingComponentNew-SPEnterpriseSearchQueryProcessingComponent

注意

[!附註] 新增索引元件的程序有所不同。如需詳細資訊,請參閱<在 SharePoint Server 中管理索引元件>。The procedure to add an index component is different. For more information, see Manage the index component in SharePoint Server .

新增搜尋元件To add a search component

  1. 確認執行此程序的使用者帳戶為伺服器陣列管理員群組的成員。Verify that the user account that is performing this procedure is a member of the Farm Administrators group.

  2. 啟動 SharePoint 管理命令介面。若已有開啟的 SharePoint 管理命令介面,且在其中已建立可重複使用的 Microsoft PowerShell 物件參照,則使用開啟的命令介面。Start a SharePoint Management Shell. If you already have an open SharePoint Management Shell in which you have created reusable Microsoft PowerShell object references, use the open shell instead.

  3. 在 Microsoft PowerShell 命令提示字元處,輸入下列命令:At the Microsoft PowerShell command prompt, type the following command(s):

    New-SPEnterpriseSearch<SearchComponent> -SearchTopology $clone -SearchServiceInstance $<host n >
    

    其中:Where:

    例如,下列命令會在伺服器上的複製拓撲中新增內容處理元件,而伺服器是以 Search Service 執行個體參照 $hostA 做為識別。For example, the following command adds a content processing component to the clone topology on the server identified by the search service instance reference $hostA.

    New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $clone -SearchServiceInstance $hostA
    
  4. 請確認已將新的搜尋元件新增至複製的拓撲。在 Microsoft PowerShell 命令提示字元處,輸入下列命令:Verify that the new search component was added to the clone topology. At the Microsoft PowerShell command prompt, type the command:

    Get-SPEnterpriseSearchComponent -SearchTopology $clone
    

移除搜尋元件Remove a search component

若要移除搜尋元件,您必須使用 Windows PowerShell。您無法直接變更使用中的搜尋拓撲。此程序假設您已如複製使用中的搜尋拓撲中所述,建立複製的拓撲物件。To remove a search component, you have to use Windows PowerShell. You cannot change the active search topology directly. This procedure assumes that you have created a clone topology object as described in Clone the active search topology.

注意

[!附註] 移除索引元件的程序有所不同。如需詳細資訊,請參閱<在 SharePoint Server 中管理索引元件>。The procedure to remove an index component is different. For more information, see Manage the index component in SharePoint Server.

移除搜尋元件To remove a search component

  1. 確認執行此程序的使用者帳戶為伺服器陣列管理員群組的成員。Verify that the user account that is performing this procedure is a member of the Farm Administrators group.

  2. 啟動 SharePoint 管理命令介面。若已有開啟的 SharePoint 管理命令介面,且在其中已建立可重複使用的 Microsoft PowerShell 物件參照,則使用開啟的命令介面。Start a SharePoint Management Shell. If you already have an open SharePoint Management Shell in which you have created reusable Microsoft PowerShell object references, use the open shell instead.

  3. 確認目前使用中的拓撲狀況良好,且要移除之搜尋元件的狀態為 作用中 。在管理中心的 [搜尋管理] 頁面或執行 Windows PowerShell Cmdlet Get-SPEnterpriseSearchStatus,皆可檢視搜尋拓撲的狀態。Make sure that the current active topology is healthy and that the search component that you are about to remove is Active. View the status of the search topology in the Search Administration page in Central Administration or run the Windows PowerShell cmdlet Get-SPEnterpriseSearchStatus.

  4. 在 Microsoft PowerShell 命令提示字元處,輸入下列命令:At the Microsoft PowerShell command prompt, type the following command(s):

    Remove-SPEnterpriseSearchComponent -Identity <Search component id> -SearchTopology $clone
    

    其中:Where:

  5. 出現提示時,請確認您要移除該搜尋元件。When prompted, confirm that you want to remove the search component.

移動搜尋元件Move a search component

若要在伺服器之間移動搜尋元件,建議您先在搜尋拓撲中新增搜尋元件,然後再移除舊的搜尋元件。If you want to move a search component from one server to another, we recommend that you add a new search component to the search topology before you remove the old search component.

移動搜尋元件To move a search component

  1. 複製使用中的搜尋拓撲。請參閱複製使用中的搜尋拓撲Clone the active search topology. See Clone the active search topology.

  2. 將搜尋元件新增至最終要裝載該搜尋元件的伺服器。請參閱新增搜尋元件Add a new search component to the server that you eventually want the search component to be hosted on. See Add a search component.

  3. 啟動搜尋拓撲。此拓撲會有一個非必要的搜尋元件。請參閱啟動搜尋拓撲Activate the search topology. This topology will have one superfluous search component. See Activate a search topology.

  4. 確認目前使用中的拓撲狀況良好。在管理中心的 [搜尋管理] 頁面或執行 Windows PowerShell Cmdlet Get-SPEnterpriseSearchStatus,皆可檢視搜尋拓撲的狀態。Make sure that the current active topology is healthy. View the status of the search topology in the Search Administration page in Central Administration or run the Windows PowerShell cmdlet Get-SPEnterpriseSearchStatus.

  5. 再次複製搜尋拓撲。請參閱複製使用中的搜尋拓撲Clone the search topology again. See Clone the active search topology.

  6. 移除非必要的搜尋元件。請參閱移除搜尋元件Remove the superfluous search component. See Remove a search component.

  7. 再次啟用搜尋拓撲。請參閱啟動搜尋拓撲Activate the search topology again. See Activate a search topology.

啟動搜尋拓撲Activate a search topology

若要啟動搜尋拓撲,您必須使用 Windows PowerShell。To activate a search topology, you have to use Windows PowerShell.

啟動搜尋拓撲To activate a search topology

  1. 確認執行此程序的使用者帳戶為伺服器陣列管理員群組的成員。Verify that the user account that is performing this procedure is a member of the Farm Administrators group.

  2. 啟動 SharePoint 管理命令介面。若已有開啟的 SharePoint 管理命令介面,且在其中已建立可重複使用的 Microsoft PowerShell 物件參照,則使用開啟的命令介面。Start a SharePoint Management Shell. If you already have an open SharePoint Management Shell in which you have created reusable Microsoft PowerShell object references, use the open shell instead.

  3. 在 Microsoft PowerShell 命令提示字元處,輸入下列命令:At the Microsoft PowerShell command prompt, type the following command(s):

    Set-SPEnterpriseSearchTopology -Identity $clone
    

    其中:Where:

  4. 確認新的拓撲為使用中。在 Windows PowerShell 命令提示字元處,輸入下列命令:Verify that your new topology is active. At the Windows PowerShell command prompt, type the following command(s):

    Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa
    

    該命令會傳回使用中與非使用中拓撲的概觀,例如:The command returns an overview of active and inactive topologies, for example:

    TopologyId     : fce8507d-61c6-4498-8038-4fd2d0a62c6e
    CreationDate   : 1/30/2016 2:52:00 AM
    State          : Inactive
    ComponentCount : 6
    TopologyId     : b63d48b2-df5c-41be-a7f4-9abaee483611
    CreationDate   : 1/30/2016 4:30:00 AM
    State          : Active
    ComponentCount : 7
    

    您將會見到使用中拓撲的元件計數會反映所做的變更。You will see that the component count of the active topology reflects the changes that you have made.