Configure a high available search service on SharePoint 2013

I needed to configure a high available search service on SharePoint 2013 using two application cum WFE servers and one SQL DB server.
 
The production environment consist OF these servers:
Server 1  : Application and WFE 1
server 2  : Application and WFE 2
Server 3  : Database server

Below diagram shows the proposed search topology :
image
The objective was to configure the search in a way that search service should keep running even when one server goes down. To create a highly available and redundant search environment we need to install all search components on both servers. SharePoint 2013 doesn’t allow us to configure/modify above the search topology through Central admin console . The only option is to configure it using SharePoint Management Shell.

Below is the script I used to create high available search service on SharePoint2013 :

#set variables
$App1 = "WFE-APP1"
$APP2 = "WFE-APP2"
$SearchAppPoolName = "Search_App_Pool1"
$SearchAppPoolAccountName = "domain\SP_service_account"
$SearchServiceName = "Search_Service_App1"
$SearchServiceProxyName = "Search_Service_Proxy1"
$DatabaseName = "Search_Admin_DB1"

#Create a Search Service Application Pool
$spAppPool = New-SPServiceApplicationPool -Name $SearchAppPoolName -Account $SearchAppPoolAccountName -Verbose

#Start Search Service Instance and Search Query instances on both Application Servers
Start-SPEnterpriseSearchServiceInstance $App1 -ErrorAction SilentlyContinue
Start-SPEnterpriseSearchServiceInstance $App2 -ErrorAction SilentlyContinue
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $App1 -ErrorAction SilentlyContinue
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $App2 -ErrorAction SilentlyContinue

#Create Search Service Application
$ServiceApplication = New-SPEnterpriseSearchServiceApplication -Partitioned -Name $SearchServiceName -ApplicationPool $spAppPool.Name -DatabaseName $DatabaseName

#Create Search Service Proxy
New-SPEnterpriseSearchServiceApplicationProxy -Partitioned -Name $SearchServiceProxyName -SearchApplication $ServiceApplication

#Setting up the topology

$hostApp1 = Get-SPEnterpriseSearchServiceInstance -Identity $APP1 
$hostApp2 = Get-SPEnterpriseSearchServiceInstance -Identity $APP2
Start-SPEnterpriseSearchServiceInstance -Identity $hostApp1
Start-SPEnterpriseSearchServiceInstance -Identity $hostApp2
Get-SPEnterpriseSearchServiceInstance -Identity $hostApp1
Get-SPEnterpriseSearchServiceInstance -Identity $hostApp2

$ssa = Get-SPEnterpriseSearchServiceApplication
$newTopology = New-SPEnterpriseSearchTopology -SearchApplication $ssa

New-SPEnterpriseSearchAdminComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1
New-SPEnterpriseSearchCrawlComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1
New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1
New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1


New-SPEnterpriseSearchAdminComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp2
New-SPEnterpriseSearchCrawlComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp2
New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp2
New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp2
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp2
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp2

#Set the primary and replica index location; ensure these drives and folders exist on application servers. Create folders on SharePoint servers.
$PrimaryIndexLocation = "L:\Index\Primary"
$ReplicaIndexLocation = "L:\Index\Replica"

#create index partitions and replicas for each partition.
New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1 -RootDirectory $PrimaryIndexLocation -IndexPartition 0
New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp2 -RootDirectory $ReplicaIndexLocation -IndexPartition 0

#Activate the Topology( this command will take considerable amount of time)
Set-SPEnterpriseSearchTopology -Identity $newTopology

# Verify the Topology
Get-SPEnterpriseSearchTopology -SearchApplication $ssa

I got help from these two blogs:
http://www.powershellmagazine.com/2013/04/29/creating-and-configuring-a-sharepoint-2013-search-service-application/
http://blogs.technet.com/b/meamcs/archive/2013/04/09/configuring-sharepoint-2013-search-topology.aspx

Popular Posts