sys.dm_hadr_database_replica_cluster_states (Transact-SQL)sys.dm_hadr_database_replica_cluster_states (Transact-SQL)

適用範圍:Applies to: 是SQL ServerSQL Server (所有支援的版本) yesSQL ServerSQL Server (all supported versions) 適用範圍:Applies to: 是SQL ServerSQL Server (所有支援的版本) yesSQL ServerSQL Server (all supported versions)

傳回包含資訊的資料列,該資訊的目的是為了提供您 Windows Server 容錯移轉叢集 (WSFC) 叢集中每個 Always On 可用性群組內 AlwaysOn 可用性群組的可用性資料庫健康情況見解。Returns a row containing information intended to provide you with insight into the health of the availability databases in the Always On availability groups in each Always On availability group on the Windows Server Failover Clustering (WSFC) cluster. 查詢 sys.dm_hadr_database_replica_states 來回答下列問題:Query sys.dm_hadr_database_replica_states to answer the following questions:

  • 可用性群組中的所有資料庫都已準備好可進行容錯移轉嗎?Are all databases in an availability group ready for a failover?

  • 強制容錯移轉之後,次要資料庫是否已在本機暫停它自己,並將其暫停狀態認可到新的主要複本?After a forced failover, has a secondary database suspended itself locally and acknowledged its suspended state to the new primary replica?

  • 如果主要複本目前無法使用,哪一個次要複本會在成為主要複本時允許最少的資料遺失?If the primary replica is currently unavailable, which secondary replica would allow the minimum data loss if it becomes the primary replica?

  • sys.databases log_reuse_wait_desc 資料行的值為 "AVAILABILITY_REPLICA" 時,可用性群組中的次要複本會在指定的主資料庫上保留記錄截斷?When the value of the sys.databases log_reuse_wait_desc column is "AVAILABILITY_REPLICA", which secondary replica in an availability group is holding up log truncation on a given primary database?

資料行名稱Column name 資料類型Data type 描述Description
replica_idreplica_id uniqueidentifieruniqueidentifier 可用性群組中可用性複本的識別碼。Identifier of the availability replica within the availability group.
group_database_idgroup_database_id uniqueidentifieruniqueidentifier 可用性群組中資料庫的識別碼。Identifier of the database within the availability group. 這個識別碼在此資料庫聯結的每個複本上都相同。This identifier is identical on every replica to which this database is joined.
database_namedatabase_name sysnamesysname 屬於可用性群組的資料庫名稱。Name of a database that belongs to the availability group.
is_failover_readyis_failover_ready bitbit 指出次要資料庫是否與對應的主要資料庫同步處理。Indicates whether the secondary database is synchronized with the corresponding primary database. 下列其中一個值:one of:

0 = 資料庫不會標示為已在叢集中同步處理。0 = The database is not marked as synchronized in the cluster. 資料庫尚未做好容錯移轉的準備。The database is not ready for a failover.

1 = 資料庫標示為已在叢集中同步處理。1 = The database is marked as synchronized in the cluster. 資料庫已做好容錯移轉的準備。The database is ready for a failover.
is_pending_secondary_suspendis_pending_secondary_suspend bitbit 指出在強制容錯移轉之後,資料庫是否會暫止暫停,可為下列其中一個值:Indicates whether, after a forced failover, the database is pending suspension, one of:

0 = HADR_SYNCHRONIZED_ SUSPENDED 除外的任何狀態。0 = Any states except for HADR_SYNCHRONIZED_ SUSPENDED.

1 = HADR_SYNCHRONIZED_ SUSPENDED。1 = HADR_SYNCHRONIZED_ SUSPENDED. 當強制容錯移轉完成時,每一個次要資料庫都會設定為 HADR_SYNCHONIZED_SUSPENDED 並持續保留在這個狀態中,直到新的主要複本接收到從該次要資料庫到 SUSPEND 訊息的認可為止。When a forced failover completes, each of the secondary databases is set to HADR_SYNCHONIZED_SUSPENDED and remains in this state until the new primary replica receives an acknowledgement from that secondary database to the SUSPEND message.

NULL = 未知 (無仲裁)NULL = Unknown (no quorum)
is_database_joinedis_database_joined bitbit 指出此可用性複本上的資料庫是否已聯結可用性群組,可為下列其中一個值:Indicates whether the database on this availability replica has been joined to the availability group, one of:

0 = 資料庫尚未聯結此可用性複本上的可用性群組。0 = Database is not joined to the availability group on this availability replica.

1 = 資料庫已聯結此可用性複本上的可用性群組。1 = Database is joined to the availability group on this availability replica.

NULL = 未知 (可用性複本缺少仲裁)。NULL = unknown (The availability replica lacks quorum.)
recovery_lsnrecovery_lsn numeric(25,0)numeric(25,0) 在主要複本上,此複本在復原或容錯移轉後、寫入任何新記錄檔記錄前,交易記錄的結尾。On the primary replica, the end of the transaction log before the replica writes any new log records after recovery or failover. 在主要複本上,給定次要資料庫的資料列將會擁有主要複本需要將次要複本同步成為 (也就是還原及重新初始化) 的值。On the primary replica, the row for a given secondary database will have the value to which the primary replica needs the secondary replica to synchronize to (that is, to revert to and reinitialize to).

在次要複本上,這個值為 NULL。On secondary replicas this value is NULL. 請注意,每一個次要複本都會擁有主要複本已告知次要複本要還原成的最大值或較低值。Note that each secondary replica will have either the MAX value or a lower value that the primary replica has told the secondary replica to go back to.
truncation_lsntruncation_lsn numeric(25,0)numeric(25,0) Always On 可用性群組Always On availability groups 記錄截斷值,如果已封鎖本機記錄截斷 (例如由備份作業封鎖),則此值可能會高於本機截斷 LSN。The Always On 可用性群組Always On availability groups log truncation value, which may be higher than the local truncation LSN if local log truncation is blocked (such as by a backup operation).

安全性Security

權限Permissions

需要伺服器的 VIEW SERVER STATE 權限。Requires VIEW SERVER STATE permission on the server.

另請參閱See Also

Always On 可用性群組動態管理檢視和函數 (Transact-sql) Always On Availability Groups Dynamic Management Views and Functions (Transact-SQL)
AlwaysOn 可用性群組目錄檢視 (Transact-SQL) Always On Availability Groups Catalog Views (Transact-SQL)
監視可用性群組 (Transact-sql) Monitor Availability Groups (Transact-SQL)
AlwaysOn 可用性群組 (SQL Server) Always On Availability Groups (SQL Server)
sys.dm_hadr_database_replica_states (Transact-SQL)sys.dm_hadr_database_replica_states (Transact-SQL)