SharePoint Search

Adding a second application server for the Search Service Index for SharePoint 2013

An incident occurred in large multi-server SharePoint 2013 farm that took out search for several hours.  This incident was highly visible as there were several search components on the Intranet’s home page.  An investigation revealed that the C: system drive ran out of disk space causing the index become corrupted.

The solution and migration strategy was to build additional redundancy in search service.

After following posts from Steve Mann’s blog, I was getting a bunch of errors that were taking too long to investigate and resolve so decided to delete the search service application rebuild it from scratch.

The following outlines the scripts I used to set up search with the 2nd application server.

Step 1

  • ​Run the following powershell script to add all search components to the topology for both application servers

The following can be run as one single script:

# Search parameters

$SVCAcct = “DOMAIN\SEARCH_SVC_ACCOUNT”

$searchServerName = “APPSERVERNAME01”

$serviceAppName = “Search Service Application”

$searchDBName = “SP13_SearchDB”

# Create an Application Pool.

write-host Create an Application Pool.

$saAppPoolName = new-SPServiceApplicationPool -name $serviceAppName -account $SVCAcct

# Grab the Application Pool for Service Application Endpoint

$saAppPool = Get-SPServiceApplicationPool $saAppPoolName

# Start Search Service Instances

Write-Host “Starting Search Service Instances…”

Start-SPEnterpriseSearchServiceInstance $searchServerName

Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $searchServerName

# Create the Search Service Application and Proxy

Write-Host “Creating Search Service Application and Proxy…”

$searchServiceApp = New-SPEnterpriseSearchServiceApplication -Name $serviceAppName -ApplicationPool $saAppPoolName -DatabaseName $searchDBName

$searchProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name “$serviceAppName Proxy” -SearchApplication $searchServiceApp

# Clone the default Topology (which is empty) and create a new one and then activate it

Write-Host “Configuring Search Component Topology… APPSERVERNAME01”

$clone = $searchServiceApp.ActiveTopology.Clone()

$searchServiceInstance = Get-SPEnterpriseSearchServiceInstance -Identity “APPSERVERNAME01”

New-SPEnterpriseSearchAdminComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance

New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance

New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance

New-SPEnterpriseSearchCrawlComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance

New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance -IndexPartition 0 -RootDirectory “D:\SPIndex”

New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance

Write-Host “Configuring Search Component Topology… APPSERVERNAME02”

$searchServiceInstance2 = Get-SPEnterpriseSearchServiceInstance -Identity “MELSPSTINTAPP02”

New-SPEnterpriseSearchAdminComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance2

New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance2

New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance2

New-SPEnterpriseSearchCrawlComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance2

New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance2 -IndexPartition 0 -RootDirectory “D:\SPIndex”

New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance2

$clone.Activate()

Write-Host “Search Done!”

Topology state:

s1

Step 2

  • Run the following script to add Query Processing search component to Topology for web front ends

The following will have to be run as one line at a time (on the SharePoint Management Shell prompt) as it relies on services to be online before continuing:

# Start a search service instance on WFEs

$wfe1 = Get-SPEnterpriseSearchServiceInstance -Identity “WFESERVERNAME01”

Start-SPEnterpriseSearchServiceInstance -Identity $wfe1

$wfe2 = Get-SPEnterpriseSearchServiceInstance -Identity “WFESERVERNAME02”

Start-SPEnterpriseSearchServiceInstance -Identity $wfe2

# Confirm search service instances are running and ONLINE

Get-SPEnterpriseSearchServiceInstance -Identity $wfe1

Get-SPEnterpriseSearchServiceInstance -Identity $wfe2

# Retrieve the active search topology – ONLY WHEN ABOVE IS ONLINE

$ssa = Get-SPEnterpriseSearchServiceApplication

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

$active

# Retrieve a list of search components

$ssa = Get-SPEnterpriseSearchServiceApplication

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

Get-SPEnterpriseSearchComponent -SearchTopology $active

# Clone the active search topology

$ssa = Get-SPEnterpriseSearchServiceApplication

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

$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone -SearchTopology $active

# Add a search component

New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $clone -SearchServiceInstance $wfe1

New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $clone -SearchServiceInstance $wfe2

# Activate a search topology

Set-SPEnterpriseSearchTopology -Identity $clone

# Verify that the new search components were added to the clone topology and Retrieve the search component Id

Get-SPEnterpriseSearchComponent -SearchTopology $clone

Output:

ComponentId : 28d7decd-2981-48a3-9330-aaaaaaaaaaaa

TopologyId  : 45fc9abf-0032-45e5-b978-bbbbbbbbbbbb

ServerId    : 68980732-535d-4019-81bf-cccccccccccc

Name        : QueryProcessingComponent1

ServerName  :APPSERVERNAME01

ComponentId : 28d7decd-2981-48a3-9330-dddddddddd

TopologyId  : 45fc9abf-0032-45e5-b978-eeeeeeeeee

ServerId    : 68980732-535d-4019-81bf-fffffffffffff

Name        : QueryProcessingComponent2

ServerName  :APPSERVERNAME02

Topology state:

s2

Step 3

  • Run the following to remove Query Processing search component from application servers from Topology

The following will have to be run as one line at a time (on the SharePoint Management Shell prompt) as it relies on services to be online before continuing:

# Clone the active search topology

$ssa = Get-SPEnterpriseSearchServiceApplication

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

$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone -SearchTopology $active

# Remove a search component (index components on app01 and app02)

# Verify that the new search components were added to the clone topology and Retrieve the search component Id

Run:

Get-SPEnterpriseSearchComponent -SearchTopology $clone

Output:

ComponentId : 28d7decd-2981-48a3-9330-aaaaaaaaaaaa

TopologyId  : 45fc9abf-0032-45e5-b978-bbbbbbbbbbbb

ServerId    : 68980732-535d-4019-81bf-cccccccccccc

Name        : QueryProcessingComponent1

ServerName  : APPERVERNAME01

ComponentId : 28d7decd-2981-48a3-9330-ddddddddd

TopologyId  : 45fc9abf-0032-45e5-b978-eeeeeeeeee

ServerId    : 68980732-535d-4019-81bf-fffffffffffffffff

Name        : QueryProcessingComponent2

ServerName  :APPERVERNAME02
Continue:

Remove-SPEnterpriseSearchComponent -Identity 28d7decd-2981-48a3-9330-aaaaaaaaaaaa -SearchTopology $clone

Remove-SPEnterpriseSearchComponent -Identity 28d7decd-2981-48a3-9330-ddddddddddd -SearchTopology $clone

# Activate a search topology

Set-SPEnterpriseSearchTopology -Identity $clone​

# Verify that your new topology is active

Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa

Topology state: s3

Advertisements