Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / productivity / SharePoint

Make SharePoint 2010/2013 Mirroring Aware

5.00/5 (1 vote)
11 Mar 2016CPOL1 min read 7.2K  
To make your Sharepoint database reliable, you need to mirror it, meaning whatever happens on SQL Server A will be mirrored or replicated on SQL Server B and it’s quite easy to achieve. You just need two steps to do it.

To make your Sharepoint database reliable, you need to mirror it, meaning whatever happens on SQL Server A will be mirrored or replicated on SQL Server B and it’s quite easy to achieve - you just need two steps to do it.

First is to mirror your SQL Server databases, you can achieve that all on SSMS and I have a published simple instructions before on how it's done. Now do this for all of your Sharepoint Databases and to get a complete list of that, you will need to use Powershell to show all active databases your Sharepoint is using, the command for that is:

Get-SPDatabase|Select Name

You will then get a result something like this, listing all the databases you need.

Image 1

Once you mirrored them all, you’re ready for the next part, making your Sharepoint mirror aware.

Now, go to your Central Administration and Manage Content Databases.

Image 2

Choose the WSS Content Database:

Image 3

Then, set a Failover Database Server to the Mirror Server you set earlier.

Image 4

Once done, set the Failover for all of your databases by using the AddFailoverServiceInstance method from the SPContentDatabase Object. To do that easily, I created a script that will loop to all the databases your Sharepoint uses and set the Failover Database on each.

SQL
$dbFailoverServer = "YOURSQLSERVER2"
$dbNames = Get-SPDatabase|Select Name
foreach ($dbName in $dbNames)
{
    Write-Host "Setting Failover for " $dbName.Name 
    $db = Get-SPDatabase | Where { $_.Name -eq $dbName.Name }
    $db.AddFailoverServiceInstance($dbFailoverServer)
    $db.Update()
}

Image 5

And you are done, you can now try to failover your main SQL server and see if it works. Tomorrow, we will be discussing High Availability on Web Front End servers to keep in touch.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)