AlwaysON 還原資料庫的步驟

在SQL AlwaysOn的狀況下如果必須還原主要副本的資料庫,整個還原流程該是如何呢?

爬文爬到一個SOP,先記錄一下。

Code would be similar to the following:

Step1.在主要副本
ALTER AVAILABILITY GROUP MyAG REMOVE DATABASE AdventureWorks2012;
Step2.在主要副本
RESTORE DATABASE AdventureWorks2012 FROM AdventureWorksBackups WITH NORECOVERY, 
MOVE 'AdventureWorks2012_Data' TO 'C:\Program Files\Microsoft SQL Server\MSSQL12
.MSSQLSERVER\MSSQL\Data\NewAdvWorks.mdf', 
MOVE 'AdventureWorks2012_Log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL12.
MSSQLSERVER\MSSQL\Data\NewAdvWorks.ldf'; 

RESTORE LOG AdventureWorks2012 FROM AdventureWorksBackups WITH RECOVERY;
Step3.在次要副本
RESTORE DATABASE AdventureWorks2012 FROM AdventureWorksBackups WITH NORECOVERY,
 MOVE 'AdventureWorks2012_Data' TO 'C:\Program Files\Microsoft SQL Server\MSSQL12
.MSSQLSERVER\MSSQL\Data\NewAdvWorks.mdf', 
MOVE 'AdventureWorks2012_Log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL12.
MSSQLSERVER\MSSQL\Data\NewAdvWorks.ldf'; 

RESTORE LOG AdventureWorks2012 FROM AdventureWorksBackups WITH NORECOVERY;
Step4.在主要副本
ALTER AVAILABILITY GROUP MyAG ADD DATABASE AdventureWorks2012;
Step5.在次要副本
ALTER DATABASE AdventureWorks2012 SET HADR AVAILABILITY GROUP = MyAG;

 

參考資料來源 http://dba.stackexchange.com/questions/82548/restoring-a-sql-server-2012-database-in-high-availability

我是ROCK

rockchang@mails.fju.edu.tw