Поделиться через


Configuring Failover Databases - and Removing That Configuration

SharePoint 2010 supports database mirroring for just about every database you can think of (there are some exceptions - the Synchronization database of the User Profile service, for instance). This allows SharePoint to make use of the Failover Partner attribute within the connection to specify the failover server to the underlying data access stack, making use of a failover database seamless. We just use the plumbing the data access (ADO.NET for the most part, and the components of its stack) provides, and get to take advantage of Other Peoples Code that just Does The Right Thing.

Once you've created a database, though, going back and adding a failover partner can only be done via PowerShell - the Central Administration UI is disabled for this purpose. This is easy enough to do:

 1 # Set failover database server
2 $database = Get-SPDatabase | where { $_.Name -eq "SomeSharePointDB" }
3 $database.AddFailoverServiceInstance("FailoverSQLServerName\OptionalInstanceIfUsed")
4 $database.Update();

What's less obvious is what you need to do when you want to turn things off. For instance, when you are adjusting your mirroring configuration and need to replace (or even remove altogether) the failover partner for a time. If you are just changing the name/instance of the failover partner, you can just re-run the script above to adjust the failover partner server name. If, on the other hand, you are removing the failover partner entirely, you'll need to execute the above script but specify either the PowerShell special variable $null as the failover partner server name, or an empty string - either will work. In so doing, you'll remove the failover server configuration for that database, and SharePoint will adjust the connection string it uses when connecting to that database, removing the Failover Partner attribute.