本文档介绍如何使用健康管理器来监控和管理分片集群的健康问题。
Overview
A Health Manager runs health checks on a health manager facet 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.
健康经理组件
下表显示了可用的健康经理组件:
Facet | 健康观察器检查的内容 |
|---|---|
| 与配置服务器连接相关的集群运行状况问题。 |
| 与 DNS 可用性和功能性相关的集群运行状况问题。 |
| 与 LDAP 可用性和功能性相关的集群运行状况问题。 |
健康管理器强度等级
下表列出了可用的健康管理器强度等级:
强度等级 | 说明 |
|---|---|
| 该组件上的健康管理器已启用,并且能够在发生错误时将出现故障的 mongos 从集群中移出。健康管理器会等待 |
| 该组件上的健康管理器已启用并记录错误,但如果出现错误,Mongo 仍保留在集群中。 |
| 该组件上的健康管理器已禁用。mongos 不会对该组件执行任何健康状况检查。这是默认强度级别。 |
主动故障持续时间
当检测到故障且健康管理器强度等级设置为 critical 时,健康管理器会等待 activeFaultDurationSecs 指定的时间,然后自动停止 mongos 并将其移出群集。
进度监视器
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 自动失败之前超时。 | 秒数 |
示例
以下示例展示了如何配置健康管理器。 有关健康经理参数的信息,请参阅健康经理参数。
强度
例如,要设置 dns 运行状况管理器组件为 critical 强度级别,则在启动时执行以下命令:
mongos --setParameter 'healthMonitoringIntensities={ values:[ { type:"dns", intensity: "critical"} ] }'
Or if using the setParameter command in a mongosh session that is connected to a running mongos:
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,强度等级
请参阅 healthMonitoringIntensities 了解详细信息。
间隔
例如,若要将 ldap 运行状况管理器组件设置为每 30 秒进行一次健康检查,则请在启动时执行以下命令:
mongos --setParameter 'healthMonitoringIntervals={ values:[ { type:"ldap", interval: "30000"} ] }'
Or if using the setParameter command in a mongosh session that is connected to a running mongos:
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,运行的时间间隔,以毫秒为单位
请参阅 healthMonitoringIntervals 了解详细信息。
主动故障持续时间
例如,要将故障到崩溃的持续时间设置为五分钟,则在启动时发出以下命令:
mongos --setParameter activeFaultDurationSecs=300
Or if using the setParameter command in a mongosh session that is connected to a running mongos:
db.adminCommand( { setParameter: 1, activeFaultDurationSecs: 300 } )
使用 setParameter 设置的参数在重启后不会持续存在。有关详细信息,请参阅 setParameter 页面。
要使该设置持续有效,使用 setParameter 选项在您的 mongos 配置文件设置 activeFaultDurationSecs,如以下示例所示:
setParameter: activeFaultDurationSecs: 300
请参阅 activeFaultDurationSecs 了解详细信息。
进度监视器
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}'
Or if using the setParameter command in a mongosh session that is connected to a running mongos:
db.adminCommand( { setParameter: 1, progressMonitor: { interval: 1000, deadline: 300 } ) } )
使用 setParameter 设置的参数在重启后不会持续存在。有关详细信息,请参阅 setParameter 页面。
要使该设置持续有效,使用 setParameter 选项在您的 mongos 配置文件设置 progressMonitor,如以下示例所示:
setParameter: progressMonitor: "{ interval: 1000, deadline: 300 }"
请参阅 progressMonitor 了解详细信息。