如何移动可用性组 (AG) 数据库
How to move Availability Group(AG) Databases
我想将 AG 的数据库移动到新位置(在新驱动器上)。
msdn 上有一篇很好的文章,它使用 SQLCmd 实用程序来做同样的事情,但我想从 C# 代码来做。
请帮助我移动需要遵循的所有步骤。
问候
阿希什
Here is a resource for SMO programming, perhaps you will find what you need in the guide.
I must admit though, administering SQL Server from managed code is not something I would recommend unless your product is aimed at administering SQL Server. Alternatively look at doing this from Powershell and then controlling your scripts/cmdlets from your managed application.
Here is another resource with a list of cmdlets for managing SQL Server Availability Groups.
Finally Get Help SQL Server Powershell
我们是在主副本还是辅助副本上移动数据库是不同的。
下面提到的是两个副本的步骤...
1.) 主要副本:-
从所有次要副本 AG 中分离 DB
从主副本 AG 中分离 DB
为需要移动的数据库发出 ALter DB T-SQL 命令。
将 db 文件复制到新目标。
将数据库附加到主副本 AG
将数据库附加到所有辅助副本 AG
2.) 二级副本:-
对数据库进行完整备份。
对数据库进行 t 日志备份
从 AG 中分离 DB
使用之前创建的备份恢复数据库并恢复到目标位置。
将 DB 附加回 AG
我想将 AG 的数据库移动到新位置(在新驱动器上)。 msdn 上有一篇很好的文章,它使用 SQLCmd 实用程序来做同样的事情,但我想从 C# 代码来做。
请帮助我移动需要遵循的所有步骤。
问候 阿希什
Here is a resource for SMO programming, perhaps you will find what you need in the guide.
I must admit though, administering SQL Server from managed code is not something I would recommend unless your product is aimed at administering SQL Server. Alternatively look at doing this from Powershell and then controlling your scripts/cmdlets from your managed application.
Here is another resource with a list of cmdlets for managing SQL Server Availability Groups.
Finally Get Help SQL Server Powershell
我们是在主副本还是辅助副本上移动数据库是不同的。 下面提到的是两个副本的步骤...
1.) 主要副本:- 从所有次要副本 AG 中分离 DB 从主副本 AG 中分离 DB 为需要移动的数据库发出 ALter DB T-SQL 命令。 将 db 文件复制到新目标。 将数据库附加到主副本 AG 将数据库附加到所有辅助副本 AG
2.) 二级副本:- 对数据库进行完整备份。 对数据库进行 t 日志备份 从 AG 中分离 DB 使用之前创建的备份恢复数据库并恢复到目标位置。 将 DB 附加回 AG