鏡像狀態 (SQL Server)Mirroring States (SQL Server)

適用於: 是SQL Server 否Azure SQL Database 否Azure Synapse Analytics (SQL DW) 否平行處理資料倉儲 APPLIES TO: yesSQL Server noAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

在資料庫鏡像工作階段期間,鏡像資料庫一定會處於特定狀態 (「鏡像狀態」 )。During a database mirroring session, the mirrored database is always in a specific state (the mirroring state). 資料庫的狀態會反映通訊狀態、資料流程,以及夥伴之間的資料差異。The state of the database reflects the communication status, data flow, and the difference in data between the partners. 資料庫鏡像工作階段會與主體資料庫採用相同的狀態。The database mirroring session adopts the same state as the principal database.

在資料庫鏡像工作階段內,伺服器執行個體會彼此監視。Throughout a database mirroring session, the server instances monitor each other. 夥伴會使用鏡像狀態來監視資料庫。The partners use the mirroring state to monitor the database. 除了 PENDING_FAILOVER 狀態之外,主體資料庫和鏡像資料庫永遠處於相同的狀態。With the exception of the PENDING_FAILOVER state, the principal and mirror database are always in the same state. 若為工作階段設定見證,則每部夥伴伺服器都會利用其連接狀態 (CONNECTED 或 DISCONNECTED) 來監視見證。If a witness is set for the session, each of the partners monitors the witness using its connection state (CONNECTED or DISCONNECTED).

可能的資料庫鏡像狀態如下:The possible mirroring states of the database are as follows:

鏡像狀態Mirroring state DescriptionDescription
SYNCHRONIZINGSYNCHRONIZING 鏡像資料庫的內容落後於主體資料庫的內容。The contents of the mirror database are lagging behind the contents of the principal database. 主體伺服器將記錄檔記錄傳送至鏡像伺服器,將所做的變更套用到鏡像資料庫來向前復原。The principal server is sending log records to the mirror server, which is applying the changes to the mirror database to roll it forward.

在資料庫鏡像工作階段開始時,資料庫處於 SYNCHRONIZING 狀態。At the start of a database mirroring session, the database is in the SYNCHRONIZING state. 主體伺服器正為資料庫提供服務,而鏡像伺服器則試圖趕上。The principal server is serving the database, and the mirror is trying to catch up.
SYNCHRONIZEDSYNCHRONIZED 當鏡像伺服器足以追趕上主體伺服器時,鏡像狀態就會變更為 SYNCHRONIZED。When the mirror server becomes sufficiently caught up to the principal server, the mirroring state changes to SYNCHRONIZED. 只要主體伺服器繼續傳送變更到鏡像伺服器,而鏡像伺服器也繼續將變更套用到鏡像資料庫,資料庫便會保持在這種狀態。The database remains in this state as long as the principal server continues to send changes to the mirror server and the mirror server continues to apply changes to the mirror database.

如果交易安全性設定為 FULL,SYNCHRONIZED 狀態將可同時支援自動容錯移轉和手動容錯移轉,而且容錯移轉之後不會遺失任何資料。If transaction safety is set to FULLautomatic failover and manual failover are both supported in the SYNCHRONIZED state, there is no data loss after a failover.

如果關閉交易安全性,永遠都有可能遺失部分資料,即使是在 SYNCHRONIZED 狀態也是如此。If transaction safety is off, some data loss is always possible, even in the SYNCHRONIZED state.
SUSPENDEDSUSPENDED 無法使用資料庫的鏡像副本。The mirror copy of the database is not available. 主體資料庫執行時並沒有傳送任何記錄檔到鏡像伺服器,這種狀況稱為「執行公開」 。The principal database is running without sending any logs to the mirror server, a condition known as running exposed. 這是容錯移轉之後的狀態。This is the state after a failover.

工作階段也會因為重做錯誤或管理員暫停工作階段而變成 SUSPENDED。A session can also become SUSPENDED as a result of redo errors or if the administrator pauses the session.

SUSPENDED 是夥伴關機和啟動時仍然有效的永續性狀態。SUSPENDED is a persistent state that survives partner shutdowns and startups.
PENDING_FAILOVERPENDING_FAILOVER 唯有開始進行容錯移轉之後但伺服器尚未轉換為鏡像角色之前,主體伺服器上才會出現此狀態。This state is found only on the principal server after a failover has begun, but the server has not transitioned into the mirror role.

起始容錯移轉時,主體資料庫便會進入 PENDING_FAILOVER 狀態,迅速終止任何使用者連接,然後馬上接替鏡像角色。When the failover is initiated, the principal database goes into the PENDING_FAILOVER state, quickly terminates any user connections, and takes over the mirror role soon thereafter.
DISCONNECTEDDISCONNECTED 夥伴已經與其他夥伴失去通訊。The partner has lost communication with the other partner.

另請參閱See Also

監視資料庫鏡像 (SQL Server)Monitoring Database Mirroring (SQL Server)