3.3安装zabbix 前端
3.安装zabbix前端
zabbix前端主要用于配置zabbix配置管理,也是用户对zabbix进行操作的主要入口。用户可以通过它创建所需要监控的Host(主机)、Template(模板)、Item(监控项)。用户通过Dashboard(仪表盘)并结合其提供的小部件可以展示收集的监控数据及告警事件。
3.1 准备
这里将使用apache作为zabbix前端的web主机,在开始配置之前,需要保证zabbix server已经正常运行。
3.2 操作步骤
首先安装zabbix前端。
在Linux操作系统中,执行以下安装命令:
[root@zabbix ~]# dnf install -y zabbix-web-mysql zabbix-apache-conf
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Last metadata expiration check: 1:15:58 ago on Wed 06 Nov 2024 02:45:15 PM CST.
Dependencies resolved.
============================================================================================================================================================================================================
Package Architecture Version Repository Size
============================================================================================================================================================================================================
Installing:
zabbix-apache-conf noarch 6.0.35-release1.el8 zabbix 29 k
zabbix-web-mysql noarch 6.0.35-release1.el8 zabbix 28 k
Installing dependencies:
apr x86_64 1.6.3-12.el8 server1 130 k
apr-util x86_64 1.6.1-9.el8 server1 106 k
httpd x86_64 2.4.37-64.module+el8.10.0+21332+dfb1b40e server1 1.4 M
httpd-filesystem noarch 2.4.37-64.module+el8.10.0+21332+dfb1b40e server1 44 k
httpd-tools x86_64 2.4.37-64.module+el8.10.0+21332+dfb1b40e server1 111 k
mod_http2 x86_64 1.15.7-10.module+el8.10.0+21653+eaff63f0 server1 156 k
nginx-filesystem noarch 1:1.14.1-9.module+el8.0.0+4108+af250afe server1 24 k
php-bcmath x86_64 7.2.24-1.module+el8.2.0+4601+7c76a223 server1 79 k
php-common x86_64 7.2.24-1.module+el8.2.0+4601+7c76a223 server1 662 k
php-fpm x86_64 7.2.24-1.module+el8.2.0+4601+7c76a223 server1 1.6 M
php-gd x86_64 7.2.24-1.module+el8.2.0+4601+7c76a223 server1 84 k
php-json x86_64 7.2.24-1.module+el8.2.0+4601+7c76a223 server1 73 k
php-ldap x86_64 7.2.24-1.module+el8.2.0+4601+7c76a223 server1 79 k
php-mbstring x86_64 7.2.24-1.module+el8.2.0+4601+7c76a223 server1 580 k
php-mysqlnd x86_64 7.2.24-1.module+el8.2.0+4601+7c76a223 server1 191 k
php-pdo x86_64 7.2.24-1.module+el8.2.0+4601+7c76a223 server1 123 k
php-xml x86_64 7.2.24-1.module+el8.2.0+4601+7c76a223 server1 189 k
redhat-logos-httpd noarch 84.5-2.el8 server2 29 k
zabbix-web noarch 6.0.35-release1.el8 zabbix 8.3 M
zabbix-web-deps noarch 6.0.35-release1.el8 zabbix 29 k
Installing weak dependencies:
apr-util-bdb x86_64 1.6.1-9.el8 server1 25 k
apr-util-openssl x86_64 1.6.1-9.el8 server1 27 k
Enabling module streams:
httpd 2.4
nginx 1.14
php 7.2
Transaction Summary
============================================================================================================================================================================================================
Install 24 Packages
Total download size: 14 M
Installed size: 56 M
Downloading Packages:
(1/24): apr-util-bdb-1.6.1-9.el8.x86_64.rpm 4.8 MB/s | 25 kB 00:00
(2/24): apr-1.6.3-12.el8.x86_64.rpm 18 MB/s | 130 kB 00:00
(3/24): apr-util-openssl-1.6.1-9.el8.x86_64.rpm 11 MB/s | 27 kB 00:00
(4/24): apr-util-1.6.1-9.el8.x86_64.rpm 11 MB/s | 106 kB 00:00
(5/24): httpd-filesystem-2.4.37-64.module+el8.10.0+21332+dfb1b40e.noarch.rpm 6.5 MB/s | 44 kB 00:00
(6/24): httpd-tools-2.4.37-64.module+el8.10.0+21332+dfb1b40e.x86_64.rpm 14 MB/s | 111 kB 00:00
(7/24): nginx-filesystem-1.14.1-9.module+el8.0.0+4108+af250afe.noarch.rpm 13 MB/s | 24 kB 00:00
(8/24): mod_http2-1.15.7-10.module+el8.10.0+21653+eaff63f0.x86_64.rpm 22 MB/s | 156 kB 00:00
(9/24): php-bcmath-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64.rpm 19 MB/s | 79 kB 00:00
(10/24): php-common-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64.rpm 28 MB/s | 662 kB 00:00
(11/24): httpd-2.4.37-64.module+el8.10.0+21332+dfb1b40e.x86_64.rpm 29 MB/s | 1.4 MB 00:00
(12/24): php-gd-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64.rpm 7.0 MB/s | 84 kB 00:00
(13/24): php-json-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64.rpm 9.7 MB/s | 73 kB 00:00
(14/24): php-fpm-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64.rpm 33 MB/s | 1.6 MB 00:00
(15/24): php-ldap-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64.rpm 4.6 MB/s | 79 kB 00:00
(16/24): php-mysqlnd-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64.rpm 20 MB/s | 191 kB 00:00
(17/24): php-mbstring-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64.rpm 24 MB/s | 580 kB 00:00
(18/24): php-pdo-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64.rpm 8.4 MB/s | 123 kB 00:00
(19/24): php-xml-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64.rpm 21 MB/s | 189 kB 00:00
(20/24): redhat-logos-httpd-84.5-2.el8.noarch.rpm 4.4 MB/s | 29 kB 00:00
(21/24): zabbix-apache-conf-6.0.35-release1.el8.noarch.rpm 30 kB/s | 29 kB 00:00
(22/24): zabbix-web-deps-6.0.35-release1.el8.noarch.rpm 28 kB/s | 29 kB 00:01
(23/24): zabbix-web-mysql-6.0.35-release1.el8.noarch.rpm 148 kB/s | 28 kB 00:00
(24/24): zabbix-web-6.0.35-release1.el8.noarch.rpm 80 kB/s | 8.3 MB 01:46
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 136 kB/s | 14 MB 01:46
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : php-common-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 1/24
Installing : apr-1.6.3-12.el8.x86_64 2/24
Running scriptlet: apr-1.6.3-12.el8.x86_64 2/24
Installing : apr-util-bdb-1.6.1-9.el8.x86_64 3/24
Installing : apr-util-openssl-1.6.1-9.el8.x86_64 4/24
Installing : apr-util-1.6.1-9.el8.x86_64 5/24
Running scriptlet: apr-util-1.6.1-9.el8.x86_64 5/24
Installing : zabbix-web-6.0.35-release1.el8.noarch 6/24
Running scriptlet: zabbix-web-6.0.35-release1.el8.noarch 6/24
Running scriptlet: httpd-filesystem-2.4.37-64.module+el8.10.0+21332+dfb1b40e.noarch 7/24
Installing : httpd-filesystem-2.4.37-64.module+el8.10.0+21332+dfb1b40e.noarch 7/24
Installing : httpd-tools-2.4.37-64.module+el8.10.0+21332+dfb1b40e.x86_64 8/24
Installing : php-bcmath-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 9/24
Installing : php-gd-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 10/24
Installing : php-json-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 11/24
Installing : php-ldap-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 12/24
Installing : php-mbstring-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 13/24
Installing : php-pdo-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 14/24
Installing : php-mysqlnd-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 15/24
Installing : php-xml-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 16/24
Installing : redhat-logos-httpd-84.5-2.el8.noarch 17/24
Installing : mod_http2-1.15.7-10.module+el8.10.0+21653+eaff63f0.x86_64 18/24
Installing : httpd-2.4.37-64.module+el8.10.0+21332+dfb1b40e.x86_64 19/24
Running scriptlet: httpd-2.4.37-64.module+el8.10.0+21332+dfb1b40e.x86_64 19/24
Running scriptlet: nginx-filesystem-1:1.14.1-9.module+el8.0.0+4108+af250afe.noarch 20/24
Installing : nginx-filesystem-1:1.14.1-9.module+el8.0.0+4108+af250afe.noarch 20/24
Installing : php-fpm-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 21/24
Running scriptlet: php-fpm-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 21/24
Installing : zabbix-web-mysql-6.0.35-release1.el8.noarch 22/24
Installing : zabbix-web-deps-6.0.35-release1.el8.noarch 23/24
Installing : zabbix-apache-conf-6.0.35-release1.el8.noarch 24/24
Running scriptlet: zabbix-apache-conf-6.0.35-release1.el8.noarch 24/24
Running scriptlet: httpd-2.4.37-64.module+el8.10.0+21332+dfb1b40e.x86_64 24/24
Running scriptlet: zabbix-apache-conf-6.0.35-release1.el8.noarch 24/24
Running scriptlet: php-fpm-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 24/24
Verifying : apr-1.6.3-12.el8.x86_64 1/24
Verifying : apr-util-1.6.1-9.el8.x86_64 2/24
Verifying : apr-util-bdb-1.6.1-9.el8.x86_64 3/24
Verifying : apr-util-openssl-1.6.1-9.el8.x86_64 4/24
Verifying : httpd-2.4.37-64.module+el8.10.0+21332+dfb1b40e.x86_64 5/24
Verifying : httpd-filesystem-2.4.37-64.module+el8.10.0+21332+dfb1b40e.noarch 6/24
Verifying : httpd-tools-2.4.37-64.module+el8.10.0+21332+dfb1b40e.x86_64 7/24
Verifying : mod_http2-1.15.7-10.module+el8.10.0+21653+eaff63f0.x86_64 8/24
Verifying : nginx-filesystem-1:1.14.1-9.module+el8.0.0+4108+af250afe.noarch 9/24
Verifying : php-bcmath-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 10/24
Verifying : php-common-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 11/24
Verifying : php-fpm-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 12/24
Verifying : php-gd-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 13/24
Verifying : php-json-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 14/24
Verifying : php-ldap-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 15/24
Verifying : php-mbstring-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 16/24
Verifying : php-mysqlnd-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 17/24
Verifying : php-pdo-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 18/24
Verifying : php-xml-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 19/24
Verifying : redhat-logos-httpd-84.5-2.el8.noarch 20/24
Verifying : zabbix-apache-conf-6.0.35-release1.el8.noarch 21/24
Verifying : zabbix-web-6.0.35-release1.el8.noarch 22/24
Verifying : zabbix-web-deps-6.0.35-release1.el8.noarch 23/24
Verifying : zabbix-web-mysql-6.0.35-release1.el8.noarch 24/24
Installed products updated.
Installed:
apr-1.6.3-12.el8.x86_64 apr-util-1.6.1-9.el8.x86_64 apr-util-bdb-1.6.1-9.el8.x86_64
apr-util-openssl-1.6.1-9.el8.x86_64 httpd-2.4.37-64.module+el8.10.0+21332+dfb1b40e.x86_64 httpd-filesystem-2.4.37-64.module+el8.10.0+21332+dfb1b40e.noarch
httpd-tools-2.4.37-64.module+el8.10.0+21332+dfb1b40e.x86_64 mod_http2-1.15.7-10.module+el8.10.0+21653+eaff63f0.x86_64 nginx-filesystem-1:1.14.1-9.module+el8.0.0+4108+af250afe.noarch
php-bcmath-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 php-common-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 php-fpm-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64
php-gd-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 php-json-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 php-ldap-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64
php-mbstring-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 php-mysqlnd-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 php-pdo-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64
php-xml-7.2.24-1.module+el8.2.0+4601+7c76a223.x86_64 redhat-logos-httpd-84.5-2.el8.noarch zabbix-apache-conf-6.0.35-release1.el8.noarch
zabbix-web-6.0.35-release1.el8.noarch zabbix-web-deps-6.0.35-release1.el8.noarch zabbix-web-mysql-6.0.35-release1.el8.noarch
Complete!
[root@zabbix ~]#
提示
如果你的主机开启了防火墙,请不要忘记配置防火墙允许80和443端口访问,否则将无法连接到zabbix前端。
3.3 启动zabbix组件
然后,启动zabbix组件,并配置开机启动服务。
在Linux操作系统中,执行以下启动命令:
[root@zabbix ~]# systemctl enable httpd php-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
[root@zabbix ~]#
[root@zabbix ~]# systemctl restart zabbix-server httpd php-fpm
在执行完以上操作后,需要对zabbix前端进行初始化配置。
在游览器中输入zabbix server在主机的IP地址,例如:
在正常情况下,应该可以看到如图所示的页面,此页面为zabbix初始化配置页面。
如果没有看到此页面,那么可能是因为操作步骤出现了问题。你需要回溯操作步骤并仔细检查配置文件,即使最小的拼写错误也可能导致页面无法访问。
单机“Next step”按钮,打开如图1.3所示的页面。这里的每一项都应该显示“ok”,如果有选项显示为“NO”,那么请按照提示修改配置文件或安装缺失的扩展文件。在选项都显示为“ok”以后,可以单机“Next step”按钮,打开如图1.4所示的页面.
在这里,配置的是zabbix前端需要连接的数据库。由于zabbix和数据库安装在同一台机器上,所以在“database host”字段中填写“localhost”(本机)即可。如果数据库安装在另外一台主机上,那么在“database host”字段中填写数据库的IP地址。然后,填写连接数据库的端口,“database port”字段中的“0”表示使用默认端口。最后,填写需要连接数据库的名称,以及用户名和密码。
需要说明的是,zabbix server和zabbix前端属于可以拆分的2个组件,所以zabbix_server.conf文件里配置的是zabbix server连接数据库的配置信息,zabbix前端配置向导主要用于zabbix前端连接数据库的。在以上步骤完整之后,单击“next step”按钮打开如图1.5所示的页面。
在这里可以为zabbix server命名,并挑选一个喜欢的页面主题。这里直接配置zabbix,并配置当前所在的时区,选择的是东八区asia/shanghai。然后,单机“next step”按钮。
核实zabbix安装摘要信息中的配置,在确认无误后单击“next step”按钮,如图1.6所示。
恭喜,zabbix前端安装已经完成,如图1.7所示。
单机“完成”按钮,打开zabbix登入界面,使用下面默认的用户名和密码登入:
3.4 工作原理
现在zabbix server和zabbix前端已经安装并部署完成,在开始之前,再花一点时间了解一下核心组件之间的通信,如图1.9所示。
不难发现,zabbix前端负责监控的配置和管理,以及监控数据的展示。zabbix server则负责根据配置信息进行数据采集。zabbix前端还负责对zabbix server进行健康状态检测。现在就可以开始使用zabbix了。
zabbix官方文档提供了非常简单的安装指南,其中包括了关于安装的大量细节,建议在安装zabbix的时候详细查看官方文档。