Zabbix5.0监控系统安装详解
一、Zabbix介绍
1.zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
2.zabbix由2部分构成,zabbix server与可选组件zabbix agent。
二、Zbbix的LAMP环境安装
1.防火墙和SElinux配置
[root@tianyi ~]# firewall-cmd --permanent --add-port=10051/tcp
success
[root@tianyi ~]# firewall-cmd --permanent --add-port=80/tcp
success
[root@tianyi ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
[root@tianyi ~]# grep SELINUX /etc/selinux/config
# SELINUX= can take one of these three values:
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
SELINUXTYPE=targeted
[root@tianyi ~]# setenforce 0
setenforce: SELinux is disabled
[root@tianyi ~]# getenforce
Disabled
2.安装LAMP环境
①安装Mysql数据库
[root@tianyi yum.repos.d]# yum -y install mysql mysql-server.x86_64
Repository AppStream is listed more than once in the configuration
Repository BaseOS is listed more than once in the configuration
CentOS-8 - AppStream 2.3 MB/s | 4.3 kB 00:00
CentOS-8 - Base 3.8 MB/s | 3.9 kB 00:00
CentOS-8 - PowerTools 4.2 MB/s | 4.3 kB 00:00
CentOS-8 - Extras 1.5 MB/s | 1.5 kB 00:00
Zabbix 12 kB/s | 131 kB 00:11
Dependencies resolved.
====================================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================================
Installing:
mysql x86_64 8.0.17-3.module_el8.0.0+181+899d6349 AppStream 11 M
mysql-server x86_64 8.0.17-3.module_el8.0.0+181+899d6349 AppStream 22 M
Installing dependencies:
mariadb-connector-c-config noarch 3.0.7-1.el8 AppStream 13 k
mecab x86_64 0.996-1.module_el8.0.0+41+ca30bab6.9 AppStream 397 k
mysql-common x86_64 8.0.17-3.module_el8.0.0+181+899d6349 AppStream 143 k
mysql-errmsg x86_64 8.0.17-3.module_el8.0.0+181+899d6349 AppStream 557 k
protobuf-lite x86_64 3.5.0-7.el8 AppStream 150 k
Enabling module streams:
mysql 8.0
Transaction Summary
====================================================================================================================================================================================
Install 7 Packages
Total download size: 33 M
Installed size: 216 M
Downloading Packages:
(1/7): mariadb-connector-c-config-3.0.7-1.el8.noarch.rpm 115 kB/s | 13 kB 00:00
(2/7): mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64.rpm 834 kB/s | 397 kB 00:00
(3/7): mysql-common-8.0.17-3.module_el8.0.0+181+899d6349.x86_64.rpm 395 kB/s | 143 kB 00:00
(4/7): mysql-errmsg-8.0.17-3.module_el8.0.0+181+899d6349.x86_64.rpm 838 kB/s | 557 kB 00:00
(5/7): protobuf-lite-3.5.0-7.el8.x86_64.rpm 409 kB/s | 150 kB 00:00
(6/7): mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64.rpm 5.8 MB/s | 11 MB 00:01
(7/7): mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86_64.rpm 10 MB/s | 22 MB 00:02
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 13 MB/s | 33 MB 00:02
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : mariadb-connector-c-config-3.0.7-1.el8.noarch 1/7
Installing : mysql-common-8.0.17-3.module_el8.0.0+181+899d6349.x86_64 2/7
Installing : mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64 3/7
Installing : mysql-errmsg-8.0.17-3.module_el8.0.0+181+899d6349.x86_64 4/7
Installing : protobuf-lite-3.5.0-7.el8.x86_64 5/7
Installing : mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64 6/7
Running scriptlet: mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64 6/7
Running scriptlet: mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86_64 7/7
Installing : mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86_64 7/7
Running scriptlet: mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86_64 7/7
ValueError: File context for /var/log/mysql(/.*)? already defined
Verifying : mariadb-connector-c-config-3.0.7-1.el8.noarch 1/7
Verifying : mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64 2/7
Verifying : mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64 3/7
Verifying : mysql-common-8.0.17-3.module_el8.0.0+181+899d6349.x86_64 4/7
Verifying : mysql-errmsg-8.0.17-3.module_el8.0.0+181+899d6349.x86_64 5/7
Verifying : mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86_64 6/7
Verifying : protobuf-lite-3.5.0-7.el8.x86_64 7/7
Installed:
mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64 mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86_64 mariadb-connector-c-config-3.0.7-1.el8.noarch
mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64 mysql-common-8.0.17-3.module_el8.0.0+181+899d6349.x86_64 mysql-errmsg-8.0.17-3.module_el8.0.0+181+899d6349.x86_64
protobuf-lite-3.5.0-7.el8.x86_64
Complete!
[root@tianyi yum.repos.d]#
[root@tianyi yum.repos.d]# yum list installed |grep mysql
Repository AppStream is listed more than once in the configuration
Repository BaseOS is listed more than once in the configuration
mysql.x86_64 8.0.17-3.module_el8.0.0+181+899d6349 @AppStream
mysql-common.x86_64 8.0.17-3.module_el8.0.0+181+899d6349 @AppStream
mysql-errmsg.x86_64 8.0.17-3.module_el8.0.0+181+899d6349 @AppStream
mysql-server.x86_64 8.0.17-3.module_el8.0.0+181+899d6349 @AppStream
②安装php相关软件包
[root@tianyi yum.repos.d]# yum -y install php-mysqlnd.x86_64 php-gd.x86_64 php-ldap.x86_64 php-odbc.x86_64 php-pear.noarch php-xml php-xmlrpc.x86_64 php-bcmath.x86_64 php-mbstring.x86_64
Last metadata expiration check: 0:12:44 ago on Thu 06 May 2021 09:29:36 PM CST.
Dependencies resolved.
======================================================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================================================
Installing:
php-bcmath x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream 79 k
php-gd x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream 84 k
php-ldap x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream 79 k
php-mbstring x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream 580 k
php-mysqlnd x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream 190 k
php-odbc x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream 88 k
php-pear noarch 1:1.10.5-9.module_el8.2.0+313+b04d0a66 AppStream 358 k
php-xml x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream 188 k
php-xmlrpc x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream 89 k
Installing dependencies:
php-cli x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream 3.1 M
php-common x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream 661 k
php-pdo x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream 122 k
php-process x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream 84 k
unixODBC x86_64 2.3.7-1.el8 AppStream 458 k
Enabling module streams:
php 7.2
Transaction Summary
======================================================================================================================================================================================
Install 14 Packages
Total download size: 6.1 M
Installed size: 23 M
Downloading Packages:
(1/14): php-bcmath-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64.rpm 15 kB/s | 79 kB 00:05
(2/14): php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64.rpm 124 kB/s | 661 kB 00:05
(3/14): php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64.rpm 635 kB/s | 84 kB 00:00
(4/14): php-cli-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64.rpm 569 kB/s | 3.1 MB 00:05
(5/14): php-ldap-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64.rpm 331 kB/s | 79 kB 00:00
(6/14): php-mbstring-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64.rpm 1.5 MB/s | 580 kB 00:00
(7/14): php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64.rpm 909 kB/s | 190 kB 00:00
(8/14): php-odbc-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64.rpm 249 kB/s | 88 kB 00:00
(9/14): php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64.rpm 481 kB/s | 122 kB 00:00
(10/14): php-pear-1.10.5-9.module_el8.2.0+313+b04d0a66.noarch.rpm 921 kB/s | 358 kB 00:00
(11/14): php-process-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64.rpm 282 kB/s | 84 kB 00:00
(12/14): php-xml-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64.rpm 622 kB/s | 188 kB 00:00
(13/14): unixODBC-2.3.7-1.el8.x86_64.rpm 2.5 MB/s | 458 kB 00:00
(14/14): php-xmlrpc-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64.rpm 377 kB/s | 89 kB 00:00
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 971 kB/s | 6.1 MB 00:06
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+313+b04d0a66.x86_64 1/14
Installing : php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 2/14
Installing : php-xml-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 3/14
Installing : php-cli-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 4/14
Installing : php-process-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 5/14
Installing : unixODBC-2.3.7-1.el8.x86_64 6/14
Running scriptlet: unixODBC-2.3.7-1.el8.x86_64 6/14
Installing : php-odbc-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 7/14
Installing : php-pear-1:1.10.5-9.module_el8.2.0+313+b04d0a66.noarch 8/14
Installing : php-xmlrpc-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 9/14
Installing : php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 10/14
Installing : php-bcmath-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 11/14
Installing : php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 12/14
Installing : php-ldap-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 13/14
Installing : php-mbstring-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 14/14
Running scriptlet: php-mbstring-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 14/14
Verifying : php-bcmath-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 1/14
Verifying : php-cli-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 2/14
Verifying : php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 3/14
Verifying : php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 4/14
Verifying : php-ldap-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 5/14
Verifying : php-mbstring-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 6/14
Verifying : php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 7/14
Verifying : php-odbc-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 8/14
Verifying : php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 9/14
Verifying : php-pear-1:1.10.5-9.module_el8.2.0+313+b04d0a66.noarch 10/14
Verifying : php-process-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 11/14
Verifying : php-xml-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 12/14
Verifying : php-xmlrpc-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 13/14
Verifying : unixODBC-2.3.7-1.el8.x86_64 14/14
Installed:
php-bcmath-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-ldap-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-mbstring-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-odbc-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-pear-1:1.10.5-9.module_el8.2.0+313+b04d0a66.noarch php-xml-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-xmlrpc-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-cli-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-process-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 unixODBC-2.3.7-1.el8.x86_64
Complete!
③安装apache
[root@tianyi yum.repos.d]# yum -y install httpd
Last metadata expiration check: 0:13:50 ago on Thu 06 May 2021 09:29:36 PM CST.
Package httpd-2.4.37-21.module_el8.2.0+382+15b0afa8.x86_64 is already installed.
Dependencies resolved.
======================================================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================================================
Upgrading:
httpd x86_64 2.4.37-30.module_el8.3.0+561+97fdbbcc AppStream 1.7 M
httpd-filesystem noarch 2.4.37-30.module_el8.3.0+561+97fdbbcc AppStream 37 k
httpd-tools x86_64 2.4.37-30.module_el8.3.0+561+97fdbbcc AppStream 104 k
Transaction Summary
======================================================================================================================================================================================
Upgrade 3 Packages
Total download size: 1.8 M
Downloading Packages:
(1/3): httpd-tools-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64.rpm 20 kB/s | 104 kB 00:05
(2/3): httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64.rpm 325 kB/s | 1.7 MB 00:05
(3/3): httpd-filesystem-2.4.37-30.module_el8.3.0+561+97fdbbcc.noarch.rpm 7.0 kB/s | 37 kB 00:05
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 351 kB/s | 1.8 MB 00:05
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: httpd-tools-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64 1/1
Upgrading : httpd-tools-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64 1/6
Running scriptlet: httpd-filesystem-2.4.37-30.module_el8.3.0+561+97fdbbcc.noarch 2/6
Upgrading : httpd-filesystem-2.4.37-30.module_el8.3.0+561+97fdbbcc.noarch 2/6
Upgrading : httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64 3/6
Running scriptlet: httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64 3/6
Running scriptlet: httpd-2.4.37-21.module_el8.2.0+382+15b0afa8.x86_64 4/6
Cleanup : httpd-2.4.37-21.module_el8.2.0+382+15b0afa8.x86_64 4/6
Running scriptlet: httpd-2.4.37-21.module_el8.2.0+382+15b0afa8.x86_64 4/6
Cleanup : httpd-filesystem-2.4.37-21.module_el8.2.0+382+15b0afa8.noarch 5/6
Cleanup : httpd-tools-2.4.37-21.module_el8.2.0+382+15b0afa8.x86_64 6/6
Running scriptlet: httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64 6/6
Running scriptlet: httpd-tools-2.4.37-21.module_el8.2.0+382+15b0afa8.x86_64 6/6
Verifying : httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64 1/6
Verifying : httpd-2.4.37-21.module_el8.2.0+382+15b0afa8.x86_64 2/6
Verifying : httpd-filesystem-2.4.37-30.module_el8.3.0+561+97fdbbcc.noarch 3/6
Verifying : httpd-filesystem-2.4.37-21.module_el8.2.0+382+15b0afa8.noarch 4/6
Verifying : httpd-tools-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64 5/6
Verifying : httpd-tools-2.4.37-21.module_el8.2.0+382+15b0afa8.x86_64 6/6
Upgraded:
httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64 httpd-filesystem-2.4.37-30.module_el8.3.0+561+97fdbbcc.noarch httpd-tools-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64
Complete!
三、安装Zabbix软件
[root@tianyi yum.repos.d]# yum -y install zabbix-server-mysql.x86_64 zabbix-web-mysql.noarch zabbix-agent zabbix-get.x86_64
Last metadata expiration check: 0:17:19 ago on Thu 06 May 2021 09:29:36 PM CST.
Dependencies resolved.
======================================================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================================================
Installing:
zabbix-agent x86_64 5.0.11-1.el8 zabbix 470 k
zabbix-get x86_64 5.0.11-1.el8 zabbix 331 k
zabbix-server-mysql x86_64 5.0.11-1.el8 zabbix 3.0 M
zabbix-web-mysql noarch 5.0.11-1.el8 zabbix 17 k
Upgrading:
mariadb-connector-c-config noarch 3.1.11-2.el8_3 AppStream 15 k
Installing dependencies:
mariadb-connector-c x86_64 3.1.11-2.el8_3 AppStream 200 k
php-fpm x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream 1.6 M
php-json x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream 73 k
OpenIPMI-libs x86_64 2.0.27-1.el8 BaseOS 507 k
dejavu-fonts-common noarch 2.35-6.el8 BaseOS 74 k
dejavu-sans-fonts noarch 2.35-6.el8 BaseOS 1.5 M
net-snmp-libs x86_64 1:5.8-18.el8_3.1 BaseOS 824 k
zabbix-web noarch 5.0.11-1.el8 zabbix 3.2 M
zabbix-web-deps x86_64 5.0.11-1.el8 zabbix 19 k
Transaction Summary
======================================================================================================================================================================================
Install 13 Packages
Upgrade 1 Package
Total download size: 12 M
Downloading Packages:
(1/14): mariadb-connector-c-3.1.11-2.el8_3.x86_64.rpm 38 kB/s | 200 kB 00:05
(2/14): php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64.rpm 14 kB/s | 73 kB 00:05
(3/14): dejavu-fonts-common-2.35-6.el8.noarch.rpm 1.5 MB/s | 74 kB 00:00
(4/14): OpenIPMI-libs-2.0.27-1.el8.x86_64.rpm 4.2 MB/s | 507 kB 00:00
(5/14): php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64.rpm 307 kB/s | 1.6 MB 00:05
(6/14): net-snmp-libs-5.8-18.el8_3.1.x86_64.rpm 11 MB/s | 824 kB 00:00
(7/14): dejavu-sans-fonts-2.35-6.el8.noarch.rpm 7.7 MB/s | 1.5 MB 00:00
(8/14): zabbix-agent-5.0.11-1.el8.x86_64.rpm 1.6 MB/s | 470 kB 00:00
(9/14): zabbix-get-5.0.11-1.el8.x86_64.rpm 914 kB/s | 331 kB 00:00
(10/14): zabbix-server-mysql-5.0.11-1.el8.x86_64.rpm 5.9 MB/s | 3.0 MB 00:00
(11/14): zabbix-web-deps-5.0.11-1.el8.x86_64.rpm 72 kB/s | 19 kB 00:00
(12/14): mariadb-connector-c-config-3.1.11-2.el8_3.noarch.rpm 310 kB/s | 15 kB 00:00
(13/14): zabbix-web-5.0.11-1.el8.noarch.rpm 5.9 MB/s | 3.2 MB 00:00
(14/14): zabbix-web-mysql-5.0.11-1.el8.noarch.rpm 96 kB/s | 17 kB 00:00
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.9 MB/s | 12 MB 00:06
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Upgrading : mariadb-connector-c-config-3.1.11-2.el8_3.noarch 1/15
Installing : mariadb-connector-c-3.1.11-2.el8_3.x86_64 2/15
Installing : net-snmp-libs-1:5.8-18.el8_3.1.x86_64 3/15
Installing : dejavu-fonts-common-2.35-6.el8.noarch 4/15
Installing : dejavu-sans-fonts-2.35-6.el8.noarch 5/15
Installing : zabbix-web-5.0.11-1.el8.noarch 6/15
Running scriptlet: zabbix-web-5.0.11-1.el8.noarch 6/15
Installing : OpenIPMI-libs-2.0.27-1.el8.x86_64 7/15
Installing : php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 8/15
Installing : php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 9/15
Running scriptlet: php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 9/15
Installing : zabbix-web-mysql-5.0.11-1.el8.noarch 10/15
Installing : zabbix-web-deps-5.0.11-1.el8.x86_64 11/15
Running scriptlet: zabbix-server-mysql-5.0.11-1.el8.x86_64 12/15
Installing : zabbix-server-mysql-5.0.11-1.el8.x86_64 12/15
Running scriptlet: zabbix-server-mysql-5.0.11-1.el8.x86_64 12/15
Installing : zabbix-get-5.0.11-1.el8.x86_64 13/15
Running scriptlet: zabbix-agent-5.0.11-1.el8.x86_64 14/15
Installing : zabbix-agent-5.0.11-1.el8.x86_64 14/15
Running scriptlet: zabbix-agent-5.0.11-1.el8.x86_64 14/15
Cleanup : mariadb-connector-c-config-3.0.7-1.el8.noarch 15/15
Running scriptlet: zabbix-agent-5.0.11-1.el8.x86_64 15/15
Running scriptlet: mariadb-connector-c-config-3.0.7-1.el8.noarch 15/15
Running scriptlet: php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 15/15
Verifying : mariadb-connector-c-3.1.11-2.el8_3.x86_64 1/15
Verifying : php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 2/15
Verifying : php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 3/15
Verifying : OpenIPMI-libs-2.0.27-1.el8.x86_64 4/15
Verifying : dejavu-fonts-common-2.35-6.el8.noarch 5/15
Verifying : dejavu-sans-fonts-2.35-6.el8.noarch 6/15
Verifying : net-snmp-libs-1:5.8-18.el8_3.1.x86_64 7/15
Verifying : zabbix-agent-5.0.11-1.el8.x86_64 8/15
Verifying : zabbix-get-5.0.11-1.el8.x86_64 9/15
Verifying : zabbix-server-mysql-5.0.11-1.el8.x86_64 10/15
Verifying : zabbix-web-5.0.11-1.el8.noarch 11/15
Verifying : zabbix-web-deps-5.0.11-1.el8.x86_64 12/15
Verifying : zabbix-web-mysql-5.0.11-1.el8.noarch 13/15
Verifying : mariadb-connector-c-config-3.1.11-2.el8_3.noarch 14/15
Verifying : mariadb-connector-c-config-3.0.7-1.el8.noarch 15/15
Upgraded:
mariadb-connector-c-config-3.1.11-2.el8_3.noarch
Installed:
zabbix-agent-5.0.11-1.el8.x86_64 zabbix-get-5.0.11-1.el8.x86_64 zabbix-server-mysql-5.0.11-1.el8.x86_64
zabbix-web-mysql-5.0.11-1.el8.noarch mariadb-connector-c-3.1.11-2.el8_3.x86_64 php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 OpenIPMI-libs-2.0.27-1.el8.x86_64 dejavu-fonts-common-2.35-6.el8.noarch
dejavu-sans-fonts-2.35-6.el8.noarch net-snmp-libs-1:5.8-18.el8_3.1.x86_64 zabbix-web-5.0.11-1.el8.noarch
zabbix-web-deps-5.0.11-1.el8.x86_64
Complete!
四、Zabbix的Mysql数据库配置
1.Mysql数据库配置文件修改
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
character-set-server=utf8
innodb_file_per_table=1
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
2.设置mysql启动
[root@tianyi yum.repos.d]# systemctl enable --now mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
3.登录mysql设置zabbix账户
①设置mysql密码策略
[root@tianyi yum.repos.d]#
[root@tianyi yum.repos.d]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.0.21 Source distribution
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'admin';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 8 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | MEDIUM |
| validate_password.special_char_count | 1 |
+--------------------------------------+--------+
7 rows in set (0.01 sec)
mysql> set global validate_password.policy=LOW;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password.length=5;
Query OK, 0 rows affected (0.00 sec)
②设置r数据库root密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'admin';
Query OK, 0 rows affected (0.04 sec)
③修改数据库字符集,并授权新建zabbix
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected, 2 warnings (0.01 sec)
mysql> create user zabbix@localhost identified by 'admin' ;
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
4.使用数据库zabbix账户导入数据库模式和数据
[root@tianyi yum.repos.d]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz |mysql -uzabbix -p zabbix
Enter password:
5.查看mysql中相关zabbix信息
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| zabbix |
+--------------------+
5 rows in set (0.00 sec)
mysql> use zabbix;
Database changed
mysql> show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| config_autoreg_tls |
| corr_condition |
| corr_condition_group |
| corr_condition_tag |
| corr_condition_tagpair |
| corr_condition_tagvalue |
| corr_operation |
| correlation |
| dashboard |
| dashboard_user |
| dashboard_usrgrp |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| event_recovery |
| event_suppress |
| event_tag |
| events |
| expressions |
| functions |
| globalmacro |
| globalvars |
| graph_discovery |
| graph_theme |
| graphs |
| graphs_items |
| group_discovery |
| group_prototype |
| history |
| history_log |
| history_str |
| history_text |
| history_uint |
| host_discovery |
| host_inventory |
| host_tag |
| hostmacro |
| hosts |
| hosts_groups |
| hosts_templates |
| housekeeper |
| hstgrp |
| httpstep |
| httpstep_field |
| httpstepitem |
| httptest |
| httptest_field |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| interface_snmp |
| item_application_prototype |
| item_condition |
| item_discovery |
| item_preproc |
| item_rtdata |
| items |
| items_applications |
| lld_macro_path |
| lld_override |
| lld_override_condition |
| lld_override_opdiscover |
| lld_override_operation |
| lld_override_ophistory |
| lld_override_opinventory |
| lld_override_opperiod |
| lld_override_opseverity |
| lld_override_opstatus |
| lld_override_optag |
| lld_override_optemplate |
| lld_override_optrends |
| maintenance_tag |
| maintenances |
| maintenances_groups |
| maintenances_hosts |
| maintenances_windows |
| mappings |
| media |
| media_type |
| media_type_message |
| media_type_param |
| module |
| opcommand |
| opcommand_grp |
| opcommand_hst |
| opconditions |
| operations |
| opgroup |
| opinventory |
| opmessage |
| opmessage_grp |
| opmessage_usr |
| optemplate |
| problem |
| problem_tag |
| profiles |
| proxy_autoreg_host |
| proxy_dhistory |
| proxy_history |
| regexps |
| rights |
| screen_user |
| screen_usrgrp |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshow_user |
| slideshow_usrgrp |
| slideshows |
| sysmap_element_trigger |
| sysmap_element_url |
| sysmap_shape |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_elements |
| sysmaps_link_triggers |
| sysmaps_links |
| tag_filter |
| task |
| task_acknowledge |
| task_check_now |
| task_close_problem |
| task_data |
| task_remote_command |
| task_remote_command_result |
| task_result |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| trigger_tag |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemaps |
| widget |
| widget_field |
+----------------------------+
166 rows in set (0.00 sec)
五、Zabbix的各相关服务配置文件修改
1.修改php配置文件
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Shanghai
2.修改zabbix-server配置文件
DBUser=zabbix
### Option: DBPassword
# Database password.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=admin
六、启动所有zabbix相关服务
[root@tianyi yum.repos.d]# systemctl enable --now zabbix-server.service zabbix-agent.service httpd php-fpm.service
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service → /usr/lib/systemd/system/zabbix-server.service.
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent.service → /usr/lib/systemd/system/zabbix-agent.service.
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@tianyi yum.repos.d]# systemctl restart zabbix-server.service zabbix-agent.service httpd php-fpm.service
七、检查安装好的环境是否正常
1.检查10051端口运行情况
[root@tianyi yum.repos.d]# netstat -tunlp |grep 100
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 18644/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 18642/zabbix_server
tcp6 0 0 :::10050 :::* LISTEN 18644/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 18642/zabbix_server
2.查看httpd是否启动
[root@tianyi yum.repos.d]# ps -ef |grep httpd
root 18728 1 0 22:47 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 18742 18728 0 22:48 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 18743 18728 0 22:48 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 18744 18728 0 22:48 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 18745 18728 0 22:48 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 19009 8509 0 22:49 pts/1 00:00:00 grep --color=auto httpd
3.查看zabbix进程
[root@tianyi yum.repos.d]# ps -ef |grep zabbix_server
zabbix 18642 1 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
zabbix 18653 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: configuration syncer [synced configuration in 0.024267 sec, idle 60 sec]
zabbix 18658 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes]
zabbix 18659 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: timer #1 [updated 0 hosts, suppressed 0 events in 0.000514 sec, idle 59 sec]
zabbix 18660 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.000451 sec, idle 5 sec]
zabbix 18661 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.000399 sec, idle 60 sec]
zabbix 18662 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: history syncer #1 [processed 0 values, 0 triggers in 0.000040 sec, idle 1 sec]
zabbix 18663 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: history syncer #2 [processed 3 values, 2 triggers in 0.005546 sec, idle 1 sec]
zabbix 18664 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: history syncer #3 [processed 0 values, 0 triggers in 0.000007 sec, idle 1 sec]
zabbix 18665 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: history syncer #4 [processed 0 values, 0 triggers in 0.000009 sec, idle 1 sec]
zabbix 18666 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.000645 sec, idle 3 sec]
zabbix 18667 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000023 sec, idle 5 sec]
zabbix 18668 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: self-monitoring [processed data in 0.000023 sec, idle 1 sec]
zabbix 18669 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: task manager [processed 0 task(s) in 0.000326 sec, idle 5 sec]
zabbix 18670 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: poller #1 [got 0 values in 0.000005 sec, idle 1 sec]
zabbix 18671 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: poller #2 [got 3 values in 0.000090 sec, idle 1 sec]
zabbix 18672 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: poller #3 [got 0 values in 0.000007 sec, idle 1 sec]
zabbix 18673 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: poller #4 [got 0 values in 0.000015 sec, idle 1 sec]
zabbix 18674 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: poller #5 [got 0 values in 0.000038 sec, idle 1 sec]
zabbix 18675 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000024 sec, idle 5 sec]
zabbix 18676 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection]
zabbix 18677 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection]
zabbix 18678 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connection]
zabbix 18679 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: trapper #4 [processed data in 0.000000 sec, waiting for connection]
zabbix 18680 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: trapper #5 [processed data in 0.002835 sec, waiting for connection]
zabbix 18681 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000017 sec, idle 5 sec]
zabbix 18682 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: alert manager #1 [sent 0, failed 0 alerts, idle 5.002741 sec during 5.002771 sec]
zabbix 18683 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: alerter #1 started
zabbix 18684 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: alerter #2 started
zabbix 18685 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: alerter #3 started
zabbix 18686 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: preprocessing manager #1 [queued 1, processed 2 values, idle 5.000465 sec during 5.000520 sec]
zabbix 18687 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: preprocessing worker #1 started
zabbix 18688 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: preprocessing worker #2 started
zabbix 18689 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: preprocessing worker #3 started
zabbix 18690 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: lld manager #1 [processed 0 LLD rules, idle 5.002649sec during 5.002679 sec]
zabbix 18691 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: lld worker #1 started
zabbix 18692 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: lld worker #2 started
zabbix 18693 18642 0 22:47 ? 00:00:00 /usr/sbin/zabbix_server: alert syncer [queued 0 alerts(s), flushed 0 result(s) in 0.000475 sec, idle 1 sec]
root 19047 8509 0 22:50 pts/1 00:00:00 grep --color=auto zabbix_server