Wednesday, May 22, 2013

SharePoint 2013 Search: Moving the Index Partition to the Web Front Ends

I previously wrote a post about Moving the Query Component to a Web Front End. There were questions in regards to the Index Partition/Index Components as well. However, in the meantime I scaled out some of my SharePoint 2013 Search architecture since I had a new "Index Server" provisioned.

While I'll post all of the details of my "scaling out" search experiences, it is recommended that the Index Partition and Query Components live on the same servers;  this is for performance purposes. The more I added to my awesome search results and promoted result blocks across multiple result sources, the slower the search response became. Therefore I decided that we should see what happens if we moved the Index Partition to the web front ends (currently I only have 1 WFE but it would still provide some baseline).

This is all accomplished in PowerShell and/or the SharePoint 2013 Management Console.

Here we go!



Step #1: Get the Search Service Instance and Start on the WFE
#Get Search Service Instance and Start on WFE
$ssi = Get-SPEnterpriseSearchServiceInstance -Identity "<<WFE Server Name>>"
Start-SPEnterpriseSearchServiceInstance -Identity $ssi


Step #2: Wait for the Search Service to Come Online
Get-SPEnterpriseSearchServiceInstance -Identity $ssi

In my full script version, I have a loop that continues until the search service is online.

Step #3: Clone the Active Search Topology
#Clone Active Search Topology
$ssa = Get-SPEnterpriseSearchServiceApplication
$active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone –SearchTopology $active


Step #4: Create the New Index Component on the WFE
#Create New Index Component for Index Partition 0
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $ssi -IndexPartition 0

-RootDirectory "E:\SPIndex"

I created a folder named SPIndex on the E: drive of the WFE. Modify this for your own location.

This step generates a new Index Component. I had IndexComponent3 and IndexComponent4 already so my new one was IndexComponent5 (yours will probably be different):



Step #5: Activate the Cloned Search Topology with the New Index Component
#Activate the Cloned Search Topology
Set-SPEnterpriseSearchTopology -Identity $clone


Once this is complete you may review your search topology:
#Review new topology
Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa



Step #6: Monitor the Distribution of the Index
Get-SPEnterpriseSearchStatus -SearchApplication $ssa

The new index component will be degraded until it has sync'ed with the active index components:



In the full script I again have a loop that waits until the new component is Active. Looking at your Search Service Application in Central Admin shows a warning:


Once the new Index Component is active, a new green check appears in the Search Service Application:


Step #7: Clone the Active Search Topology Again
# Clone Again
$ssa = Get-SPEnterpriseSearchServiceApplication
$active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone –SearchTopology $active


Step #8: Get the ID of the Index Component to Remove
# Get the Index Search Component ID To Remove
$indexComponentID = (Get-SPEnterpriseSearchComponent -SearchTopology $clone -Identity IndexComponent3).componentID


My component was IndexComponent3 yours may be different.
Use Get-SPEnterpriseSearchStatus -SearchApplication $ssa to see which components you have.

Step #9: Remove the original Index Component
# Remove Search Component
Remove-SPEnterpriseSearchComponent -Identity $indexComponentID.GUID -SearchTopology $clone -confirm:$false


In my case I has had the two components on two servers so I repeated Step #8 and Step #9.


Step #10: Activate Search Topology Again
# Activate  Search Topology Again
Set-SPEnterpriseSearchTopology -Identity $clone



Step #11: Monitor the Distribution of the Index (this time it should be instantaneous)
Get-SPEnterpriseSearchStatus -SearchApplication $ssa

Once the new search topology is activated the Index Partition is moved to the web front end:



What about other WFEs? I will need to add index components to additional WFEs which will be similiar to the process I used to build out my index components on my index servers. More to come on that.

Full Script (fill in the << >> values)

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get Search Service Instance and Start on WFE
$ssi = Get-SPEnterpriseSearchServiceInstance -Identity "<<WFE Server Name>>"
Start-SPEnterpriseSearchServiceInstance -Identity $ssi


#Wait for Search Service Instance to come online
do {$online = Get-SPEnterpriseSearchServiceInstance -Identity $ssi; Write-Host "Waiting for service: " $online.Status}
until ($online.Status -eq "Online")


#Clone Active Search Topology
$ssa = Get-SPEnterpriseSearchServiceApplication
$active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone –SearchTopology $active

#Create New Index Component for Index Partition 0
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $ssi -IndexPartition 0 -RootDirectory "E:\SPIndex"

#Activate the Cloned Search Topology
Set-SPEnterpriseSearchTopology -Identity $clone


#Review new topology
Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa


#Monitor Distribution of Index
do {$activeState = Get-SPEnterpriseSearchStatus -SearchApplication $ssa | Where-Object {$_.Name -eq "IndexComponent5"}; Write-Host "Waiting for active distribution: " $activeState.State}
until ($activeState.State -eq "Active")


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


