一 什么是zabbix?
zabbix([`zæbiks])是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
zabbix由2部分构成,zabbix server与可选组件zabbix agent。
zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。
二 安装使用
1 yum源修改
2 软件安装
yum install -y zabbix-server-mysql.x86_64
yum install -y zabbix-agent
yum install -y mariadb
yum install -y mariadb-server.x86_64
三 搭建监控环境
1 启动数据库并且安全初始化
systemctl start mariadb
mysql_secure_installation
2 进入数据库
mysql -pwestos
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> create user 'zabbix'@'localhost' identified by 'westos';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* 'zabbix'@'localhost';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''zabbix'@'localhost'' at line 1
MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit
3 往数据库倒入数据
cd /usr/share/doc/
cd zabbix-server-mysql-4.0.5/
zcat create.sql.gz | mysql -pwestos zabbix
zcat create.sql.gz | wc -l
4 修改配置文件并且启动服务
vim zabbix_server.conf
systemctl enable --now zabbix-server.service
systemctl enable --now zabbix-agent.service
5 安装zabbix前端
yum install -y zabbix-web-mysql
6修改时区并且启动httpd
vim zabbix.conf
systemctl enable --now httpd
7查看zabbix监控
四 监控主机的添加
1 在server2上
rpm -ivh zabbix-agent-4.0.5-1.el7.x86_64.rpm
cd /etc/zabbix/
vim zabbix_agentd.conf
systemctl enable --now zabbix-agent.service
客户端安装
配置文件修改
2 在server3上
rpm -ivh zabbix-agent-4.0.5-1.el7.x86_64.rpm
cd /etc/zabbix/
vim zabbix_agentd.conf
systemctl enable --now zabbix-agent.service
安装软件
修改配置文件
3 自动发现添加监控机
先设置动作及操作
在设置自动发现规则
在server2上启动服务
查看监控主机
4 自动注册
动作设置
操作设置
在server3上启动服务
查看监控主机