centos7.2下快速安装zabbix4.0
本笔记是基于CentOS 7.2下最小化安装的操作系统搭建的Zabbix4.0环境,主要用于做一些企业路由器和交换机等设备的运行状态监控。
1、安装epel源

- yum -y install epel-release
2、安装php-fpm和mariadb

- yum -y install php-fpm mariadb mariadb-server wget
3、配置zabbix4.0源(我这里主要使用的是清华大学的zabbix镜像源)

- wget -P /etc/yum.repos.d/ http://down.whsir.com/downloads/zabbix.repo
4、安装zabbix4.0

- yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
5、启动mariadb

- systemctl enable mariadb
systemctl start mariadb
6、配置mariadb(创建zabbix数据库,默认密码为空,直接enter)

- mysql -u root -p

- MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'www.pengqi.club';
MariaDB [(none)]> quit
7、导入zabbix数据库

- zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pwww.pengqi.club zabbix
8、修改zabbix-server配置文件

- vi /etc/zabbix/zabbix_server.conf

- DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=www.pengqi.club
9、修改http配置文件,修改时区为亚洲上海

- vi /etc/httpd/conf.d/zabbix.conf

- php_value date.timezone Asia/Shanghai
10、启动相关应用服务并设置开机启动

- systemctl enable php-fpm
systemctl start php-fpm
systemctl enable httpd
systemctl start httpd
systemctl enable zabbix-server
systemctl start zabbix-server
systemctl enable zabbix-agent
systemctl start zabbix-agent
11、访问web页面初始化安装zabbix4.0(http://你的IP地址/zabbix/)
温馨提示:
1、需要关闭 selinux,一定要关闭这个,开启selinux会引起一连串问题。

- sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
2、关闭防火墙

- systemctl start firewalld.service#启动firewall
systemctl stop firewalld.service#停止firewall
systemctl disable firewalld.service#禁止firewall开机启动
添加被监控服务器(添加zabbix-agent)
- 安装zabbix-agent客户端
wget -P /etc/yum.repos.d/ http://down.whsir.com/downloads/zabbix.repo
yum install -y zabbix-agent
- 编辑修改配置文件
grep -n '^'[a-Z] /etc/zabbix/zabbix_agentd.conf
vim /etc/zabbix/zabbix_agentd.conf
13:PidFile=/var/run/zabbix/zabbix_agentd.pid
32:LogFile=/var/log/zabbix/zabbix_agentd.log
43:LogFileSize=0
98:Server=192.168.144.113 //zabbix服务器地址
139:ServerActive=192.168.144.113 //活跃服务器地址
150:Hostname=test
268:Include=/etc/zabbix/zabbix_agentd.d/*.conf
- 关闭防火墙,启动服务
systemctl stop firewalld.service
setenforce 0
systemctl enable zabbix-agent.service
systemctl restart zabbix-agent.servicenetstat -anpt | grep zabbix //监听在10050端口
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人