2022 Zabbix中国峰会
2022 Zabbix中国峰会

2 安装要求

硬件

内存和磁盘

Zabbix 运行需要物理内存和磁盘空间。如果刚接触 Zabbix,128 MB 的物理内存和 256 MB 的可用磁盘空间可能是一个很好的起点。 然而,所需的内存和磁盘空间显然取决于被监控的主机数量和配置参数。 如果您计划调整参数以保留较长的历史数据,那么您应该考虑至少有几 GB 磁盘空间,以便有足够的磁盘空间将历史数据存储在数据库中。

每个 Zabbix 守护程序进程都需要与数据库服务器建立多个连接。 为连接分配的内存量取决于数据库引擎的配置。

您拥有的物理内存越多,数据库(以及 Zabbix )的工作速度就越快!

CPU

Zabbix,尤其是 Zabbix 数据库可能需要大量 CPU 资源,该具体取决于被监控参数的数量和所选的数据库引擎。

其他硬件

如果需要启用短信(SMS)通知功能,需要串行通讯口(serial communication port)和串行GSM调制解调器(serial GSM modem)。USB转串行转接器也同样可以工作。

硬件资源配置参考

下表提供了几个硬件配置参考:

规模 平 CPU 内存 数据库 受监控的主机数量
小型 C ntOS V rtual Appliance M SQL InnoDB 1 0
中型 C ntOS 2 CPU cores/2GB M SQL InnoDB 5 0
大型 R dHat Enterprise Linux 4 CPU cores/8GB R ID10 MySQL InnoDB 或 PostgreSQL &g ;1000
极大型 Re Hat Enterprise Linux 8 PU cores/16GB Fa t RAID10 MySQL InnoDB 或 PostgreSQL &gt 10000

实际上,Zabbix 环境的配置非常依赖于监控项(主动)和更新间隔。 如果是进行大规模部署,强烈建议将数据库独立部署。

受支持的平台

由于服务器操作的安全性要求和任务关键性,UNIX 是唯一能够始终如一地提供必要性能、容错和弹性的操作系统。 Zabbix以市场主流的操作系统版本运行。

经测试,Zabbix 可以运行在下列平台:

  • Linux
  • IBM AIX
  • FreeBSD
  • NetBSD
  • OpenBSD
  • HP-UX
  • Mac OS X
  • Solaris
  • Windows:自 XP 以来的所有桌面和服务器版本(仅限 Zabbix agent)

Zabbix 可以在其他类 Unix 操作系统上运行。

如果使用加密编译,Zabbix将禁用核心转储(Core dumps),如果系统不允许禁用核心转储,则 Zabbix 不会启动。

软件

Zabbix 是基于先进 Apache Web 服务器、领先的数据库引擎和 PHP 脚本语言构建的。

数据库管理系统
数据库 版本 备注
MySQL 5.0.3 - 8.0.x 使用 MySQL 作为 Zabbix 后端数据库。需要InnoDB引擎。
MariaDB 同样支持。
Oracle 10g or later 使用 Oracle 作为 Zabbix 后端数据库。
PostgreSQL 8.1 or later 使用 PostgreSQL 作为 Zabbix 后端数据库。
建议使用 PostgreSQL 8.3 以上的版本, 以 提供更好的VACUUM性能
IBM DB2 9.7 or later 使用 DB2 作为 Zabbix 后端数据库。
SQLite 3.3.5 or later 只有 Zabbix proxy 支持 SQLite ,可以使用 SQLite 作为 Zabbix proxy 数据库。

值得注意的是,对于 IBM DB2 的支持是实验性的!

前端

Zabbix 前端需要使用下列软件:

