Compartilhar via


Adding a New Search Partition and Replica in SharePoint 2013

I think there are probably resources out there somewhere for this by now, but I had a hard time finding them when I went looking for them previously so I thought I'd just post it here. Fortunately my friend Knut B. was good enough to shoot me some PowerShell a while back to help you manage your index partitions. In short - what you want to do is get a reference to the search service instance on the host where you want to create a partition or partition replica, then you're going to clone the existing search topology and add your partition or replica to it. Once you've done that, you can tell SharePoint to start using the clone of the topology that you created. Assuming you are starting with a farm that was created with the farm wizard, you will have one index partition, and that partition has no replicas. So let's look first at adding a new search partition:

# Specify the new server you want to add, and start the Search Service Instance:
$newssi = Get-SPEnterpriseSearchServiceInstance -Identity "nameOfServerThatYouWantTheNewPartitionOn"
Start-SPEnterpriseSearchServiceInstance -Identity $newssi

# Wait until the SSI is running. Run the following command until the SSI state indicates “Online”:
Get-SPEnterpriseSearchServiceInstance -Identity $newssi

Now that you've picked the server you want to work with and you know the search service instance is running on it, you can clone the existing search topology:

# Clone the existing topology:
$ssa = Get-SPEnterpriseSearchServiceApplication
$activeTopology=Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa
$newTopology = New-SPEnterpriseSearchTopology -SearchTopology $activeTopology -SearchApplication $ssa -Clone

Once you have your clone in hand, you can create a new partition. Partitions are just numbered 0 through whatever, so again, assuming you have used the wizard and just have one partition so far, then that partition number is 0. To add a second partition to our cloned topology we'll call it partition 1, then we'll set our cloned topology to be the new search topology.

# Add a new index component and specify it is associated with the new index partition 1:
New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology -SearchServiceInstance $newssi -IndexPartition 1
Set-SPEnterpriseSearchTopology -Identity $newTopology

As you can see in the New-SPEnterpriseSearchIndexComponent, we pass along the $newssi variable, which is where we assigned the server on which we want to create the partition. Now once that partition is created, we run virtually the same exact PowerShell to create a replica of that partition on another server. Since I explained above what's going on, I'll just paste the entire PowerShell here and then comment on it:

# Specify the new server you want to add, and start the Search Service Instance:
$newssi = Get-SPEnterpriseSearchServiceInstance -Identity "nameOfServerThatYouWantTheReplicaOn"
Start-SPEnterpriseSearchServiceInstance -Identity $newssi

# Wait until the SSI is running. Run the following command until the SSI state indicates “Online”:
Get-SPEnterpriseSearchServiceInstance -Identity $newssi

# Clone the existing topology:
$ssa = Get-SPEnterpriseSearchServiceApplication
$activeTopology=Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa
$newTopology = New-SPEnterpriseSearchTopology -SearchTopology $activeTopology -SearchApplication $ssa -Clone

# Add a new index component and specify it is associated with the new index partition 1:
New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology -SearchServiceInstance $newssi -IndexPartition 1
Set-SPEnterpriseSearchTopology -Identity $newTopology

The two things to note here are:

  1. In the Get-SPEnterpriseSearchServiceInstance cmdlet I indicate which server I want to host the partition replica
  2. In the New-SPEnterpriseSearchIndexComponent cmdlet I indicated the partition with the -IndexPartition flag. Since I already have an index partition 1, SharePoint will create a replica of that partition for me.

That's it - hope that gets you on your way to managing your search partitions in SharePoint 2013, and thanks again to Knut for sharing his PowerShell.

Comments