zabbix 监控安装

**

什么是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等平台上。

准备实验机两台
主机 IP 角色
server1(rhel7.3) 172.25.68.1 server
server2 (rhel7.3) 172.25.68.2 agent

一、安装zabbix监控
在 zabbix官网上有非常详细的细节!
zabbix 监控安装
首先 所要安装的软件!

yum install zabbix-server-mysql
yum install zabbix-proxy-mysql
yum install zabbix-web-mysql

安装并配置mariadb数据库:

[[email protected] ~]# yum install mariadb-server -y
[[email protected] ~]# systemctl start mariadb
[[email protected] ~]# mysql_secure_installation    重新设置密码

Set root password? [Y/n]  回车
New password:  新密码
Re-enter new password:  确认密码 

Remove anonymous users? [Y/n]  回车

Disallow root login remotely? [Y/n]  回车

Remove test database and access to it? [Y/n]  回车

Reload privilege tables now? [Y/n]  回车

进入数据库对用户授权
[[email protected] ~]# mysql -uroot -p

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| zabbix             |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to [email protected] identified by 'westos';
Query OK, 0 rows affected (0.00 sec)

导入zabbix数据库

[[email protected] ~]# cd /usr/share/doc/zabbix-server-mysql-4.0.5/
[[email protected] zabbix-server-mysql-4.0.5]# ls
AUTHORS  ChangeLog  COPYING  create.sql.gz  NEWS  README
[[email protected] zabbix-server-mysql-4.0.5]# zcat create.sql.gz | mysql -uzabbix -p zabbix
Enter password: 

登陆数据库查看导入的数据库show databases; show tables;
zabbix 监控安装

编辑zabbix的配置文件,修改数据库密码,修改时区

[[email protected] zabbix-server-mysql-4.0.5]# vim /etc/zabbix/zabbix_server.conf   修改密码

zabbix 监控安装

[[email protected] zabbix-server-mysql-4.0.5]# vim /etc/httpd/conf.d/zabbix.conf   修改时区

zabbix 监控安装
启动 zabbix server、zabbix agent、httpd

[[email protected] zabbix-server-mysql-4.0.5]# systemctl start zabbix-server
[[email protected] zabbix-server-mysql-4.0.5]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[[email protected] zabbix-server-mysql-4.0.5]# systemctl start httpd
[[email protected] zabbix-server-mysql-4.0.5]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

浏览器输入172.25.68.1/zabbix/,进行zabbix的web界面配置
点击Next step
zabbix 监控安装
检查是否全部ok 即可点击Next step
zabbix 监控安装
输入密码 为 数据库的密码 为westos
zabbix 监控安装
输入名字 可以任意!
zabbix 监控安装
最后一次检查的机会
zabbix 监控安装
点击蓝色小框框
zabbix 监控安装
输入 账户密码 密码为 zabbix 与导入进mysql时一致
zabbix 监控安装
登陆成功
zabbix 监控安装
点击右上方小人可将语言转换为中文
zabbix 监控安装

zabbix 监控安装
测试

[[email protected] zabbix-server-mysql-4.0.5]# yum install zabbix-agent -y
[[email protected] zabbix-server-mysql-4.0.5]# systemctl start zabbix-agent
[[email protected] zabbix-server-mysql-4.0.5]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[[email protected] zabbix-server-mysql-4.0.5]# netstat -antlp | grep  :10050
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      12441/zabbix_agentd 
tcp6       0      0 :::10050                :::*                    LISTEN      12441/zabbix_agentd 

zabbix 监控安装
二、 添加agent主机
手动添加主机
[[email protected] yum.repos.d]# yum install zabbix-agent -y
[[email protected] yum.repos.d]# cd /etc/zabbix/
[[email protected] zabbix]# ls
zabbix_agentd.conf zabbix_agentd.d
[[email protected] zabbix]# vim zabbix_agentd.conf
98 Server=172.25.68.1
139 ServerActive=172.25.68.1
150 Hostname=server2 ##为主机名!
[email protected] ~]# systemctl start zabbix-agent
点击右上角创建主机

zabbix 监控安装

群组选择
zabbix 监控安装
zabbix 监控安装
点击添加 模板
zabbix 监控安装
点击添加
zabbix 监控安装
刷新界面
zabbix 监控安装

自动发现
首先将server2 从主机中删除
在动作中 点击右上角 找到自动发现
zabbix 监控安装

删除原有的A 加入新的条件

zabbix 监控安装

zabbix 监控安装

状态为以启用
zabbix 监控安装
选择配置 自动发现
zabbix 监控安装
zabbix 监控安装
zabbix 监控安装

自动注册
将server2 从主机中删除 并且禁用掉自动发现的的动作和自动发现
在动作中 点击右上角 找到自动注册
zabbix 监控安装
创建动作
zabbix 监控安装
zabbix 监控安装

重启
zabbix 监控安装
zabbix 监控安装