centos7.2下快速安装zabbix4.0
本笔记是基于CentOS 7.2下最小化安装的操作系统搭建的Zabbix4.0环境,主要用于做一些企业路由器和交换机等设备的运行状态监控。
1、安装epel源
![点击复制代码](https://www.pengqi.club/zb_system/image/admin/page_copy.png)
- yum -y install epel-release
2、安装php-fpm和mariadb
![点击复制代码](https://www.pengqi.club/zb_system/image/admin/page_copy.png)
- yum -y install php-fpm mariadb mariadb-server wget
3、配置zabbix4.0源(我这里主要使用的是清华大学的zabbix镜像源)
![点击复制代码](https://www.pengqi.club/zb_system/image/admin/page_copy.png)
- wget -P /etc/yum.repos.d/ http://down.whsir.com/downloads/zabbix.repo
4、安装zabbix4.0
![点击复制代码](https://www.pengqi.club/zb_system/image/admin/page_copy.png)
- yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
5、启动mariadb
![点击复制代码](https://www.pengqi.club/zb_system/image/admin/page_copy.png)
- systemctl enable mariadb
systemctl start mariadb
6、配置mariadb(创建zabbix数据库,默认密码为空,直接enter)
![点击复制代码](https://www.pengqi.club/zb_system/image/admin/page_copy.png)
- mysql -u root -p
![点击复制代码](https://www.pengqi.club/zb_system/image/admin/page_copy.png)
- 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数据库
![点击复制代码](https://www.pengqi.club/zb_system/image/admin/page_copy.png)
- zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pwww.pengqi.club zabbix
8、修改zabbix-server配置文件
![点击复制代码](https://www.pengqi.club/zb_system/image/admin/page_copy.png)
- vi /etc/zabbix/zabbix_server.conf
![点击复制代码](https://www.pengqi.club/zb_system/image/admin/page_copy.png)
- DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=www.pengqi.club
9、修改http配置文件,修改时区为亚洲上海
![点击复制代码](https://www.pengqi.club/zb_system/image/admin/page_copy.png)
- vi /etc/httpd/conf.d/zabbix.conf
![点击复制代码](https://www.pengqi.club/zb_system/image/admin/page_copy.png)
- php_value date.timezone Asia/Shanghai
10、启动相关应用服务并设置开机启动
![点击复制代码](https://www.pengqi.club/zb_system/image/admin/page_copy.png)
- 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会引起一连串问题。
![点击复制代码](https://www.pengqi.club/zb_system/image/admin/page_copy.png)
- sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
2、关闭防火墙
![点击复制代码](https://www.pengqi.club/zb_system/image/admin/page_copy.png)
- 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端口
WEB管理界面添加被管理主机
参考文章:https://www.pengqi.club/blog/288.html
参考文章:https://blog.51cto.com/13659253/2165146
参考文章:https://www.zhouzhifei.com/?p=153