# Get the Index Search Component ID To Remove
$indexComponentID = (Get-SPEnterpriseSearchComponent -SearchTopology $clone -Identity <<Index Component Name>>).componentID


# Remove Search Component
Remove-SPEnterpriseSearchComponent -Identity $indexComponentID.GUID -SearchTopology $clone -confirm:$false


# Activate  Search Topology Again
Set-SPEnterpriseSearchTopology -Identity $clone


#Monitor Distribution of Index
do {$activeState = Get-SPEnterpriseSearchStatus -SearchApplication $ssa | Where-Object {$_.Name -eq "<<New Index Component Name>>"}; Write-Host "Waiting for active distribution: " $activeState.State}
until ($activeState.State -eq "Active")


 

28 comments:

  1. Nice information. Thanks Steve.

    My question is: For Search Service we have 4 database at the back end.
    1. AnalyticsReportingStore DB
    2. CrawlStoreDB
    3. Search DB
    4. LinksStore DB

    In which DB the Indexed data is stored? Can you please tell me specific name of any table in the DB?
    I was looking for information which would tell me detailed internals of how the data is passed from one search component to another. Eg: When the data is crawled how it is stored and passed on the content processing component and then to Index component

    Thanks
    Rahul
    prabhune_rahul@yahoo.com

    ReplyDelete
    Replies
    1. This link has a good overview:
      http://msdn.microsoft.com/en-us/library/sharepoint/jj163300.aspx#bk_crawl

      Delete
  2. HI Steve,
    Great posts on moving query and index components. Very helpful.

    Couple side notes
    1. Users should move Query before Index or Index will fail.
    2. Run the index script on the WFE server you are deploying to; otherwise, the -RootDirectory "E:\SPIndex" fails because that path already exists with the old index component data.
    "New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $ssi -IndexPartition 0 -RootDirectory "E:\SPIndex""
    Thanks!
    Matt

    ReplyDelete
    Replies
    1. Thanks Matt. I agree with the first note but I didn't have to run my new index script on the wfe. The $ssi should tell it which server. However, my original index was on f: so maybe if its the same drive and folder, it needs to run on the wfe. Thanks again for the notes. Should help clarify to readers.

      Delete
  3. Hi, I'm moving search to another server, trying to remove the original search component but can't get the command below to work. Any ideas??

    $indexComponentID = (Get-spenterprisesearchcomponent -searchtopology $clone -identity indexcomponent1).componentid

    This is the error....
    Get-spenterprisesearchcomponent : Sequence contains no elements
    At line:1 char:22
    + $indexComponentID = (Get-spenterprisesearchcomponent -searchtopology $clone
    -ide ...
    +
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidData: (Microsoft.Offic...SearchComponent:
    GetSearchComponent) [Get-SPEnterpriseSearchComponent], InvalidOperationExc
    eption
    + FullyQualifiedErrorId : Microsoft.Office.Server.Search.Cmdlet.GetSearchC
    omponent

    ReplyDelete
  4. Have you verified that IndexComponent1 is the name of the component?
    Use:
    Get-SPEnterpriseSearchComponent -SearchTopology $clone
    to verify.

    Maybe it is case sensitive?

    -=Steve

    ReplyDelete
    Replies
    1. Thanks Steve, it is case sensitive! :)

      Delete
  5. Nice script.
    Remember to stop any crawls before cloning topology though:
    http://technet.microsoft.com/en-us/library/dn535606.aspx#BKMK_MakeSureNoCrawls

    # Disable Continious Crawl
    $contentSources = $ssa | Get-SPEnterpriseSearchCrawlContentSource | ? Type -eq "SharePoint" | % { $_.EnableContinuousCrawls = $false; $_.Update() }
    # Stop crawls
    foreach ( $contentSource in $contentSources )
    {
    if ( $contentSource.CrawlStatus -ne "Idle" )
    {
    $contentSource.StopCrawl()
    while ( $contentSource.CrawlStatus -ne "Idle" )
    {
    Write-Host $contentSource.CrawlStatus
    Start-Sleep 1
    }
    }
    }

    ReplyDelete
  6. I see the reasoning for having the index on the same server as the query component, but I would rather move the query component to an app server than moving the index to the WFE's. I would not want my WFE's to have a high disk io load.. they should be dummy cpu processing units.

    Can you also provide some numbers on how much data you had in your test, and the different query times when you moved components around?

    By having the content processing on a different machine than the index, you also have to move more data across the network during indexing.

    Then again, there are many ways to make it work, and it all depends on your workload :)

    ReplyDelete
    Replies
    1. I agree this is not a specified search topology. The query response did improve once I split out. I don't have numbers but perception was reality. We have 3 WFEs for only 3500 users worldwide. Average of only a few hundred concurrently. Therefore our WFEs are not being pounded at all. We wanted to do more with less resources so we opted for the Query and Index on WFEs.

      Delete
    2. Cool.. and I agree that if the hardware can support it, use it :) You might want to have a backup index as well, which you don't have in the scenario above..as you have more boxes. I was sort of wondering if it changed from 200ms to 20ms, or if it was closer to 1 second before the move.... so that a user notice it or not.

      And there is no question about it that having query and index on the same server will remove the need to do network traffic to another server. Something I haven't tested is if you ahve two WFE's, both with an index(replica)... can you be sure the WFE will send the request to the index of the same machine, or can you risk it sending it across the wire in a round robin fashion.

      I'll ping someone and try to find out :)

      Delete
  7. Hi Steve,
    After removing one of the Index partition it is failing with you cant remove non empty, can you help me.
    Set-SPEnterpriseSearchTopology -Identity $clone

    Set-SPEnterpriseSearchTopology : Topology activation failed. Removing index partitions from a non-empty is not
    supported.
    At line:1 char:1
    + Set-SPEnterpriseSearchTopology -Identity $clone
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidData: (Microsoft.Offic...tSearchTopology:SetSearchTopology) [Set-SPEnterpriseSea
    rchTopology], SearchTopologyActivationException
    + FullyQualifiedErrorId : Microsoft.Office.Server.Search.Cmdlet.SetSearchTopology

    ReplyDelete
    Replies
    1. You should move the Query component first. Did you do that?

      Delete
    2. im having the same problem. 2 nodes
      1 with index 0
      1 with index 0 and 1

      when i try to remove index replica 1, it said the same error.

      Delete
  8. I was able to move the index files (thanks so much for that), but it looks like I'm unable to change the default crawl location (which is still on C). Hopefully my google-fu is just weak and I'm missing something, but I'd rather not have to reinstall SP. Please help, thanks :)

    ReplyDelete
  9. You mean the index location is on C:? What did you specify in the -RootDirectory parameter.

    ReplyDelete
  10. Thanks for the great post. I agree moving Query Processing and Index components will improve End User experience, but what will you recommend to make Crawling for Content Source better for servers. So for example, if Content Source Crawling takes 2 hours on a server with all components installed on the same box , what will you recommend to get Crawling completed in less time? Thoughts? I tried splitting in multiple content sources and adding host files entries for 127.0.0.1 for each url , but I am looking more efficient ways.
    Thanks again for great series!

    ReplyDelete
    Replies
    1. Adding more search servers always helps. We have two dedicated search boxes that run all components except for query and index. You may also enable continuous crawl so your index is always fresh and you don't need to run a full crawl. Here are other options: http://technet.microsoft.com/en-us/library/dn727118(v=office.15).aspx

      Delete
  11. Steve,
    Loved your articles and they were really what I was looking for so I could understand why you would put the query and index on the front end.
    In one of the Microsoft 2013 topology documents it shows a dedicated server on the front end for just query and index. If I have the resources do you think this would be the way to go?
    thanks for the great articles.

    ReplyDelete
    Replies
    1. Yes! Technically Query/Index on WFE is not a recomnended topology. Having them on two separate dedicated servers is the recommended scale out.

      Delete
  12. Steve,
    Similar to Query and Index component is there a way to have the default drive of Content and Analytic processing component move to desperate drive I thought it should be easy but nothing I can find out as of now.Also is there a way we reduce the temps files that gets created during the crawling before it gets dumped out to avoid having extra space for these files from Content and Analytics.

    ReplyDelete
    Replies
    1. That is determined by the SharePoint install. I always use the E: drive and even change the ULS logs to point to a location on E:.

      Delete
  13. Hi Steve,

    WE are facing this problem when trying to mvoe the index component to other server. tried clearing config cache etc. any clue about this error.

    Rollback prending due to the last activation
    failure. Cannot start Activation of another topology now.

    ReplyDelete
    Replies
    1. it is trying to clean up itself. did you try rebooting the server that runs the component? also make sure there is enough disk space where the index files live

      Delete
  14. Hi Steve. I have a question for you. We installed the May 2016 CU onto our SharePoint farm this morning and the one application server we are using for search services took forever to update. When all was said and done, we were left with a server that had almost no storage space on the "C" drive due to extremely large sized files in the SearchAnalytics folder. (561.linksByFromCache.0, 1, etc)

    Needless to say I did not perform the PSConfig.exe to update the databases after this for fear of causing problems.

    Is there a safe way that I can wipe out these cache files, and free up some space so that I can continue on with our update? Can these files be deleted or cleared out somehow with a powershell command?

    Thanks!

    ReplyDelete
    Replies
    1. I don't know off hand. I wouldn't want to be responsible for causing havoc but I would probably just delete the files.

      Delete
    2. I don't know off hand. I wouldn't want to be responsible for causing havoc but I would probably just delete the files.

      Delete

Matched Content