在RHEL8上安装Zabbix5.2
首先
我总结了在RHEL8上安装Zabbix5.2的步骤。
Zabbix5.2于2020年10月27日发布,截止到2021年4月,Zabbix5.2.6是最新版本。
Zabbix 5.2的新功能。
系统配置
这次使用的软件和版本如下:
Zabbix:Zabbix 5.2.6
操作系统:RHEL8.3
Web服务器:Apache HTTP Server 2.4.37
PHP:PHP 7.2.24
数据库管理系统:MariaDB 10.3.27
环境和前提条件:
・目标服务器可以与互联网进行通信。
・将Zabbix Server、相关软件包和Zabbix Agent全部安装在一台服务器上。
・在SELinux上以Permissive状态进行安装。
・每个步骤都由具有root权限的用户执行。
・打开防火墙端口:HTTP(80/tcp)、HTTPS(443/tcp)、10050/tcp、10051/tcp。
1. 安装MariaDB
在安装Zabbix 5.2之前,先安装和设置MariaDB。
安装MariaDB
$ yum install mariadb-server
$ systemctl start mariadb
$ systemctl enable mariadb
为了设置MySQL的root密码,并删除不必要的设置,我们将使用mysql_secure_installation来进行安全性的初始设置。
$ mysql_secure_installation
(略)
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): <- Enterを入力
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 <- yを入力
New password: <- DBユーザ-rootのパスワードを入力
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 <- 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] y <- yを入力(rootのリモートログイン禁止)
... Success!
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 <- yを入力(不要なDBを削除)
- 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 <- 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!
编辑MariaDB的配置文件,并进行一些设置,如默认字符编码等。
$ vi /etc/my.cnf.d/mariadb-server.cnf
(略)
[mysqld]
character-set-server = utf8
collation-server = utf8_bin
skip-character-set-client-handshake
innodb_file_per_table
(略)
重新启动MariaDB。
$ systemctl restart mariadb
2. 安装Zabbix
根据官方网站的步骤进行引入。 de .)
2.1 注册 Zabbix LLC 仓库
※由于未来可能会发布新版本的软件包,请在下面的官方仓库中进行确认。
https://repo.zabbix.com/zabbix/5.2/rhel/8/x86_64/
在注册存储库后,请先清除缓存。
$ rpm -Uvh https://repo.zabbix.com/zabbix/5.2/rhel/8/x86_64/zabbix-release-5.2-1.el8.noarch.rpm
$ dnf clean all
2.2 安装Zabbix服务器包。
安装Zabbix Server相关的软件包。
$ dnf -y install zabbix-server-mysql zabbix-web-japanese zabbix-apache-conf
2.3 安装 Zabbix Agent
在此架构中,将安装Zabbix Agent2。
$ dnf -y install zabbix-agent2
3. Zabbix的初始设置
3.1 创建Zabbix所需的数据库。
在MariaDB上创建数据库和用户。
$ mysql -uroot -p
Enter password: <- DBユーザ-rootのパスワードを入力
(略)
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> create user zabbix@localhost identified by 'DBユーザzabbixのパスワードを入力';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> quit;
Bye
导入用于Zabbix的数据库架构和初始数据。
$ zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password: <- DBユーザーzabbixのパスワードを入力
3.2 Zabbix服务器的配置。
我們要編輯Zabbix Server的配置文件,將Zabbix用的數據庫密碼設定為DBPassword。
$ vi /etc/zabbix/zabbix_server.conf
DBPassword=<DBユーザzabbixのパスワード>
将PHP的时区设定为日本。
在PHP-FPM的配置文件中,取消掉时区行的注释,并将其更改为”Asia/Tokyo”。
$ vi /etc/php-fpm.d/zabbix.conf
; php_value[date.timezone] = Europe/Riga
↓
php_value[date.timezone] = Asia/Tokyo
3.4 Zabbix代理的配置
修改Zabbix Agent的配置文件,设置与Zabbix服务器的连接和代理主机名。
$ vi /etc/zabbix/zabbix_agent2.conf
# 監視通信を許可するZabbix ServerのIPアドレス
# 今回の構成では、Zabbix Server自身にAgentを導入しているので値を変更しない
# Zabbix Server以外のマシンにAgentを構成する場合は、Zabbix ServerのIPアドレスを指定する
Server=127.0.0.1
# ActiveCheckのデータ送信先Zabbix Server IPアドレス
# 今回の構成では、Zabbix Server自身にAgentを導入しているので値を変更しない
ServerActive=127.0.0.1
# Agentのホスト名(OSのhostnameではなく、zabbixに登録するホスト名)
Hostname=Zabbix server
↓
Hostname=<ホスト名>
3.4 启动服务并启用自动启动
$ systemctl restart zabbix-server zabbix-agent2 httpd php-fpm
$ systemctl enable zabbix-server zabbix-agent2 httpd php-fpm
3.5 Zabbix前端配置




打开登录页面后,请使用下方提供的初始用户名和密码进行登录。
用户名:Admin
密码:zabbix
