这是原厂英文文档的翻译页面. 欢迎帮助我们 完善文档.
2022 Zabbix中国峰会
2022 Zabbix中国峰会

1 Red Hat 企业版 Linux

Overview

Official Zabbix 6.3 PRE-RELEASE packages for Red Hat Enterprise Linux and Oracle Linux are available on Zabbix website. Packages for Zabbix 6.4 will be available upon its release.

Packages are available with either MySQL/PostgreSQL database and Apache/Nginx web server support.

Zabbix agent packages and utilities Zabbix get and Zabbix sender are available on Zabbix Official Repository for RHEL 9, RHEL 8, RHEL 7, and RHEL 6.

Zabbix Official Repository provides fping, iksemel and libssh2 packages as well. These packages are located in the non-supported directory.

Notes on installation

See installation instructions per platform in the download page for:

  • installing the repository
  • installing server/agent/frontend
  • creating initial database, importing initial data
  • configuring database for Zabbix server
  • configuring PHP for Zabbix frontend
  • starting server/agent processes
  • configuring Zabbix frontend

If you want to run Zabbix agent as root, see Running agent as root.

Zabbix web service process, which is used for scheduled report generation, requires Google Chrome browser. The browser is not included into packages and has to be installed manually.

使用时序数据库导入数据

使用 TimescaleDB,除了 PostgreSQL 的导入命令外,还需运行:

· # cat /usr/share/zabbix-sql-scripts/postgresql/timescaledb.sql | sudo -u zabbix psql zabbix

只有 Zabbix 服务器支持 TimescaleDB。

SELinux 配置

Zabbix 使用基于套接字的进程间通信。 在启用 SELinux 的系统上,可能需要添加 SELinux 规则以允许 Zabbix 在 SocketDir 目录中创建/使用 UNIX 域套接字。 当前套接字文件由服务器(告警器、预处理、IPMI)和代理(IPMI)使用。 套接字文件是持久的,这意味着它们在进程运行时存在。

在强制模式下启用 SELinux 状态后,您需要执行以下命令以启用 Zabbix 前端和服务器之间的通信:

RHEL 7 及更高版本:

· # setsebool -P httpd_can_connect_zabbix on · 如果可以通过网络访问数据库(包括 PostgreSQL 中的“localhost”),您也需要允许 Zabbix 前端连接到数据库: · # setsebool -P httpd_can_network_connect_db on

7 之前的 RHEL:

· # setsebool -P httpd_can_network_connect on · # setsebool -P zabbix_can_network on

前端和 SELinux 配置完成后,重启 Apache Web 服务器:

· # service httpd restart

In addition, Zabbix provides the zabbix-selinux-policy package as part of source RPM packages for RHEL 8 and RHEL 7. This package provides a basic default policy for SELinux and makes zabbix components work out-of-the-box by allowing Zabbix to create and use sockets and enabling httpd connection to PostgreSQL (used by frontend).

The source zabbix_policy.te file contains the following rules:

module zabbix_policy 1.2;
       
       require {
         type zabbix_t;
         type zabbix_port_t;
         type zabbix_var_run_t;
         type postgresql_port_t;
         type httpd_t;
         class tcp_socket name_connect;
         class sock_file { create unlink };
         class unix_stream_socket connectto;
       }
       
       #============= zabbix_t ==============
       allow zabbix_t self:unix_stream_socket connectto;
       allow zabbix_t zabbix_port_t:tcp_socket name_connect;
       allow zabbix_t zabbix_var_run_t:sock_file create;
       allow zabbix_t zabbix_var_run_t:sock_file unlink;
       allow httpd_t zabbix_port_t:tcp_socket name_connect;
       
       #============= httpd_t ==============
       allow httpd_t postgresql_port_t:tcp_socket name_connect;

This package has been created to prevent users from turning off SELinux because of the configuration complexity. It contains the default policy that is sufficient to speed up Zabbix deployment and configuration. For maximum security level, it is recommended to set custom SELinux settings.

代理安装

添加所需的存储库后,您可以通过运行以下命令安装 Zabbix 代理:

· # dnf install zabbix-proxy-mysql zabbix-sql-scripts

将命令中的“mysql”替换为“pgsql”以使用 PostgreSQL,或替换为“sqlite3”以使用 SQLite3(仅限代理)。

“zabbix-sql-scripts”包包含 Zabbix 服务器和 Zabbix 代理的所有支持的数据库管理系统的数据库模式,并将用于数据导入。

创建数据库

创建 Zabbix 代理的单独数据库。

Zabbix server 和 Zabbix proxy 不能使用同一个数据库。 如果它们安装在同一台主机上,则代理数据库必须具有不同的名称。

#####导入数据

导入初始schema:

· # cat /usr/share/zabbix-sql-scripts/mysql/proxy.sql | mysql -uzabbix -p zabbix

对于 PostgreSQL(或 SQLite)的代理:

· # cat /usr/share/zabbix-sql-scripts/postgresql/proxy.sql | sudo -u zabbix psql zabbix · # cat /usr/share/zabbix-sql-scripts/sqlite3/proxy.sql | sqlite3 zabbix.db

为 Zabbix 代理配置数据库

编辑 zabbix_proxy.conf:

· # vi /etc/zabbix/zabbix_proxy.conf · DBHost=localhost · DBName=zabbix · DBUser=zabbix · DBPassword=<password>

在 Zabbix 代理的 DBName 中,使用与 Zabbix 服务器不同的数据库。

在 DBPassword 中使用 MySQL 的 Zabbix 数据库密码; PostgreSQL 的 PostgreSQL 用户密码。

在 PostgreSQL 中使用 DBHost=。 您可能希望保留默认值设置 DBHost=localhost(或 IP 地址),但这会使PostgreSQL 使用网络套接字连接到 Zabbix。 有关说明,请参阅 SELinux 配置 (/manual/installation/install_from_packages/rhel#selinux_configuration)。

启动Zabbix代理进程

要启动 Zabbix 代理进程并使其在系统启动时启动:

· # service zabbix-proxy start · # systemctl enable zabbix-proxy

前端配置

Zabbix 代理没有前端; 它只与 Zabbix 服务器通信。

Java网关安装

只有在以下情况下才需要安装 Java 网关 您想要监视 JMX 应用程序。 Java网关是轻量级的,不需要数据库。

添加所需的存储库后,您可以通过运行以下命令安装 Zabbix Java 网关:

· # dnf install zabbix-java-gateway

继续 setup 了解有关配置和运行 Java 网关的更多详细信息。

Installing debuginfo packages

Debuginfo packages are currently available for RHEL versions 9, 7, 6 and 5.

To enable debuginfo repository, edit /etc/yum.repos.d/zabbix.repo file. Change enabled=0 to enabled=1 for zabbix-debuginfo repository.

[zabbix-debuginfo]
       name=Zabbix Official Repository debuginfo - $basearch
       baseurl=http://repo.zabbix.com/zabbix/6.4/rhel/7/$basearch/debuginfo/
       enabled=0
       gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
       gpgcheck=1

This will allow you to install the zabbix-debuginfo package.

# yum install zabbix-debuginfo

This single package contains debug information for all binary Zabbix components.