Zabbix 是一个功能强大的开源监控办理方案,广泛用于企业级环境中的系统、网络和运用程序监控。本文将详细先容如何在 Linux 8 上安装和配置 Zabbix 6.4,帮助你快速搭建一个高效的监控系统。无论你是初学者还是有履历的系统管理员,本文都将为你供应详细的步骤和最佳实践,确保你能顺利地完成安装和配置。
一、选择您Zabbix做事器的平台
配置环境如下

ZABBIX版本:6.4
OS版本:RHEL 8
DB版本:postgresql 16
WEB做事器版本: Apache/2.4.37
php版本:7.4
二、安装和配置 Zabbix2.1 配置安装 Zabbix 存储库
1) 禁用 EPEL 供应的 Zabbix 软件包(如果已安装)。
编辑配置文件/etc/yum.repos.d/epel.repo并添加以下语句。
[epel]...excludepkgs=zabbix2)连续安装 zabbix 存储库。 rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/8/x86_64/zabbix-release-6.4-1.el8.noarch.rpm dnf clean all
2.2 安装Zabbix server,Web前端,agent
dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent zabbix-get net-snmp nginx
2.3. 配置监控数据库1)初始化pg数据库配置环境变量
$ cat .bash_profileexport PGHOME=/usr/local/postgresexport PGDATA=/data/pgdata/dataexport PGLIB=/usr/local/postgresql/libexport LC_ALL=en_US.UTF8export LANG=en_US.UTF8PATH=/usr/local/postgres/bin:$PATHexport PATH
初始化数据库
$ initdb pg_ctl -D /data/pgdata/data -l logfile start
调度参数
listen_addresses = ''log_min_duration_statement=0logging_collector = onlog_filename = 'postgresql-%Y-%m-%d.log'log_rotation_age = '1d'log_directory = 'pg_log'log_checkpoints = onlog_connections = onlog_disconnections = onlog_lock_waits = onlog_temp_files = 0log_autovacuum_min_duration = 0
调度hba
host all all 0.0.0.0/0 trust
pg_ctl restart -D /data/pgdata/data
[postgres用户]createuser --pwprompt zabbixcreatedb -O zabbix zabbix--授权psqlpostgres=# alter user zabbix SUPERUSER;ALTER ROLE
# zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | psql zabbix
2.4. 配置Zabbix server和agent1)配置Zabbix server参数
编辑配置文件 /etc/zabbix/zabbix_server.conf# egrep -v '^\#|^$' /etc/zabbix/zabbix_server.confLogFile=/var/log/zabbix/zabbix_server.logLogFileSize=0PidFile=/run/zabbix/zabbix_server.pidSocketDir=/run/zabbixDBName=zabbixDBUser=zabbixDBPassword=zabbixSNMPTrapperFile=/var/log/snmptrap/snmptrap.logTimeout=4LogSlowQueries=3000StatsAllowedIP=127.0.0.1
2)配置Zabbix agent参数
编辑配置文件 /etc/zabbix/zabbix_agent.conf[root@db1 zabbix]# egrep -v '^\#|^$' /etc/zabbix/zabbix_agentd.confPidFile=/run/zabbix/zabbix_agentd.pidLogFile=/var/log/zabbix/zabbix_agentd.logLogFileSize=0Server=192.168.2.115ServerActive=192.168.2.115Hostname=192.168.2.115Include=/etc/zabbix/zabbix_agentd.d/.conf#Server=192.168.2.115 agent向server上报的做事器,也便是server做事器#Hostname=192.168.2.115 agent地址
3) 验证zabbix server和agent连接
# zabbix_get -s 192.168.2.115 -p 10050 -k "system.cpu.load[all,avg1]"0.570000
启动Zabbix server和agent进程,并为它们设置开机自启:
# systemctl restart zabbix-server zabbix-agent httpd php-fpm# systemctl enable zabbix-server zabbix-agent httpd php-fpm
2.5. 升级php版本
zabbix 6.4对php最低版本哀求为7.4,当前配置版本为7.2,不符合哀求。
1)查看当前利用的php版本[root@ora19c zabbix]# dnf module list phpUpdating Subscription Management repositories.Unable to read consumer identityThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.Last metadata expiration check: 1:09:35 ago on Mon 10 Jun 2024 11:04:18 PM CST.CentOS-8 - AppStream - mirrors.aliyun.comName Stream Profiles Summaryphp 7.2 [d][e] common [d], devel, minimal PHP scripting languagephp 7.3 common [d], devel, minimal PHP scripting languagephp 7.4 common [d], devel, minimal PHP scripting languageHint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
2)卸载重新安装
dnf module reset php:7.2dnf module install php:7.4
3)查看生效的版本
# dnf module list phpUpdating Subscription Management repositories.Unable to read consumer identityThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.Last metadata expiration check: 0:41:15 ago on Mon 10 Jun 2024 10:44:15 PM PDT.CentOS-8 - AppStream - mirrors.aliyun.comName Stream Profiles Summaryphp 7.2 [d] common [d], devel, minimal PHP scripting languagephp 7.3 common [d], devel, minimal PHP scripting languagephp 7.4 [e] common [d] [i], devel, minimal PHP scripting languageHint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
3.2 安装前检讨
3.2 配置pg数据库
3.3 配置zabbix属性
3.4 安装信息预览
3.5 完成安装用户名默认Admin,密码zabbix
写在末了
数据库在当今信息社会中扮演着重要角色,为各行各业供应数据支持。如果你想深入理解数据库的利用与管理,欢迎关注我们的微信公众年夜众号“安呀智数据坊”,我们将定期分享更多干系知识和行业动态。
如果你以为这篇文章对你有帮助,记得点赞支持一下哦!
你的每一个点赞都是我连续创作的动力!