How to move the SharePoint Search Service Application database

For one of our customers there was the need to move all Sharepoint 2010 databases to another instance within SQL Server 2008 R2. For all the content databases this was no issue. For the Search Service provider this was a little different. On the internet I was not able to find any workable solution for this problem or at least I could not find it. The crawler processes did not want to stop, start or restart. The way I solved this issue is as follows:

Step 1

In “Sharepoint 2010 Central Administration”, under “Application Management” select “Specify the default database server”. Change your default database server under “Content Database Server” to the new SQL Instance, for example “SQLSERVER/SQLInstance” and confirm this change.

Step 2

From “SharePoint 2010 Central Administration”, “Application Management”, “Manage Service Applications”, Select the “Search Service Application” and select “Content Sources”.  Document all settings for all content sources used.

Step 3

Because the crawlers weren’t running, restartable or startable I remove the Search Service Application. In PowerShell:

$Search = Get-SPServiceApplication |?{$_.name -eq “Search Service Application”}
Remove-SpServiceApplication -Identity $search.Id –RemoveData

And if Powershell won’t work use STSADM:

In PowerShell: Get-SPServiceApplication |?{$_.name -eq “Search Service Application”} to get the ID.

Then

STSADM –o deleteconfigurationobject –id “<the id from the previous powershell command>”

Step 4

Create a new Search Service Application with PowerShell, this will automatically use the new default entered in Step 1. This part I found on http://www.idocs.info/index.php/2010/06/create-a-search-service-moss-2010-with-powershell/

In PowerShell:

# 1.Setting up initial variables.
write-host 1.Setting up initial variables.
$Search_Service_name = “Search Service Application”
$Search_Service_account = “<SearchServiceAccount>”
$Search_Service_Instance = get-spenterprisesearchserviceinstance -local
$err = $null

# Start Services search services for Search_Service_Instance
write-host Start Services search services for Search_Service_Instance
Start-SPEnterpriseSearchServiceInstance -Identity $Search_Service_Instance

# 2.Create an Application Pool.
write-host 2.Create an Application Pool.
$AppPool = new-SPServiceApplicationPool -name $Search_Service_name”_AppPool” -account $Search_Service_account

# 3.Create the SearchApplication and set it to a variable
write-host 3.Create the SearchApplication and set it to a variable
$SearchApplication = New-SPEnterpriseSearchServiceApplication -Name $Search_Service_name -applicationpool $AppPool -databasename $Search_Service_name”_AdminDB”

#4 Create search service application proxy
write-host 4 Create search service application proxy
$Search_Service_Proxy = new-spenterprisesearchserviceapplicationproxy -name $Search_Service_name”ApplicationProxy” -Uri $SearchApplication.Uri.AbsoluteURI

# 5.Provision Search Admin Component.
write-host 5.Provision Search Admin Component.
set-SPenterprisesearchadministrationcomponent -SearchApplication $SearchApplication  -searchserviceinstance $Search_Service_Instance

# 6.Create a new Crawl Topology.
write-host 6.Create a new Crawl Topology.
$CrawlTopo = $SearchApplication | New-SPEnterpriseSearchCrawlTopology

# 7.Create a new Crawl Store.
write-host 7.Create a new Crawl Store.
$CrawlStore = $SearchApplication | Get-SPEnterpriseSearchCrawlDatabase

# 8.Create a new Crawl Component.
write-host 8.Create a new Crawl Component.
New-SPEnterpriseSearchCrawlComponent -CrawlTopology $CrawlTopo -CrawlDatabase $CrawlStore -SearchServiceInstance $Search_Service_Instance

# 9.Activate the Crawl Topology.
write-host 9.Activate the Crawl Topology.
do
{
$err = $null
$CrawlTopo | Set-SPEnterpriseSearchCrawlTopology -Active -ErrorVariable err
if ($CrawlTopo.State -eq “Active”)
{
$err = $null
}
Start-Sleep -Seconds 10
}
until ($err -eq $null)

# 10.Create a new Query Topology.
write-host 10.Create a new Query Topology.
$QueryTopo = $SearchApplication | New-SPenterpriseSEarchQueryTopology -partitions 1

# 11.Create a variable for the Query Partition
write-host 11.Create a variable for the Query Partition
$Partition1 = ($QueryTopo | Get-SPEnterpriseSearchIndexPartition)

# 12.Create a Query Component.
write-host 12.Create a Query Component.
New-SPEnterpriseSearchQueryComponent -indexpartition $Partition1 -QueryTopology $QueryTopo -SearchServiceInstance $Search_Service_Instance

# 13.Create a variable for the Property Store DB.
write-host 13.Create a variable for the Property Store DB.
$PropDB = $SearchApplication | Get-SPEnterpriseSearchPropertyDatabase

# 14.Set the Query Partition to use the Property Store DB.
write-host 14.Set the Query Partition to use the Property Store DB.
$Partition1 | Set-SPEnterpriseSearchIndexPartition -PropertyDatabase $PropDB

# 15.Activate the Query Topology.
write-host 15.Activate the Query Topology.
do
{
$err = $null
$QueryTopo | Set-SPEnterpriseSearchQueryTopology -Active -ErrorVariable err -ErrorAction SilentlyContinue
Start-Sleep -Seconds 10
if ($QueryTopo.State -eq “Active”)
{
$err = $null
}
}
until ($err -eq $null)
Write-host “Your search application $Search_Service_name is now ready”

Step 5

All Search Service Application services, processes and settings should be in-place now. Configure your content sources as documented in Step 2. And ready you are.

Comments are closed.