本文将手把手教你如何在CentOS8上完成Zabbix7.0 LTS的部署,并集成PostgreSQL作为后端数据库。同时涵盖Linux、Windows等不同系统的Zabbix Agent安装方法,助你实现跨平台监控。教程面向新手,每一步都附带详细命令和解释。
确保CentOS8系统最小化安装,并拥有root或sudo权限。首先更新系统并关闭防火墙和SELinux(或按需放行端口)。
dnf update -ysystemctl stop firewalldsystemctl disable firewalldsetenforce 0sed -i "s/^SELINUX=.*/SELINUX=disabled/" /etc/selinux/config PostgreSQL数据库集成是Zabbix7.0 LTS稳定运行的基础。Zabbix7.0要求PostgreSQL至少13版本,我们安装PostgreSQL 13。
dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpmdnf -qy module disable postgresqldnf install -y postgresql13-server/usr/pgsql-13/bin/postgresql-13-setup initdbsystemctl enable --now postgresql-13 创建Zabbix数据库和用户:
sudo -u postgres psql -c "CREATE USER zabbix WITH PASSWORD "zabbix_pwd";"sudo -u postgres psql -c "CREATE DATABASE zabbix OWNER zabbix;" 配置Zabbix官方仓库并安装核心组件:
rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rhel/8/x86_64/zabbix-release-7.0-1.el8.noarch.rpmdnf clean alldnf install -y zabbix-server-pgsql zabbix-web-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent2 导入Zabbix初始数据:
zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix 编辑Zabbix server配置文件/etc/zabbix/zabbix_server.conf,修改数据库连接信息:
DBHost=localhostDBName=zabbixDBUser=zabbixDBPassword=zabbix_pwd Zabbix前端需要PHP支持。编辑Nginx配置/etc/nginx/conf.d/zabbix.conf,设置listen和server_name。然后启动服务:
systemctl enable --now zabbix-server zabbix-agent2 nginx php-fpmsystemctl restart nginx php-fpm 此时可通过http://服务器IP访问Zabbix前端,按照向导完成后续设置,数据库信息填写之前创建的PostgreSQL库即可。
Zabbix Agent安装是实现跨平台监控的关键。下面分别演示在CentOS8(兼容Rocky/Alma)、Ubuntu和Windows上安装Agent。
CentOS8安装Agent2:
rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rhel/8/x86_64/zabbix-release-7.0-1.el8.noarch.rpmdnf install -y zabbix-agent2sed -i "s/^Server=.*/Server=ZABBIX_SERVER_IP/" /etc/zabbix/zabbix_agent2.confsed -i "s/^ServerActive=.*/ServerActive=ZABBIX_SERVER_IP/" /etc/zabbix/zabbix_agent2.confsystemctl enable --now zabbix-agent2 Ubuntu 20.04/22.04安装Agent2:
wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_7.0-1+ubuntu20.04_all.debdpkg -i zabbix-release_7.0-1+ubuntu20.04_all.debapt updateapt install -y zabbix-agent2sed -i "s/^Server=.*/Server=ZABBIX_SERVER_IP/" /etc/zabbix/zabbix_agent2.confsed -i "s/^ServerActive=.*/ServerActive=ZABBIX_SERVER_IP/" /etc/zabbix/zabbix_agent2.confsystemctl enable --now zabbix-agent2 从Zabbix官网下载Windows版本的Agent2(zabbix_agent2-7.0.0-windows-amd64-openssl.zip),解压到C:\Program Files\Zabbix Agent2,编辑配置文件conf\zabbix_agent2.conf,设置Server和ServerActive为Zabbix服务器IP。以管理员身份打开PowerShell,运行:
cd "C:\Program Files\Zabbix Agent2in".\zabbix_agent2.exe --config ..\conf\zabbix_agent2.conf --installStart-Service Zabbix-Agent2 登录Zabbix前端,在“配置”→“主机”中可以看到新添加的Agent主机,状态变为绿色即表示跨平台监控已生效。
总结:通过以上步骤,你已成功在CentOS8上完成CentOS8 Zabbix7.0 LTS部署,并集成了PostgreSQL数据库集成,同时掌握了Linux和Windows系统的Zabbix Agent安装方法,实现了基础的企业级跨平台监控。后续可根据需要配置模板、告警等。
本文由主机测评网于2026-03-10发表在主机测评网_免费VPS_免费云服务器_免费独立服务器,如有疑问,请联系我们。
本文链接:https://vpshk.cn/20260330147.html