参考文章
Centos9部署Zabbix7.0 Server详细教程【保姆级】_zabbix 7.0-CSDN博客
大神写的很详细
开源监控zabbix对接可视化工具grafana教程_zabbix对接grafana-CSDN博客
##关闭selinux
[root@Zabbix-Server ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
##禁用防火墙
[root@Zabbix-Server ~]# systemctl disable --now firewalld
##重启
[root@Zabbix-Server ~]# reboot
##查看selinux状态
[root@Zabbix-Server ~]# sestatus
SELinux status: disabled
##查看防火墙状态
[root@Zabbix-Server ~]# systemctl status firewalld.service
升级系统
yum -y update
安装常用工具
sudo yum -y install vim net-tools wget gcc make cmake lrzsz
安装php
dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm
dnf clean all
dnf makecache
安装php8和相关组件
sudo dnf install -y php80 php80-php-cli php80-php-gd php80-php-json php80-php-mbstring php80-php-mysqlnd php80-php-xml
安装zabbix
rpm -Uvh https://repo.zabbix.com/zabbix/7.0/alma/9/x86_64/zabbix-release-7.0-2.el9.noarch.rpm
修改epel.repo中enabled值 为0
vi /etc/yum.repos.d/epel.repo
enabled=1改为enabled=0
安装zabbix所需组件
dnf install -y zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
安装完成后,重新修改epel.repo值
vi /etc/yum.repos.d/epel.repo
修改enabled=0改为enabled=1
#重新启动zabbix-server、zabbix-agent、httpd、php-fpm服务
[root@localhost ~]# systemctl restart zabbix-server zabbix-agent httpd php-fpm
#加入开机自动启动
[root@localhost ~]# systemctl enable zabbix-server zabbix-agent httpd php-fpm
下载mysql安装源rpm
yum -y install https://repo.mysql.com//mysql84-community-release-el9-1.noarch.rpm
安装mysql
yum -y install mysql-community-server
启动mysql服务器
systemctl start mysqld
查看mysql服务器状态
systemctl status mysqld
开机自启动mysql服务器
systemctl enable mysqld
查询mysql安装时的密码
grep password /var/log/mysqld.log
登录mysql
mysql -u root -p 查询到的密码
更改默认密码
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Start123!@#';
exit;
##初始化数据库, 按提示初始化
[root@Zabbix-Server ~]# mysql_secure_installation
删除匿名用户,禁止远程登录,删除测试数据库
##使用新密码登录数据库测试
登录数据库,建zabbix数据库
mysql -uroot -p
建zabbix数据库
create database zabbix character set utf8mb4 collate utf8mb4_bin;
create user zabbix@localhost identified by 'Start123!';
grant all privileges on zabbix.* to zabbix@localhost;
show databases;
use zabbix;
set global log_bin_trust_function_creators = 1;
quit;
#导入zabbixd的初始数据库
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix;
Enter password:输入之前设置zabbix访问数据库的密码
#关闭修改非确定性函数
mysql -uroot -p
Enter password:输入之前设置root访问数据库的密码
set global log_bin_trust_function_creators = 0;
quit;
配置zabbix conf文件
vi /etc/zabbix/zabbix_server.conf
修改数据库密码为刚才设置的密码,设置监听端口为10051
#设置数据库密码位上方设置的zabbix密码Start123!
DBPassword=Start123!
#设置监听客户端端口位10051:
ListenPort=10051
退出
安装grafana
yum install -y https://dl.grafana.com/enterprise/release/grafana-enterprise-11.0.0-1.x86_64.rpm
#查看服务状态
systemctl status grafana-server.service
#设置服务开机自启动
systemctl enable grafana-server.service
#启动服务
systemctl start grafana-server.service
安装zabbix插件
grafana-cli plugins install alexanderzobnin-zabbix-app
重启grafana
systemctl restart grafana-server.service
配置数据源连接
http://localhost/zabbix/api_jsonrpc.php