Answers:
听您的顾问。通过还原备份,您实际上是在替换数据库架构和数据。您将需要关闭同步,从HA中删除数据库并在主数据库和副本数据库上执行还原,并使用WITH NORECOVERY使副本版本处于还原状态。备份到位后,将数据库放回HA并再次开始同步。
HA与镜像非常相似,并使用类似的技术,但差强人意。您也将希望同样对待HA DB。
代码类似于以下内容:
-在小学
ALTER AVAILABILITY GROUP MyAG REMOVE DATABASE AdventureWorks2012;
-在小学
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.
RESTORE LOG AdventureWorks2012
FROM AdventureWorksBackups
WITH RECOVERY;
-在中学
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;
-在小学
ALTER AVAILABILITY GROUP MyAG ADD DATABASE AdventureWorks2012;
-在中学
ALTER DATABASE AdventureWorks2012 SET HADR AVAILABILITY GROUP = MyAG;
The mirror database, "dbname", has insufficient transaction log data to preserve the log backup chain of the principal database. This may happen if a log backup from the principal database has not been taken or has not been restored on the mirror database.