Manually Fail Over a Database Mirroring Session (Transact-SQL)
Applies to: SQL Server
When the mirrored database is synchronized (that is, when the database is in the SYNCHRONIZED state), the database owner can initiate manual failover to the mirror server. Manual failover can be initiated only from the principal server.
To manually fail over a database mirroring session
Connect to the principal server.
Set the database context to the master database:
USE master;
Issue the following statement on the principal server:
ALTER DATABASE database_name SET PARTNER FAILOVER, where database_name is the mirrored database.
This initiates an immediate transition of the mirror server to the principal role.
On the former principal, clients are disconnected from the database and in-flight transactions are rolled back.
Note
Transactions that have been prepared by using the Microsoft Distributed Transaction Coordinator but are still not committed when a failover occurs are considered aborted after the database has failed over.
See Also
ALTER DATABASE Database Mirroring (Transact-SQL)
Manually Fail Over a Database Mirroring Session (SQL Server Management Studio)
Role Switching During a Database Mirroring Session (SQL Server)
Phản hồi
https://aka.ms/ContentUserFeedback.
Sắp ra mắt: Trong năm 2024, chúng tôi sẽ dần gỡ bỏ Sự cố với GitHub dưới dạng cơ chế phản hồi cho nội dung và thay thế bằng hệ thống phản hồi mới. Để biết thêm thông tin, hãy xem:Gửi và xem ý kiến phản hồi dành cho