软件 版 备注
Apache 1.3.12 或以上
PHP 5.4.0 或以上
PHP 扩展库:
gd 2.0 or later PHP GD 扩展库必须支持 PNG 图像(--with-png-dir)、JPEG 图像 (--with-jpeg-dir) 和 FreeType 2 (--with-freetype-dir).
bcmath php-bcmath (--enable-bcmath)
ctype php-ctype (--enable-ctype)
libXML 2.6.15 或以上 ph -xml or php5-dom,如果发布者提供独立的部署包。
xmlreader php-xmlreader,如果发布者提供独立的部署包。
xmlwriter php-xmlwriter,如果发布者提供独立的部署包。
session php-session,如果发布者提供独立的部署包。
sockets php-net-socket (--enable-sockets) 。用户脚本支持所需要的组件。
mbstring php-mbstring (--enable-mbstring)
gettext php-gettext (--with-gettext)。用于多语言翻译支持。
ldap php-ldap。只有在前端使用 LDAP 认证时才需要。
ibm_db2 使用 IBM DB2 作为 Zabbix 后端数据库所需要的组件。
mysqli 使用 MySQL 作为 Zabbix 后端数据库所需要的组件。
oci8 使用 Oracle 作为 Zabbix 后端数据库所需要的组件。
pgsql 使用 PostgreSQL 作为 Zabbix 后端数据库所需要的组件。

Zabbix 也许可以在以前的Apache、MySQL、Oracle 和 PostgreSQL 版本上运行。

值得注意的是,如果需要使用默认 DejaVu 以外的字体, 可能会需要 PHP 的 imagerotate 函数。如果缺少,则在 Zabbix 前端查看图形时显示异常。该函数只有在使用捆绑的 GD 库编译 PHP 时才可用。在 Debian 和某些发行版本中,这个问题不存在。

客户端浏览器

浏览器必须启用 Cookies 和 Java Script 。

支持最新版本的 Google、Mozilla Firefox、Microsoft Internet Explorer 和 Opero。其他浏览器(Apple Safari、Konqueror)也许会支持。

值得注意的,为了执行 IFrame 的“同源政策”,意味着 Zabbix 不能放在不同域的 frames 中。

但是,如果放置在 frames 中的页面和 Zabbix 前端位于同一个域中,则置于 Zabbix frames 中的页面将可以访问 Zabbix 前端(通过JavaScript)。像 http://secure-zabbix.com/cms/page.html 这样的页面,如果置于 http://secure-zabbix.com/zabbix/ 的聚合图形或仪表盘上,将拥有对 Zabbix 的完整 JS 访问权限。

Server

Mandatory requirements are needed always. Optional requirements are needed for the support of the specific function.

Requirement Status Description
libpcre Mandatory PCRE library is required for Perl Compatible Regular Expression (PCRE) support.
The naming may differ depending on the GNU/Linux distribution, for example 'libpcre3' or 'libpcre1'. Note that you need exactly PCRE (v8.x); PCRE2 (v10.x) library is not used.
libevent Required for bulk metric support and IPMI monitoring. Version 1.4 or higher.
Note that for Zabbix proxy this requirement is optional; it is needed for IPMI monitoring support.
libpthread Required for mutex and read-write lock support.
zlib Required for compression support.
OpenIPMI Optional Required for IPMI support.
libssh2 Required for SSH support. Version 1.0 or higher.
fping Required for ICMP ping items.
libcurl Required for web monitoring, VMware monitoring and SMTP authentication. For SMTP authentication, version 7.20.0 or higher is required. Also required for Elasticsearch.
libiksemel Required for Jabber support.
libxml2 Required for VMware monitoring.
net-snmp Required for SNMP support.
Java gateway

如果从源码存储库或归档中获取 Zabbix,则在源代码树中已包含必需的依赖关系。

如果从发行包中获取 Zabbix ,则封装系统里已提供了必要的依赖关系。

在上述两种情况下,即可准备部署软件了,而不需要下载额外的依赖包。

但是,如果您希望提供这些依赖关系的版本(例如,如果您正在为某些 Linux 发行版准备软件包),则下面是 Java gateway 已知可以使用的库的版本列表。 Zabbix 也许可以与这些库的其他版本一起使用。

下表列出了原始代码中当前与 Java gateway 捆绑在一起的 JAR 文件:

可 网站 备注
logback-core-0.9.27.jar EPL 1.0, LGPL 2.1 http://logback.qos.ch/ 0.9.27、1.0.13 和 1.1.1 测试通过。
logback-classic-0.9.27.jar EPL 1.0, LGPL 2.1 http://logback.qos.ch/ 0.9.27、1.0.13 和 1.1.1 测试通过。
slf4j-api-1.6.1.jar MIT License http://www.slf4j.org/ 1.6.1、1.6.6 和 1.7.6 测试通过
android-json-4.3_r3.1.jar Apache License 2.0 https://android.googlesource.com/platform/libcore/+/master/json 2.3.3_r1.1 和 4.3_r3.1 测试通过。关于创建 JAR 文件,详见 src/zabbix_java/lib/README 说明。

