SQL Server Failover +alwayson Increase database to availability group

Source: Internet
Author: User
Tags failover

SQL Server Failover +alwayson Add database to availability Group
The configuration of SQL Server Failover +alwayson has been described in detail in the previous articles, and today we mainly introduce the addition of databases to availability groups under SQL Server Failover Cluster+alwayson
We first need to create a database and a table

Database name
HAGroupDB2

Create a table

To insert data into a table

We add this database to the High Availability Group; The currently created database is not synchronized

We'll increase the database under the High Availability Group

Tip We need a full backup.

So we back up

We also back up the transaction log

After the backup is complete, we need to restore the backed up database and things Log on node 3

Restoring a Database

Restore status must be selected in the option when restoring: Restore with NORECOVERY

Database Restore Complete

We view the Restore status

Restore the Thing log again


Restore Options---We choose the second option---resotre with NORECOVERY

Restore complete

After we restore the database and transaction log, the state of the database is not being restored

And then we started adding databases to the AG.

We choose Join only

We link a replica server that already exists

Connection Successful

Join success

We look at the database information in AG

View the status of the cluster database and also become a synchronized


We look at the panel, everything works.

Combined with the above, we can use PowerShell to complete

 $DatabaseBackupFile = "\\share\backups\MyDatabase.bak" $LogBackupFile = "\\SHARE\BACKUPS\MYDATABASE.TRN" $ Myagprimarypath = "Sqlserver:\sql\primaryserver\instancename\availabilitygroups\myag" $MyAgSecondaryPath = " Sqlserver:\sql\secondaryserver\instancename\availabilitygroups\myag "Backup-sqldatabase-database" MyDatabase "- BackupFile $DatabaseBackupFile-serverinstance "Primaryserver\instancename" Backup-sqldatabase-database "MyDatabase "-backupfile $LogBackupFile-serverinstance" primaryserver\instancename "-backupaction ' Log ' restore-sqldatabase- Database "MyDatabase"-backupfile $DatabaseBackupFile-serverinstance "Secondaryserver\instancename"-norecovery Restore-sqldatabase-database "MyDatabase"-backupfile $LogBackupFile-serverinstance "Secondaryserver\instancename" -restoreaction ' Log '-norecovery add-sqlavailabilitydatabase-path $MyAgPrimaryPath-database "MyDatabase" Add-sqlavailabilitydatabase-path $MyAgSecondaryPath-database "MyDatabase" 

SQL Server Failover +alwayson Add a database to an availability group

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.