关闭selinux

sed -i "s/SELINUX\=enforcing/SELINUX\=disabled/g" /etc/selinux/config

firewalld防火墙策略

firewall-cmd --zone=public --add-port=80/tcp --permanent

firewall-cmd --zone=public --add-port=10050/tcp --permanent

firewall-cmd --zone=public --add-port=10051/tcp --permanent

systemctl restart firewalld

卸载mariadb

[root@localhost ~]# rpm -qa | grep mariadb

mariadb-libs-5.5.68-1.el7.x86_64

[root@localhost ~]# yum remove mariadb-libs -y

配置yum

sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://mirrors.163.com|g' /etc/yum.repos.d/Cent*
sed -i 's|$releasever|8-stream|g' /etc/yum.repos.d/Cent*

安装mysql

[root@localhost ~]# yum -y install wget
[root@localhost ~]# yum -y install dnf
[root@localhost ~]# dnf install @mysql 回车输入y,自动下载安装

启动mysql

mysqld --initialize-insecure --user=mysql

systemctl start mysqld

修改mysql密码: 

先查看系统自动生成的密码【有的版本不需要这一步】
[root@localhost mysql]# more /var/log/mysqld.log | grep password
2022-05-04T13:06:01.810960Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: jMcXextbs9<j

修改mysql密码

mysql_secure_installation

[root@localhost mysql]# mysql_secure_installation 

Securing the MySQL server deployment.

Enter password for user root: 【默认直接回车,没有密码;或者是通过mysqld.log查看密码】
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

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!


安装依赖包

yum -y install httpd  php php-mysql php-common php-mbstring php-gd php-odbc php-pear curl curl-devel net-snmpnet-snmp-devel perl-DBI php-xml ntpdate php-bcmath gcc* libxml2 libxml2-devel net-snmp net-snmp-devel libssh2 libssh2-devel libevent libevent-devel


安装zabbix server

a. Install Zabbix repository
yum -y install dnf
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm
dnf clean all
b. 安装Zabbix server,Web前端,agent
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
c. 创建初始数据库

在数据库主机上运行以下代码。

[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 8.0.29 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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 character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.00 sec)

mysql> create user zabbix@localhost identified by '设置zabbix用户的密码';
Query OK, 0 rows affected (0.02 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> quit;
Bye

导入初始架构和数据,系统将提示您输入新创建的密码。

zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p zabbix
d. 为Zabbix server配置数据库

编辑配置文件 /etc/zabbix/zabbix_server.conf

DBPassword=password   #增加这一行,密码是刚才创建的密码
e. 启动Zabbix server和agent进程

启动Zabbix server和agent进程,并为它们设置开机自启:

启动:
systemctl restart zabbix-server zabbix-agent httpd php-fpm
设置开机启动:
systemctl enable zabbix-server zabbix-agent httpd php-fpm
f. 配置Zabbix前端

安装中文字体:

dnf install -y langpacks-zh_CN

连接到新安装的Zabbix前端: http://server_ip_or_name/zabbix

根据Zabbix文件里步骤操作: ​​Installing frontend​

配置zabbix web

Centos8安装zabbix6.0_zabbix6.0

Centos8安装zabbix6.0_centos8安装zabbix_02

Centos8安装zabbix6.0_zabbix_03

Centos8安装zabbix6.0_zabbix_04

Centos8安装zabbix6.0_zabbix6.0_05

Centos8安装zabbix6.0_zabbix_06

Centos8安装zabbix6.0_centos8安装zabbix_07

用户名:Admin

密码:zabbix

zabbix修改Admin密码

Centos8安装zabbix6.0_zabbix6.0_08

Centos8安装zabbix6.0_zabbix6.0_09

模板导出

Centos8安装zabbix6.0_zabbix6.0_10

Centos8安装zabbix6.0_centos安装zabbix_11

模板修改前备份

Centos8安装zabbix6.0_centos8安装zabbix_12

Centos8安装zabbix6.0_centos安装zabbix_13

Centos8安装zabbix6.0_centos8安装zabbix_14

Centos8安装zabbix6.0_zabbix6.0_15

模板修改【linux by zabbix agent】

Centos8安装zabbix6.0_zabbix6.0_16

只保留CPU、内存使用率,网络接口流量

先删除自动发现规则

Centos8安装zabbix6.0_centos8安装zabbix_17

删除图形里边

Centos8安装zabbix6.0_centos安装zabbix_18

删除监控项

删除其他不相关的只剩,如下几项

Centos8安装zabbix6.0_zabbix6.0_19

关联-添加ICMP监控【也可以添加主机的时候单独关联】

Centos8安装zabbix6.0_zabbix6.0_20

通过备份模板恢复模板

Centos8安装zabbix6.0_zabbix6.0_21

Centos8安装zabbix6.0_centos8安装zabbix_22

Centos8安装zabbix6.0_centos8安装zabbix_23

添加监控主机

Centos8安装zabbix6.0_zabbix_24