Docs 菜单

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.

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.

The following table shows the available Health Manager facets:

Facet
健康观察器检查的内容

configServer

与配置服务器连接相关的集群运行状况问题。

dns

与 DNS 可用性和功能性相关的集群运行状况问题。

ldap

与 LDAP 可用性和功能性相关的集群运行状况问题。

The following table shows the available Health Manager intensity levels:

强度等级
说明

critical

该组件上的健康管理器已启用,并且能够在发生错误时将出现故障的 mongos 从集群中移出。健康管理器会等待 activeFaultDurationSecs 指定的时间,然后自动停止并从集群中移出 mongos

non-critical

该组件上的健康管理器已启用并记录错误,但如果出现错误,Mongo 仍保留在集群中。

off

该组件上的健康管理器已禁用。mongos 不会对该组件执行任何健康状况检查。这是默认强度级别。

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 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

如果健康管理器检查没有取得进展,则在 Mongo 自动失败之前超时。

秒数

The following examples show how Health Managers can be configured. For information on Health Manager parameters, see 健康管理器参数.

例如,要设置 dns 运行状况管理器组件为 critical 强度级别,则在启动时执行以下命令:

mongos --setParameter 'healthMonitoringIntensities={ values:[ { type:"dns", intensity: "critical"} ] }'

或者,如果在连接至正在运行的 mongosmongosh 会话中使用 setParameter 命令:

db.adminCommand(
{
setParameter: 1,
healthMonitoringIntensities: { values: [ { type: "dns", intensity: "critical" } ] } } )
}
)

使用 setParameter 设置的参数在重启后不会持续存在。有关详细信息,请参阅 setParameter 页面

要使该设置持续有效,使用 setParameter 选项在您的 mongos 配置文件设置 healthMonitoringIntensities,如以下示例所示:

setParameter:
healthMonitoringIntensities: "{ values:[ { type:\"dns\", intensity: \"critical\"} ] }"

healthMonitoringIntensities 接受一个文档数组,valuesvalues 中的每个文档都有两个字段:

  • type,健康管理器组件

  • intensity ,强度级别

See healthMonitoringIntensities for details.

例如,若要将 ldap 运行状况管理器组件设置为每 30 秒进行一次健康检查,则请在启动时执行以下命令:

mongos --setParameter 'healthMonitoringIntervals={ values:[ { type:"ldap", interval: "30000"} ] }'

或者,如果在连接至正在运行的 mongosmongosh 会话中使用 setParameter 命令:

db.adminCommand(
{
setParameter: 1,
healthMonitoringIntervals: { values: [ { type: "ldap", interval: "30000" } ] } } )
}
)

使用 setParameter 设置的参数在重启后不会持续存在。有关详细信息,请参阅 setParameter 页面

要使该设置持续有效,使用 setParameter 选项在您的 mongos 配置文件设置 healthMonitoringIntervals,如以下示例所示:

setParameter:
healthMonitoringIntervals: "{ values: [{type: \"ldap\", interval: 200}] }"

healthMonitoringIntervals 接受一个文档数组,valuesvalues 中的每个文档都有两个字段:

  • type,健康管理器组件

  • interval ,其运行的时间间隔(以毫秒为单位)

See healthMonitoringIntervals for details.

例如,要将故障到崩溃的持续时间设置为五分钟,则在启动时发出以下命令:

mongos --setParameter activeFaultDurationSecs=300

或者,如果在连接至正在运行的 mongosmongosh 会话中使用 setParameter 命令:

db.adminCommand(
{
setParameter: 1,
activeFaultDurationSecs: 300
}
)

使用 setParameter 设置的参数在重启后不会持续存在。有关详细信息,请参阅 setParameter 页面

要使该设置持续有效,使用 setParameter 选项在您的 mongos 配置文件设置 activeFaultDurationSecs,如以下示例所示:

setParameter:
activeFaultDurationSecs: 300

See activeFaultDurationSecs for details.

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.

要将 intervaldeadline 分别设置为 1000 毫秒和 300 秒,则在启动时发出以下命令:

mongos --setParameter 'progressMonitor={"interval": 1000, "deadline": 300}'

或者,如果在连接至正在运行的 mongosmongosh 会话中使用 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.