Java gateway 使用 Java 1.6 及更高版本编译和运行。 如需要对 Java gateway 预编译版本进行编译,建议使用Java 1.6进行编译,直到最新版本。

数据库容量

Zabbix 配置文件数据需要固定数量的磁盘空间,且增长不大。

Zabbix 数据库大小主要取决于这些变量,这些变量决定了存储的历史数据量:

  • 每秒处理值的数量

这是 Zabbix server 每秒接收的新值的平均数。 例如,如果有3000个监控项用于监控,取值间隔为60秒,则这个值的数量计算为 3000/60 = ** 50 **。

这意味着每秒有 50 个新值被添加到 Zabbix 数据库中。

  • 关于历史数据的管家设置

Zabbix 将接收到的值保存一段固定的时间,通常为几周或几个月。 每个新值都需要一定量的磁盘空间用于数据和索引。

所以,如果我们每秒收到 50 个值,且希望保留 30 天的历史数据,值的总数将大约在 (30*24*3600)* 50 = 129.600.000,即大约 130M 个值。

根据所使用的数据库引擎,接收值的类型(浮点数、整数、字符串、日志文件等),单个值的磁盘空间可能在 40 字节到数百字节之间变化。 通常,数值类型的每个值大约为 90 个字节。

在上面的例子中,这意味着 130M 个值需要占用 130M * 90 bytes = 10.9GB 磁盘空间。

文本和日志类型的监控项值的大小是无法确定的,但可以以每个值大约 500 字节来计算。

  • 趋势数据的管家设置

Zabbix 为表 trends 中的每个项目保留1小时的最大值 / 最小值 / 平均值 / 统计值。 该数据用于趋势图形和历史数据图形。 这一个小时的时间段是无法自定义。

Zabbix数据库,根据数据库类型,每个值总共需要大约90个字节。

假设我们希望将趋势数据保持5年。 3000 个监控项的值每年需要占用 3000*24*365* 90 = 2.2GB 空间,或者5年需要占用 11GB 空间。

  • 事件的管家设置

每个 Zabbix 事件需要大约 170 个字节的磁盘空间。 很难估计 Zabbix 每天生成的事件数量。 在最坏的情况下,假设 Zabbix 每秒生成一个事件。

这意味着如果想要保留3年的事件,这将需要占用 3*365*24*3600* 170 = 15GB 的空间。

下表包含可用于计算 Zabbix 系统所需磁盘空间的公式:

参数 所 磁盘空间的计算公式 (单位:字节)
Zabbix 配置文件 固定大 。通常为 10MB 或更少。
History days*(items/refresh rate)*24*3600*bytes
items:监控项数量。
days:保留历史数据的天数。
refresh rate:监控项的更新间隔。
bytes:保留单个值所需要占用的字节数,依赖于数据库引擎,通常为 ~90 字节。
Trends days*(items/3600)*24*3600*bytes
items:监控项数量。
days:保留历史数据的天数。
bytes:保留单个趋势数据所需要占用的字节数,依赖于数据库引擎,通常为 ~90 字节。
Events days*events*24*3600*bytes
events:每秒产生的事件数量。假设最糟糕的情况下,每秒产生 1 个事件。
days:保留历史数据的天数。
bytes:保留单个趋势数据所需的字节数,取决于数据库引擎,通常为 ~170 字节。

根据使用 MySQL 后端数据库的实际统计数据中收集到的平均值,例如监控项为数值类型的值约 90 个字节,事件约 170 个字节。

因此,所需要的磁盘总空间按下列方法计算:

配置文件数据+ 历史数据+ 趋势数据+ 事件数据

在安装 Zabbix 后不会立即使用磁盘空间。 数据库大小取决于管家设置,在某些时间点增长或停止增长。

时间同步

在运行 Zabbix 的服务器上拥有精确的系统日期非常重要。 ntpd 是最受欢迎的守护进程,它将主机的时间与其他服务器的时间同步。 对于所有运行 Zabbix 组件的系统,强烈建议这些系统的时间保持同步。

