在 CentOS 8 上安装 LAMP 堆栈

Zabbix 是基于 PHP 的网络监控工具,因此需要 PHP 应用程序服务器才能运行。

因此,我们使用单个 dnf 命令安装 Apache Web 服务器、MySQL 数据库服务器和 PHP 支持。

[root@zabbix-01 ~]# dnf install -y httpd mysql-server php php-mysqlnd php-mbstring php-pdo php-gd

启用并启动 Apache 服务。

[root@zabbix-01 ~]# systemctl enable --now httpd.service
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service -> /usr/lib/systemd/system/httpd.service.

允许 Apache 服务接受 Linux 防火墙中的传入流量。

[root@zabbix-01 ~]# firewall-cmd --permanent --add-service=http ; firewall-cmd --reload
success
success

启用并启动 MySQL 数据库服务。

[root@zabbix-01 ~]# systemctl enable --now mysqld.service
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service -> /usr/lib/systemd/system/mysqld.service.

配置 MySQL 服务器实例如下。

[root@zabbix-01 ~]# mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Please set the password for root here.
New password:
Re-enter new password:
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
Success.
All done!

编辑 PHP 配置以根据环境对其进行自定义。

[root@zabbix-01 ~]# vi /etc/php.ini

取消注释并设置以下指令。

date.timezone = Asia/Karachi

在 CentOS 8 上安装 Zabbix Yum 存储库

如 Zabbix 文档中所述,我们可以在我们的 CentOS 8 服务器中安装 Zabbix yum 存储库,如下所示。

[root@zabbix-01 ~]# cd /tmp
[root@zabbix-01 tmp]# wget https://repo.zabbix.com/zabbix/4.4/rhel/8/x86_64/zabbix-release-4.4-1.el8.noarch.rpm

使用 dnf 命令安装下载的 RPM。

[root@zabbix-01 tmp]# dnf install -y zabbix-release-4.4-1.el8.noarch.rpm

为 Zabbix yum 存储库构建 yum 包管理器缓存。

[root@zabbix-01 ~]# dnf makecache
CentOS-8 - AppStream                            3.8 kB/s | 4.3 kB     00:01
CentOS-8 - Base                                 2.3 kB/s | 3.9 kB     00:01
CentOS-8 - Extras                               546  B/s | 1.5 kB     00:02
Zabbix Official Repository - x86_64             1.7 kB/s | 2.9 kB     00:01
Zabbix Official Repository non-supported - x86_ 2.8 kB/s | 3.0 kB     00:01
Metadata cache created.

在 CentOS 8 上安装 Zabbix Agent 软件

Zabbix 是基于代理的服务器监控软件。
因此,我们需要在每台需要监控的服务器上安装Zabbix代理软件。

在同一台 Linux 服务器上安装 Zabbix Agent。

[root@zabbix-01 ~]# dnf install -y zabbix-agent

启用并启动 Zabbix 代理服务。

[root@zabbix-01 ~]# systemctl enable --now zabbix-agent
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent.service -> /usr/lib/systemd/system/zabbix-agent.service.

在 Linux 防火墙中允许 Zabbix 代理服务端口。

[root@zabbix-01 ~]# firewall-cmd --permanent --add-port={10051/tcp,10050/tcp}
success
[root@zabbix-01 ~]# firewall-cmd --reload
success

在 Web 浏览器中打开 URL http://zabbix-01.recipes.com/zabbix/。

单击下一步。

检查所有必需的 PHP 设置是否正常。
单击下一步。

输入 MySQL 数据库连接参数,然后单击下一步。

单击下一步。

单击下一步。

单击完成。

使用 Zabbix 默认用户名/密码登录,例如:admin/zabbix。

我们可以通过 Zabbix 服务器的仪表板到达。

我们已经在 CentOS 8 上成功安装了 Zabbix 服务器。

在 CentOS 8 上安装 Zabbix 网络监控服务器

Zabbix 是一个免费的基于服务器的网络监控软件。
使用 Zabbix,我们可以监控网络、服务器、虚拟机和云服务。
Zabbix 提供监控指标,其中包括网络利用率、CPU 负载和磁盘空间消耗。

在本文中,我们将学习如何在 CentOS 8 上安装 Zabbix 网络监控服务器。

更多: zhilu jiaocheng

在 CentOS 8 上安装 Zabbix 网络监控服务器

我们已经设置了 Zabbix yum 存储库,因此,我们可以使用 dnf 命令轻松安装 Zabbix 包。
在这里,我们使用以下命令安装支持 MySQL 数据库的 Zabbix。

[root@zabbix-01 ~]# dnf install -y zabbix-server-mysql

安装支持 MySQL 和 Apache 的 Zabbix 前端。

[root@zabbix-01 ~]# dnf -y install zabbix-web-mysql zabbix-apache-conf

创建一个 MySQL 数据库用户来拥有 Zabbix 服务器数据。

[root@zabbix-01 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.17 Source distribution
Copyright (c) 2000, 2019, 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> create database zabbix;
Query OK, 1 row affected (0.04 sec)
mysql> create user 'zabbix'@'localhost' identified by 'Zabbix@1234';
Query OK, 0 rows affected (0.14 sec)
mysql> grant ALL on zabbix.* to 'zabbix'@'localhost';
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)
mysql> exit
Bye

使用 Zabbix 服务器安装文件提供的脚本创建 Zabbix 数据库。

[root@zabbix-01 ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -D zabbix -pZabbix@1234
mysql: [Warning] Using a password on the command line interface can be insecure.

配置 Zabbix 服务器设置。

[root@zabbix-01 ~]# vi /etc/zabbix/zabbix_server.conf

并其中设置以下指令。

DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=Zabbix@1234

在 CentOS 8 上为 Zabbix 配置 SELinux 设置。
在执行以下命令之前,请确保我们已安装 policoreutils-python 包。

[root@zabbix-01 ~]# grep zabbix_t /var/log/audit/audit.log | audit2allow -M zabbix_server_custom
 IMPORTANT ***
To make this policy package active, execute:
semodule -i zabbix_server_custom.pp
[root@zabbix-01 ~]# semodule -i zabbix_server_custom.pp
[root@zabbix-01 ~]# rm -f zabbix_server_custom.*
[root@zabbix-01 ~]# setsebool -P httpd_can_connect_zabbix on
[root@zabbix-01 ~]# setsebool -P httpd_can_network_connect_db on

启用并启动 Zabbix 服务。

[root@zabbix-01 ~]# systemctl enable --now zabbix-server
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service -> /usr/lib/systemd/system/zabbix-server.service.
日期:2020-09-17 00:16:45 来源:oir作者:oir