Geeks With Blogs
Points To Share Mostly SharePoint

Renaming SharePoint service app databases

When you install SharePoint 2010 and use the wizards, you will be asked which services you’d like to install. By default all but Lotus-Notes-Connector are preselected. SharePoint will install the services and assign a plethora of databases to serve these services.

Alas, horror of horror, all these databases are named by Microsoft and all end with GUIDs. DBAs and other keepers of standards abhor it. Sometimes they even go a step further and want the DB names to conform to some esoteric naming convention or another, so they demand (and we the meek comply) that the DB names will be changed.

Here we (the meek) will save ourselves tons of work by being more selective. Instead of ‘wizardly’ creating apps and databases – databases that we later must rename, let us select just what we need but need not later change. So tick all the apps off except: Access Services, Excel Services, Application Registry, Admin Content, and Search.  The first two have no associated DBs, the next two have ‘guided’ DB that we cannot change or affect – which means that even the strictest of the DBAs has no choice but to live with it, and Search because changing its database names (yes names, 3 of them) is bordering on the impossible – probably on the wrong side of the border.

You may create the services by using Central Admin or by using PowerShell, but I am not going into how this is done.  In here I am only going to speak about handling the Search app and its databases.

I was asked to do the database renaming by a client. Luckily we agreed on a T&M approach or I would have lost my pants – possibly even my underwear. I came after the fact and immediately ‘googled’ for solutions. (Why didn’t I use Bing? Because Bing has no Bang!!). The best article I found was:

This article guided me more or less w/o any events until I tried to follow its advice about search. More or less because what they forgot to tell you was not to rename all the databases. Instead you’ll do much better if you rename them one-by-one and just before you do a step. So be warned. Again, you are better off creating the apps already with the right database names, but I digress. Following the article’s advice with the Search app simply does not work. Worse than that, renaming the search databases in SQL Server opens a Pandora’s Box. You’ll get stuck with a Search app that does not work and that you cannot remove, at least not in CA or in PowerShell.

To remove the now ‘offended’ and offending app, you must get its id – in CA go to Manage Service Apps, right click on the Search and copy shortcut. The last piece of the shortcut is the app’s id in a form of – you guessed it – a GUID. Now go to the bin directory of the 14 hive and use the following STSADM command: Stsadm -o deleteconfigurationobject -id   97s2fgd9-453k-3423-f334-8r78jd3bv2t6 replace the yellowed GUID with your own.

So now that you don’t have a Search app, you can create it and control the DB name to boot. How? Use the script below, but set the first five variables to reflect your own set of servers and database name.

## Parameters used

## change the variables below to your own servers and naming conventions


$databaseServerName = "shrpt-db-server"

$searchServerName = "shrpt-apps-server"

$searchSAName = "Search Service Application"

$saAppPoolName = "SharePoint Web Services Default"

$searchDBName = "Search_Services_Application_DB"


## First remove the old search

## This will require an id - namely a guid so get the service guid before doing this


$spapp = Get-SPServiceApplication -Name $searchSAName

Remove-SPServiceApplication $spapp -RemoveData



Write-Host "Creating Search Service and Proxy..."

Write-Host "  Starting Services..."

Start-SPEnterpriseSearchServiceInstance $searchServerName

Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $searchServerName


Write-Host "  Creating Search Application..."

$searchApp = New-SPEnterpriseSearchServiceApplication -Name $searchSAName -ApplicationPool $saAppPoolName -DatabaseServer $databaseServerName -DatabaseName $searchDBName

$searchInstance = Get-SPEnterpriseSearchServiceInstance $searchServerName 


Write-Host "  Creating Administration Component..."

$searchApp | Get-SPEnterpriseSearchAdministrationComponent | Set-SPEnterpriseSearchAdministrationComponent -SearchServiceInstance $searchInstance




Write-Host "  Creating Crawl Component..."

$InitialCrawlTopology = $searchApp | Get-SPEnterpriseSearchCrawlTopology -Active

$CrawlTopology = $searchApp | New-SPEnterpriseSearchCrawlTopology

$CrawlDatabase = ([array]($searchApp | Get-SPEnterpriseSearchCrawlDatabase))[0]

$CrawlComponent = New-SPEnterpriseSearchCrawlComponent -CrawlTopology $CrawlTopology -CrawlDatabase $CrawlDatabase -SearchServiceInstance $searchInstance

$CrawlTopology | Set-SPEnterpriseSearchCrawlTopology -Active


Write-Host -ForegroundColor white "  Waiting for the old crawl topology to become inactive" -NoNewline

do {write-host -NoNewline .;Start-Sleep 6;} while ($InitialCrawlTopology.State -ne "Inactive")

$InitialCrawlTopology | Remove-SPEnterpriseSearchCrawlTopology -Confirm:$false





Write-Host "  Creating Query Component..."

$InitialQueryTopology = $searchApp | Get-SPEnterpriseSearchQueryTopology -Active

$QueryTopology = $searchApp | New-SPEnterpriseSearchQueryTopology -Partitions 1 

$IndexPartition= (Get-SPEnterpriseSearchIndexPartition -QueryTopology $QueryTopology)

$QueryComponent = New-SPEnterpriseSearchQuerycomponent -QueryTopology $QueryTopology -IndexPartition $IndexPartition -SearchServiceInstance $searchInstance

$PropertyDatabase = ([array]($searchApp | Get-SPEnterpriseSearchPropertyDatabase))[0] 

$IndexPartition | Set-SPEnterpriseSearchIndexPartition -PropertyDatabase $PropertyDatabase

$QueryTopology | Set-SPEnterpriseSearchQueryTopology -Active

## Proxy


Write-Host "  Creating Proxy..."

$searchAppProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "$searchSAName Proxy" -SearchApplication $searchSAName > $null   


#####END SEARCH   

That’s All Folks!


Posted on Wednesday, December 7, 2011 12:47 PM | Back to top

Comments on this post: Renaming SharePoint Service Apps Databases

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © PointsToShare | Powered by: | Join free