如果时间未同步,Zabbix将在建立数据连接之后,根据得到的客户端和服务器的时间戳,并通过客户端和服务器的时间差对获得值的时间戳进行调整,将获得值的时间戳转化为 Zabbix server 的时间。 为了尽可能简化并且避免可能的并发问题出现,网络延迟将会被忽略。因此,通过主动连接(active agent, active proxy, sender)获得的时间戳数据将包含网络延迟,通过被动连接(passive proxy)获得的数据已经减去了网络延迟。所有其他监控类型都在服务器时间里完成,并且不会调整其时间戳。

Database size

Zabbix configuration data require a fixed amount of disk space and do not grow much.

Zabbix database size mainly depends on these variables, which define the amount of stored historical data:

  • Number of processed values per second

This is the average number of new values Zabbix server receives every second. For example, if we have 3000 items for monitoring with a refresh rate of 60 seconds, the number of values per second is calculated as 3000/60 = 50.

It means that 50 new values are added to Zabbix database every second.

  • Housekeeper settings for history

Zabbix keeps values for a fixed period of time, normally several weeks or months. Each new value requires a certain amount of disk space for data and index.

So, if we would like to keep 30 days of history and we receive 50 values per second, the total number of values will be around (30*24*3600)* 50 = 129.600.000, or about 130M of values.

Depending on the database engine used, type of received values (floats, integers, strings, log files, etc), the disk space for keeping a single value may vary from 40 bytes to hundreds of bytes. Normally it is around 90 bytes per value for numeric items2. In our case, it means that 130M of values will require 130M * 90 bytes = 10.9GB of disk space.

The size of text/log item values is impossible to predict exactly, but you may expect around 500 bytes per value.

  • Housekeeper setting for trends

Zabbix keeps a 1-hour max/min/avg/count set of values for each item in the table trends. The data is used for trending and long period graphs. The one hour period can not be customized.

Zabbix database, depending on the database type, requires about 90 bytes per each total. Suppose we would like to keep trend data for 5 years. Values for 3000 items will require 3000*24*365* 90 = 2.2GB per year, or 11GB for 5 years.

  • Housekeeper settings for events

Each Zabbix event requires approximately 250 bytes of disk space1. It is hard to estimate the number of events generated by Zabbix daily. In the worst-case scenario, we may assume that Zabbix generates one event per second.

For each recovered event, an event_recovery record is created. Normally most of the events will be recovered so we can assume one event_recovery record per event. That means additional 80 bytes per event.

Optionally events can have tags, each tag record requiring approximately 100 bytes of disk space1. The number of tags per event (#tags) depends on configuration. So each will need an additional #tags * 100 bytes of disk space.

It means that if we want to keep 3 years of events, this would require 3*365*24*3600* (250+80+#tags*100) = ~30GB+#tags*100B disk space2.

1 More when having non-ASCII event names, tags and values.

2 The size approximations are based on MySQL and might be different for other databases.

The table contains formulas that can be used to calculate the disk space required for Zabbix system:

Parameter Formula for required disk space (in bytes)
Zabbix configuration Fixed size. Normally 10MB or less.
History days*(items/refresh rate)*24*3600*bytes
items : number of items
days : number of days to keep history
refresh rate : average refresh rate of items
bytes : number of bytes required to keep single value, depends on database engine, normally ~90 bytes.
Trends days*(items/3600)*24*3600*bytes
items : number of items
days : number of days to keep history
bytes : number of bytes required to keep single trend, depends on the database engine, normally ~90 bytes.
Events days*events*24*3600*bytes
events : number of event per second. One (1) event per second in worst-case scenario.
days : number of days to keep history
bytes : number of bytes required to keep single trend, depends on the database engine, normally ~330 + average number of tags per event * 100 bytes.

So, the total required disk space can be calculated as:
Configuration + History + Trends + Events
The disk space will NOT be used immediately after Zabbix installation. Database size will grow then it will stop growing at some point, which depends on housekeeper settings.

Time synchronization

It is very important to have precise system time on the server with Zabbix running. ntpd is the most popular daemon that synchronizes the host's time with the time of other machines. It's strongly recommended to maintain synchronized system time on all systems Zabbix components are running on.