这是原厂英文文档的翻译页面. 欢迎帮助我们 完善文档.

2 Proxy 负载均衡 及高可用性

概述

Proxy 负载均衡 允许通过 proxy 组 对 主机 进行监控,并在 proxies 之间自动分发 主机,同时提供高可用性 proxy。

如果一个 proxy 从 proxy 组 中下线,则其 主机 将立即分配给组内分配最少 主机 的其他 proxies。或者,如果某个 proxy 的 主机 数量与组平均值相比过多/过少,则会通过均匀分配 主机 来触发组的重新平衡。

主机 重分配仅发生在联机 proxy 组 中。如果某个 proxy 组 的配置最小数量的 proxies 处于联机状态(非离线或未知状态),则该节点视为“联机”。

:::notetip 组中在线proxies的最小数量应小于该组的proxy总数。在包含10个proxies的组中,将最小在线proxy数量设置为10,会导致只要有一个proxy发生故障,整个组都会下线的情况。建议要求至少有6个在线的proxies,这样可以支持4个非健康的proxies。 仅返回OutputFormat格式要求结果

proxy 状态为:

  • 在线 - 如果在故障转移延迟期间与其进行了通信(被动proxy响应了服务器请求,并且主动proxy向服务器发送了请求);
  • 离线 - 如果在故障转移延迟期间没有与其通信;
  • 未知 - 在 proxy 创建或服务器启动后。

您可以使用 zabbix[proxy 组,<name>,state]zabbix[proxy 组,discovery] 内部 监控项 来监控 proxy 组 状态。

Proxy 负载均衡 并且高可用性由 服务器进程类型与线程 进程管理。proxy 组 管理器始终知道哪些其他 proxies 是健康的或不健康的。

版本兼容性

  • 仅支持 Zabbix agents 7.0 及更高版本以主动模式与 proxy 组 配合使用;
  • Zabbix 预配置的 7。0 version proxies 以及这些 proxies 所监控的 主机 在升级之前将从重新平衡操作中排除。

Host redistribution

Proxy load balancing and high availability is managed by Zabbix server via the proxy group manager, which continuously monitors the state of all proxies in each proxy group and their host distribution.

Proxy high availability within a group is triggered when a proxy goes offline—its hosts are immediately redistributed to other proxies. Proxy load balancing also occurs, as hosts are reassigned to proxies with the fewest assigned hosts.

Additionally, proxy load balancing is triggered when proxy host count differs from the group average by at least 10 hosts and a factor of 2 (host excess or host deficit). If the imbalance persists after a grace period (10 x failover delay), the proxy group is queued for host redistribution.

The proxy group manager redistributes hosts using the following logic:

  1. Calculate the average number of hosts per proxy.
  2. For proxies with host excess—move the excess hosts to the unassigned pool of proxies.
  3. For proxies with host deficit—calculate how many hosts are needed to reach balance.
  4. Remove the required number of hosts from proxies with the most hosts.
  5. Move unassigned hosts to proxies with the fewest hosts.

Examples of host redistribution:

Hosts on proxy Group average Host reassignment
100 50 Yes
60 50 No
40 50 No
25 50 Yes
15 5 Yes
10 5 No

Hosts monitored by a single proxy (even if it belongs to a proxy group) are not involved in load balancing/high availability. Additionally, having fewer than 10 hosts monitored by a proxy group may lead to uneven host distribution among proxies in the group.

配置 proxy 组

要在 Zabbix 前端配置一个 proxy 组:

  • 转至:管理 → proxy 组
  • 点击 创建 proxy 组

参数 描述
Name 输入 proxy 组 名称。
Failover period 输入故障转移执行前的等待时间(默认为 1m;允许范围为 10s-15m)。
支持时间后缀(例如,30s,1m)。
支持用户宏。
Minimum number of proxies 输入组在线所需的最少在线 proxies 数量(默认为 1;允许范围为 1-1000)。
支持用户宏。
Description 输入 proxy 组 描述。
Proxies 组中的 proxies 列表。最多显示五个 proxies(根据对 proxy 的权限,显示为链接或纯文本)。
当编辑现有 proxy 组 且组中至少有一个 proxy 时,将显示此列表。

配置 proxy 负载均衡

配置 Proxy 负载均衡 以监控 主机:

1。创建一个 proxy 组(参见下面的“配置 proxy 组”)。

对于被动检查,组的所有 proxies 必须列在 agents 的 Server 参数中。

将组的所有 proxies 添加到被监控 主机 的 serveractive agent 参数中(以分号分隔)是有益的,但不是强制性的。
一个主动的 agent 可以在 ServerActive 字段中只有一个 proxy,Proxy 负载均衡 仍可正常工作。
当 agent 服务启动时,agent 将接收所有 Zabbix proxies 的完整 IP 地址列表,并加载到内存中并保持。
主动检查(和 Zabbix 发送器数据请求)将根据当前 proxy-主机 分配情况,被重定向到正确的在线 proxy 进行 主机。

如果在 ServerActive 字段中只有一个 proxy,当该特定 proxy 离线时重启 agent 可能导致监控数据丢失。

2。确保 proxy 组 处于在线状态。

3。配置这些 主机 由 proxy 组 监控(而不是单个的 proxies)。您可以使用 主机 mass update 将 主机 从 proxy 移动到 proxy 组。

由单个 proxy 监控的 主机(即使它属于某个 proxy 组)不参与负载均衡/高可用性。
此外,分配给某个 proxy 组 的 主机 少于 10 个,可能导致组内 proxies 之间的 主机 分布不均。

4。等待几秒钟以完成配置 update 以及 proxy 组 内 proxies 之间的 主机 分布。通过刷新 Monitoring -> 主机 中的 主机 列表来观察变化。

当 一个主机 是基于来自属于 proxy 组 的某个 proxy 的自动注册/网络发现数据创建时——则该 主机 将被设置为由该 proxy 组 监控。

Testing proxy load balancing

To test proxy load balancing:

  1. Configure a proxy group.
  2. Make sure that the proxy group has an online state.
  3. Make sure that hosts are monitored by a proxy group, not individual proxies (you may use host mass update to move hosts from proxies to the proxy group).
  4. Wait a few seconds for the configuration update and host distribution among proxies in the proxy group. Observe the change by refreshing the host list in Monitoring > Hosts.
限制
  • 在 proxy 组 中,proxies 不支持 SNMP traps。
  • 依赖于外部配置的检查必须在 proxy 组 中的所有 proxies 上具有相同的配置。这包括:
    • 外部检查 - 脚本;
    • 数据库检查 - ODBC 配置。
  • 使用“数据库监控”监控项时,数据库object/服务器必须具有扩展权限。
  • 在 proxy 组 中被监控时,VMware 主机 将随机分布在组内的 proxies 之间,并将导致每个 proxy 缓存所有 VMware 数据,从而增加 vCenter 的负载。