Configure Self-Managed Sharded Cluster Health with Health Managers
This document describes how to use Health Managers to monitor and manage sharded cluster health issues.
Overview
A Health Manager runs health checks on a 健康管理器组件 at a specified intensity level. Health Manager checks run at specified time intervals. A Health Manager can be configured to move a failing mongos out of a cluster automatically. Progress Monitor ensures that Health Manager checks do not become stuck or unresponsive.
Health Manager Facets
The following table shows the available Health Manager facets:
Facet | 健康观察器检查的内容 |
---|---|
| 与配置服务器连接相关的集群运行状况问题。 |
| 与 DNS 可用性和功能性相关的集群运行状况问题。 |
| 与 LDAP 可用性和功能性相关的集群运行状况问题。 |
Health Manager Intensity Levels
The following table shows the available Health Manager intensity levels:
强度等级 | 说明 |
---|---|
| 该组件上的健康管理器已启用,并且能够在发生错误时将出现故障的 mongos 从集群中移出。健康管理器会等待 |
| 该组件上的健康管理器已启用并记录错误,但如果出现错误,Mongo 仍保留在集群中。 |
| 该组件上的健康管理器已禁用。mongos 不会对该组件执行任何健康状况检查。这是默认强度级别。 |
Active Fault Duration
When a failure is detected and the Health Manager intensity level
is set to critical
, the Health Manager waits the amount of time specified by
activeFaultDurationSecs
before stopping and moving the
mongos out of the cluster automatically.
Progress Monitor
Progress Monitor runs tests
to ensure that Health Manager checks do not become stuck or
unresponsive. Progress Monitor runs these tests in intervals specified
by interval
. If a health check begins but does not complete within
the timeout given by deadline
, Progress Monitor stops the
mongos and removes it from the cluster.
progressMonitor
字段
字段 | 说明 | 单位 |
---|---|---|
| 确保健康管理器不会卡住或无响应的频率。 | 毫秒 |
| 如果健康管理器检查没有取得进展,则在 Mongo 自动失败之前超时。 | 秒数 |
示例
The following examples show how Health Managers can be configured. For information on Health Manager parameters, see 健康管理器参数.
Intensity
例如,要设置 dns
运行状况管理器组件为 critical
强度级别,则在启动时执行以下命令:
mongos --setParameter 'healthMonitoringIntensities={ values:[ { type:"dns", intensity: "critical"} ] }'
或者,如果在连接至正在运行的 mongos
的 mongosh
会话中使用 setParameter
命令:
db.adminCommand( { setParameter: 1, healthMonitoringIntensities: { values: [ { type: "dns", intensity: "critical" } ] } } ) } )
使用 setParameter
设置的参数在重启后不会持续存在。有关详细信息,请参阅 setParameter 页面。
要使该设置持续有效,使用 setParameter
选项在您的 mongos 配置文件设置
healthMonitoringIntensities
,如以下示例所示:
setParameter: healthMonitoringIntensities: "{ values:[ { type:\"dns\", intensity: \"critical\"} ] }"
healthMonitoringIntensities
接受一个文档数组,values
。values
中的每个文档都有两个字段:
type
,健康管理器组件intensity
,强度级别
See healthMonitoringIntensities
for details.
Intervals
例如,若要将 ldap
运行状况管理器组件设置为每 30 秒进行一次健康检查,则请在启动时执行以下命令:
mongos --setParameter 'healthMonitoringIntervals={ values:[ { type:"ldap", interval: "30000"} ] }'
或者,如果在连接至正在运行的 mongos
的 mongosh
会话中使用 setParameter
命令:
db.adminCommand( { setParameter: 1, healthMonitoringIntervals: { values: [ { type: "ldap", interval: "30000" } ] } } ) } )
使用 setParameter
设置的参数在重启后不会持续存在。有关详细信息,请参阅 setParameter 页面。
要使该设置持续有效,使用 setParameter
选项在您的 mongos 配置文件设置
healthMonitoringIntervals
,如以下示例所示:
setParameter: healthMonitoringIntervals: "{ values: [{type: \"ldap\", interval: 200}] }"
healthMonitoringIntervals
接受一个文档数组,values
。values
中的每个文档都有两个字段:
type
,健康管理器组件interval
,其运行的时间间隔(以毫秒为单位)
See healthMonitoringIntervals
for details.
Active Fault Duration
例如,要将故障到崩溃的持续时间设置为五分钟,则在启动时发出以下命令:
mongos --setParameter activeFaultDurationSecs=300
或者,如果在连接至正在运行的 mongos
的 mongosh
会话中使用 setParameter
命令:
db.adminCommand( { setParameter: 1, activeFaultDurationSecs: 300 } )
使用 setParameter
设置的参数在重启后不会持续存在。有关详细信息,请参阅 setParameter 页面。
要使该设置持续有效,使用 setParameter
选项在您的 mongos 配置文件设置
activeFaultDurationSecs
,如以下示例所示:
setParameter: activeFaultDurationSecs: 300
See activeFaultDurationSecs
for details.
Progress Monitor
Progress Monitor runs tests
to ensure that Health Manager checks do not become stuck or
unresponsive. Progress Monitor runs these tests in intervals specified
by interval
. If a health check begins but does not complete within
the timeout given by deadline
, Progress Monitor stops the
mongos and removes it from the cluster.
要将 interval
和 deadline
分别设置为 1000 毫秒和 300 秒,则在启动时发出以下命令:
mongos --setParameter 'progressMonitor={"interval": 1000, "deadline": 300}'
或者,如果在连接至正在运行的 mongos
的 mongosh
会话中使用 setParameter
命令:
db.adminCommand( { setParameter: 1, progressMonitor: { interval: 1000, deadline: 300 } ) } )
使用 setParameter
设置的参数在重启后不会持续存在。有关详细信息,请参阅 setParameter 页面。
要使该设置持续有效,使用 setParameter
选项在您的 mongos 配置文件设置
progressMonitor
,如以下示例所示:
setParameter: progressMonitor: "{ interval: 1000, deadline: 300 }"
See progressMonitor
for details.