SharePoint 2016 - Managing AlwaysOn Availability Group

Introduction

I will walk through the cmdlets which are available in SharePoint 2016 RTM TO manage the databases. With the release of SharePoint 2016, Microsoft introduced 3 new cmdlets to manage the AlwaysOn group. Now, with the help of new cmdlets, the SharePoint administrator can manage the Availability group on AlwaysOn database. With the new commands, we can check the status of the AG group, add the database to AG group or remove the database. Moreover, you can even fail DBServer from primary to secondary.

Here is the list of commands given below.

  • Get-AvailabilityGroupStatus
  • Add-DatabaseToAvailabilityGroup
  • Remove-DatabaseFromAvailabilityGroup
  • Dismount-SPContentDatabase
  • Mount-SPContentDatabase
  • Test-SPContentDatabase

Prior to starting, make sure that a shared location is created on SQL Server, which is accessible from both the primary and secondary group. Also, configure a SharePoint Farm admin account & install an account which has read & write access to that shared location.

Another thing you have to configure is the Always-On group on SQL Server before using these commands. You can't create the Always-On group via these commands.

Get-AvailabilityGroupStatus

This command will return all the available Availability Groups, which are known as SharePoint Farm. 

Get-AvailabilityGroupStatus -Identity krossfarmGroup 

This example returns an Availability Group named KrossFarmGroup. It will show all the information related to Always-On group which is a current primary Server.

Add-DatabaseToAvailabilityGroup

This command is used to add the database(s) from a SharePoint Farm into an Availability Group on the SQL Server. 

Add-DatabaseToAvailabilityGroup -AGName KrossFarmgroup -DatabaseName KF-ContentDB -FileShare \\backup\share\ 

This example adds an Availability Group named KrossFarmgroup to the KF-ContentDB content database.

  • AGName (Required)-The name of the availability group from which the databases are being added.
  • DatabaseName (Required)-The name of the database to be added to the availability group.
  • FileShare (Optional)- This is location which will use this command to perform the backup and restore of the database which will be added to availability group. This location should be accessible from both the Servers.

Remove-DatabaseFromAvailabilityGroup

This command will remove one or more SharePoint databases from an Availability Group in SQL Server.I.e

Remove-DatabaseFromAvailabilityGroup -AGName KrossFarmgroup -DatabaseName KF_ContentDB -force 

This example removes KrossfarmGroup Availability Group from the KF_contentDB content database.

  • AGName (Required)- The name of the Availability Group from which the databases are being removed.
  • DatabaseName (Required)- The name of the database to be removed from the availability group.
  • Force(Optional)- It is a better idea to use Forces switch.
  • KeepSecondaryData(Optional)- You use this parameter, if you want to keep the copies of the database on the secondary Server, else the database copies will be dropped from SQL Server.

If you want to remove all the databases from the AlwaysOn group, you can use the ProcessAllDatabases parameters.

Note

If you manually add the databases to Always-On group, you will not get anything via this command. Make sure to add all SharePoint databases to Availability Group, using these commands.

Up Next
    Ebook Download
    View all
    Learn
    View all