安装操作系统
系统版本
代码语言:javascript复制# uname -a
Linux localhost.localdomain 4.18.0-193.el8.x86_64 #1 SMP Fri May 8 10:59:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
安装好操作系统后,关闭防火墙和 selinux 并重启
代码语言:javascript复制sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
systemctl disable --now firewalld
reboot
安装Zabbix 5.0 LTS
安装 zabbix rpm 源
代码语言:javascript复制# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
# dnf clean all
安装 zabbix server 和 agent
代码语言:javascript复制# dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-agent
如果遇到不成功多试几次,输出结果:
代码语言:javascript复制[root@localhost ~]# dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-agent
Last metadata expiration check: 0:00:03 ago on Tue 18 Aug 2020 15:51:56 CST.
Dependencies resolved.
==============================================================================================================================================================================
Package Architecture Version Repository Size
==============================================================================================================================================================================
Installing:
zabbix-agent x86_64 5.0.2-1.el8 zabbix 457 k
zabbix-apache-conf noarch 5.0.2-1.el8 zabbix 17 k
zabbix-server-mysql x86_64 5.0.2-1.el8 zabbix 2.7 M
zabbix-web-mysql noarch 5.0.2-1.el8 zabbix 16 k
Installing dependencies:
OpenIPMI-libs x86_64 2.0.27-1.el8 BaseOS 507 k
apr x86_64 1.6.3-9.el8 AppStream 125 k
apr-util x86_64 1.6.1-6.el8 AppStream 105 k
centos-logos-httpd noarch 80.5-2.el8 BaseOS 24 k
fping x86_64 4.2-2.el8 epel 43 k
httpd x86_64 2.4.37-21.module_el8.2.0 382 15b0afa8 AppStream 1.7 M
httpd-filesystem noarch 2.4.37-21.module_el8.2.0 382 15b0afa8 AppStream 36 k
httpd-tools x86_64 2.4.37-21.module_el8.2.0 382 15b0afa8 AppStream 103 k
mariadb-connector-c x86_64 3.0.7-1.el8 AppStream 148 k
mariadb-connector-c-config noarch 3.0.7-1.el8 AppStream 13 k
mod_http2 x86_64 1.11.3-3.module_el8.2.0 307 4d18d695 AppStream 157 k
nginx-filesystem noarch 1:1.14.1-9.module_el8.0.0 184 e34fea82 AppStream 24 k
php-bcmath x86_64 7.2.24-1.module_el8.2.0 313 b04d0a66 AppStream 79 k
php-common x86_64 7.2.24-1.module_el8.2.0 313 b04d0a66 AppStream 661 k
php-fpm x86_64 7.2.24-1.module_el8.2.0 313 b04d0a66 AppStream 1.6 M
php-gd x86_64 7.2.24-1.module_el8.2.0 313 b04d0a66 AppStream 84 k
php-json x86_64 7.2.24-1.module_el8.2.0 313 b04d0a66 AppStream 73 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-pdo x86_64 7.2.24-1.module_el8.2.0 313 b04d0a66 AppStream 122 k
php-xml x86_64 7.2.24-1.module_el8.2.0 313 b04d0a66 AppStream 188 k
unixODBC x86_64 2.3.7-1.el8 AppStream 458 k
zabbix-web noarch 5.0.2-1.el8 zabbix 3.1 M
Installing weak dependencies:
apr-util-bdb x86_64 1.6.1-6.el8 AppStream 25 k
apr-util-openssl x86_64 1.6.1-6.el8 AppStream 27 k
Enabling module streams:
httpd 2.4
nginx 1.14
php 7.2
Transaction Summary
==============================================================================================================================================================================
Install 30 Packages
Total size: 13 M
Total download size: 5.8 M
Installed size: 51 M
Is this ok [y/N]: y
Downloading Packages:
[SKIPPED] apr-1.6.3-9.el8.x86_64.rpm: Already downloaded
[SKIPPED] apr-util-1.6.1-6.el8.x86_64.rpm: Already downloaded
[SKIPPED] apr-util-bdb-1.6.1-6.el8.x86_64.rpm: Already downloaded
[SKIPPED] apr-util-openssl-1.6.1-6.el8.x86_64.rpm: Already downloaded
[SKIPPED] httpd-2.4.37-21.module_el8.2.0 382 15b0afa8.x86_64.rpm: Already downloaded
[SKIPPED] httpd-filesystem-2.4.37-21.module_el8.2.0 382 15b0afa8.noarch.rpm: Already downloaded
[SKIPPED] httpd-tools-2.4.37-21.module_el8.2.0 382 15b0afa8.x86_64.rpm: Already downloaded
[SKIPPED] mariadb-connector-c-3.0.7-1.el8.x86_64.rpm: Already downloaded
[SKIPPED] mariadb-connector-c-config-3.0.7-1.el8.noarch.rpm: Already downloaded
[SKIPPED] mod_http2-1.11.3-3.module_el8.2.0 307 4d18d695.x86_64.rpm: Already downloaded
[SKIPPED] nginx-filesystem-1.14.1-9.module_el8.0.0 184 e34fea82.noarch.rpm: Already downloaded
[SKIPPED] php-bcmath-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64.rpm: Already downloaded
[SKIPPED] php-common-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64.rpm: Already downloaded
[SKIPPED] php-fpm-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64.rpm: Already downloaded
[SKIPPED] php-gd-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64.rpm: Already downloaded
[SKIPPED] php-json-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64.rpm: Already downloaded
[SKIPPED] php-ldap-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64.rpm: Already downloaded
[SKIPPED] php-mbstring-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64.rpm: Already downloaded
[SKIPPED] php-mysqlnd-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64.rpm: Already downloaded
[SKIPPED] php-pdo-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64.rpm: Already downloaded
[SKIPPED] php-xml-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64.rpm: Already downloaded
[SKIPPED] unixODBC-2.3.7-1.el8.x86_64.rpm: Already downloaded
[SKIPPED] OpenIPMI-libs-2.0.27-1.el8.x86_64.rpm: Already downloaded
[SKIPPED] centos-logos-httpd-80.5-2.el8.noarch.rpm: Already downloaded
[SKIPPED] fping-4.2-2.el8.x86_64.rpm: Already downloaded
[SKIPPED] zabbix-agent-5.0.2-1.el8.x86_64.rpm: Already downloaded
[SKIPPED] zabbix-apache-conf-5.0.2-1.el8.noarch.rpm: Already downloaded
[SKIPPED] zabbix-web-mysql-5.0.2-1.el8.noarch.rpm: Already downloaded
[MIRROR] zabbix-web-5.0.2-1.el8.noarch.rpm: Curl error (18): Transferred a partial file for http://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-web-5.0.2-1.el8.noarch.rpm [transfer closed with 1247757 bytes remaining to read]
(29/30): zabbix-server-mysql-5.0.2-1.el8.x86_64.rpm 27 kB/s | 2.7 MB 01:39
(30/30): zabbix-web-5.0.2-1.el8.noarch.rpm 21 kB/s | 3.1 MB 02:32
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 39 kB/s | 5.8 MB 02:32
warning: /var/cache/dnf/epel-6519ee669354a484/packages/fping-4.2-2.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 2f86d6a1: NOKEY
Extra Packages for Enterprise Linux 8 - x86_64 1.6 MB/s | 1.6 kB 00:00
Importing GPG key 0x2F86D6A1:
Userid : "Fedora EPEL (8) <epel@fedoraproject.org>"
Fingerprint: 94E2 79EB 8D8F 25B2 1810 ADF1 21EA 45AB 2F86 D6A1
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
Is this ok [y/N]: y
Key imported successfully
warning: /var/cache/dnf/zabbix-b7349cbb4866b08d/packages/zabbix-agent-5.0.2-1.el8.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Zabbix Official Repository - x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0xA14FE591:
Userid : "Zabbix LLC <packager@zabbix.com>"
Fingerprint: A184 8F53 52D0 22B9 471D 83D0 082A B56B A14F E591
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Running scriptlet: mariadb-connector-c-3.0.7-1.el8.x86_64 1/1
Preparing : 1/1
Installing : php-common-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 1/30
Installing : apr-1.6.3-9.el8.x86_64 2/30
Running scriptlet: apr-1.6.3-9.el8.x86_64 2/30
Installing : apr-util-bdb-1.6.1-6.el8.x86_64 3/30
Installing : apr-util-openssl-1.6.1-6.el8.x86_64 4/30
Installing : apr-util-1.6.1-6.el8.x86_64 5/30
Running scriptlet: apr-util-1.6.1-6.el8.x86_64 5/30
Running scriptlet: httpd-filesystem-2.4.37-21.module_el8.2.0 382 15b0afa8.noarch 6/30
Installing : httpd-filesystem-2.4.37-21.module_el8.2.0 382 15b0afa8.noarch 6/30
Installing : httpd-tools-2.4.37-21.module_el8.2.0 382 15b0afa8.x86_64 7/30
Installing : php-bcmath-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 8/30
Installing : php-gd-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 9/30
Installing : php-json-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 10/30
Installing : php-ldap-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 11/30
Installing : php-mbstring-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 12/30
Installing : php-pdo-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 13/30
Installing : php-mysqlnd-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 14/30
Installing : php-xml-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 15/30
Installing : fping-4.2-2.el8.x86_64 16/30
Installing : centos-logos-httpd-80.5-2.el8.noarch 17/30
Installing : mod_http2-1.11.3-3.module_el8.2.0 307 4d18d695.x86_64 18/30
Installing : httpd-2.4.37-21.module_el8.2.0 382 15b0afa8.x86_64 19/30
Running scriptlet: httpd-2.4.37-21.module_el8.2.0 382 15b0afa8.x86_64 19/30
Installing : OpenIPMI-libs-2.0.27-1.el8.x86_64 20/30
Installing : unixODBC-2.3.7-1.el8.x86_64 21/30
Running scriptlet: unixODBC-2.3.7-1.el8.x86_64 21/30
Running scriptlet: nginx-filesystem-1:1.14.1-9.module_el8.0.0 184 e34fea82.noarch 22/30
Installing : nginx-filesystem-1:1.14.1-9.module_el8.0.0 184 e34fea82.noarch 22/30
Installing : php-fpm-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 23/30
Running scriptlet: php-fpm-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 23/30
Installing : zabbix-web-mysql-5.0.2-1.el8.noarch 24/30
Installing : zabbix-web-5.0.2-1.el8.noarch 25/30
Running scriptlet: zabbix-web-5.0.2-1.el8.noarch 25/30
Installing : mariadb-connector-c-config-3.0.7-1.el8.noarch 26/30
Installing : mariadb-connector-c-3.0.7-1.el8.x86_64 27/30
Running scriptlet: zabbix-server-mysql-5.0.2-1.el8.x86_64 28/30
Installing : zabbix-server-mysql-5.0.2-1.el8.x86_64 28/30
Running scriptlet: zabbix-server-mysql-5.0.2-1.el8.x86_64 28/30
Installing : zabbix-apache-conf-5.0.2-1.el8.noarch 29/30
Running scriptlet: zabbix-apache-conf-5.0.2-1.el8.noarch 29/30
Running scriptlet: zabbix-agent-5.0.2-1.el8.x86_64 30/30
Installing : zabbix-agent-5.0.2-1.el8.x86_64 30/30
Running scriptlet: zabbix-agent-5.0.2-1.el8.x86_64 30/30
Running scriptlet: httpd-2.4.37-21.module_el8.2.0 382 15b0afa8.x86_64 30/30
Running scriptlet: zabbix-agent-5.0.2-1.el8.x86_64 30/30
Running scriptlet: php-fpm-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 30/30
Verifying : apr-1.6.3-9.el8.x86_64 1/30
Verifying : apr-util-1.6.1-6.el8.x86_64 2/30
Verifying : apr-util-bdb-1.6.1-6.el8.x86_64 3/30
Verifying : apr-util-openssl-1.6.1-6.el8.x86_64 4/30
Verifying : httpd-2.4.37-21.module_el8.2.0 382 15b0afa8.x86_64 5/30
Verifying : httpd-filesystem-2.4.37-21.module_el8.2.0 382 15b0afa8.noarch 6/30
Verifying : httpd-tools-2.4.37-21.module_el8.2.0 382 15b0afa8.x86_64 7/30
Verifying : mariadb-connector-c-3.0.7-1.el8.x86_64 8/30
Verifying : mariadb-connector-c-config-3.0.7-1.el8.noarch 9/30
Verifying : mod_http2-1.11.3-3.module_el8.2.0 307 4d18d695.x86_64 10/30
Verifying : nginx-filesystem-1:1.14.1-9.module_el8.0.0 184 e34fea82.noarch 11/30
Verifying : php-bcmath-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 12/30
Verifying : php-common-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 13/30
Verifying : php-fpm-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 14/30
Verifying : php-gd-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 15/30
Verifying : php-json-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 16/30
Verifying : php-ldap-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 17/30
Verifying : php-mbstring-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 18/30
Verifying : php-mysqlnd-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 19/30
Verifying : php-pdo-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 20/30
Verifying : php-xml-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 21/30
Verifying : unixODBC-2.3.7-1.el8.x86_64 22/30
Verifying : OpenIPMI-libs-2.0.27-1.el8.x86_64 23/30
Verifying : centos-logos-httpd-80.5-2.el8.noarch 24/30
Verifying : fping-4.2-2.el8.x86_64 25/30
Verifying : zabbix-agent-5.0.2-1.el8.x86_64 26/30
Verifying : zabbix-apache-conf-5.0.2-1.el8.noarch 27/30
Verifying : zabbix-server-mysql-5.0.2-1.el8.x86_64 28/30
Verifying : zabbix-web-5.0.2-1.el8.noarch 29/30
Verifying : zabbix-web-mysql-5.0.2-1.el8.noarch 30/30
Installed products updated.
Installed:
OpenIPMI-libs-2.0.27-1.el8.x86_64 apr-1.6.3-9.el8.x86_64
apr-util-1.6.1-6.el8.x86_64 apr-util-bdb-1.6.1-6.el8.x86_64
apr-util-openssl-1.6.1-6.el8.x86_64 centos-logos-httpd-80.5-2.el8.noarch
fping-4.2-2.el8.x86_64 httpd-2.4.37-21.module_el8.2.0 382 15b0afa8.x86_64
httpd-filesystem-2.4.37-21.module_el8.2.0 382 15b0afa8.noarch httpd-tools-2.4.37-21.module_el8.2.0 382 15b0afa8.x86_64
mariadb-connector-c-3.0.7-1.el8.x86_64 mariadb-connector-c-config-3.0.7-1.el8.noarch
mod_http2-1.11.3-3.module_el8.2.0 307 4d18d695.x86_64 nginx-filesystem-1:1.14.1-9.module_el8.0.0 184 e34fea82.noarch
php-bcmath-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-fpm-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-json-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-pdo-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64 php-xml-7.2.24-1.module_el8.2.0 313 b04d0a66.x86_64
unixODBC-2.3.7-1.el8.x86_64 zabbix-agent-5.0.2-1.el8.x86_64
zabbix-apache-conf-5.0.2-1.el8.noarch zabbix-server-mysql-5.0.2-1.el8.x86_64
zabbix-web-5.0.2-1.el8.noarch zabbix-web-mysql-5.0.2-1.el8.noarch
Complete!
安装mariadb数据库
手动安装数据库
代码语言:javascript复制 yum install mariadb-server -y
启动数据库,并配置开机自动启动
代码语言:javascript复制systemctl enable --now mariadb
使用以下命令初始化 mariadb 并配置 root 密码
代码语言:javascript复制mysql_secure_installation
注意:此时数据库密码为空,过程如下:
代码语言:javascript复制[root@localhost ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): //空
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password: //新密码
Re-enter new password: //新密码
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n
... skipping.
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
创建初始数据库
代码语言:javascript复制# mysql -uroot -p
password //密码
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> create user zabbix@localhost identified by 'password';
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
MariaDB [(none)]> quit;
使用以下命令导入 zabbix 数据库,zabbix 数据库用户为 zabbix,密码为 password
代码语言:javascript复制zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
修改 zabbix server 配置文件/etc/zabbix/zabbix_server.conf 里的数据库密码
代码语言:javascript复制DBPassword=password
为Zabbix前端配置PHP
编辑配置文件 /etc/php-fpm.d/zabbix.conf, uncomment and set the right timezone for you.
代码语言:javascript复制php_value[date.timezone] = Asia/Shanghai
启动Zabbix server和agent进程,并为它们设置开机自启:
代码语言:javascript复制# systemctl restart zabbix-server zabbix-agent httpd php-fpm
# systemctl enable zabbix-server zabbix-agent httpd php-fpm
配置Zabbix前端
连接到新安装的Zabbix前端: http://server_ip_or_name/zabbix 根据Zabbix文件里步骤操作: Installing frontend
1.
2.
3.
4.
5.
6.