centos7.x之yum安装zabbix_proxy以及自动注册

zabbix proxy就是所谓的分布式监控,主要是代理zabbix server进行采集数据,zabbix proxy端也需要搭建另外一个mysql数据库,并且mysql需要创建一个zabbix_proxy数据库.

如果你有多个proxy和一个zabbix server组合,这就可以叫分布式监控了。

  zabbix proxy 只是一个进程 需要一个数据库 没有web界面 不会处理事件 也不会发送邮件 只是一个采集数据的功能

zabbix proxy的作用,官方描述

A Zabbix proxy can collect performance and availability data on behalf of the Zabbix server. This way, a proxy can take on itself some of the load of collecting data and offload the Zabbix server.

Also, using a proxy is the easiest way of implementing centralized and distributed monitoring, when all agents and proxies report to one Zabbix server and all data is collected centrally.

A Zabbix proxy can be used to:

Monitor remote locations

Monitor locations having unreliable communications

Offload the Zabbix server when monitoring thousands of devices  监控上万台服务器就靠他

Simplify the maintenance of distributed monitoring

先说说思路:安装zabbix proxy >安装mysql数据库 >导入zabbix_proxy数据库结构 > 配置zabbix proxy(server ip 需要指向zabbix server地址) > 安装zabbix agent 并配置即可

#安装zabbix proxy
rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
yum -y install zabbix-proxy  zabbix-proxy-mysql
#安装数据库5.6
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server
systemctl restart mysqld.service
#设置msyql密码为 123456
mysql> set password for 'root'@'localhost' =password('123456');
 
#远程连接设置,所有以root账号连接的远程用户,设其密码为 123456
mysql> grant all on xxxx.* to 'root'@'%' identified by '123456' with grant option;
 
#更新权限
mysql>flush privileges;
 
#数据库开机启动
systemctl enable mysqld.service
###创建MySQL  zabbix_proxy数据库和用户
mysql –u root –p
mysql> create database zabbix_proxy character set utf8;
 
mysql> grant all privileges on zabbix_proxy.* to 'zabbix'@'127.0.0.1' identified by 'zabbix';
 
mysql> flush privileges;
#数据库导入zabbix schema.sql.gz
zcat /usr/share/doc/zabbix-proxy-mysql-3.4.*/schema.sql.gz | mysql -uzabbix -p zabbix_proxy

#登陆数据库
mysql -uroot -p
#查看数据库,多了一个zabbix_proxy数据库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| zabbix_proxy       |
+--------------------+
4 rows in set (0.01 sec)
#zabbix proxy配置文件
grep '^[a-Z]' /etc/zabbix/zabbix_proxy.conf

Server=zabbix server端服务器ip地址
Hostname=Zabbix proxy final
LogFile=/var/log/zabbix/zabbix_proxy.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_proxy.pid
SocketDir=/var/run/zabbix
DBHost=127.0.0.1
DBName=zabbix_proxy
DBUser=zabbix
DBPassword=zabbix
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
#zabbix agent客户端
grep '^[a-Z]' /etc/zabbix/zabbix_agentd.conf

PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=zabbix proxy ip地址
ServerActive=zabbix proxy ip地址
Hostname=nginx02
Include=/etc/zabbix/zabbix_agentd.d/*.conf

#server 日志 

#server 日志 
 105825:20170920:155704.097 cannot parse proxy data from active proxy at "xx.xx.xx.xx": proxy "Zabbix proxy final" not found
105826:20170920:155705.108 cannot parse proxy data from active proxy at "xx.xx.xx.xx": proxy "Zabbix proxy final" not found
105826:20170920:155706.119 cannot parse proxy data from active proxy at "xx.xx.xx.xx": proxy "Zabbix proxy final" not found
105825:20170920:155707.128 cannot parse proxy data from active proxy at "xx.xx.xx.xx": proxy "Zabbix proxy final" not found
105826:20170920:155708.139 cannot parse proxy data from active proxy at "xx.xx.xx.xx": proxy "Zabbix proxy final" not found
105825:20170920:155709.149 cannot parse proxy data from active proxy at "xx.xx.xx.xx": proxy "Zabbix proxy final" not found
105826:20170920:155710.160 cannot parse proxy data from active proxy at "xx.xx.xx.xx": proxy "Zabbix proxy final" not found
105825:20170920:164017.897 sending configuration data to proxy "Zabbix proxy final" at "xx.xx.xx.xx", datalen 8172
105800:20170920:165042.107 executing housekeeper
105800:20170920:165052.563 housekeeper [deleted 37754 hist/trends, 0 items, 0 events, 0 problems, 0 sessions, 0 alarms, 0 audit items in 10.439203 sec, idle for 1 hour(s)]
#按照我的推断是,server端没有及时发送配置数据给proxy,应该是同步配置问题。这个过程中,我差不多度娘了一个小时,突然发现自己可以监控数据了。
后面我都试验了几次,时间长就可以正常同步了。只要server端发送数据给proxy

#proxy日志

#zabbix_proxy日志
t [nginx02] not found
 17523:20170920:163748.893 cannot send list of active checks to "127.0.0.1": host [nginx02] not found
 17523:20170920:163948.912 cannot send list of active checks to "127.0.0.1": host [nginx02] not found
 17504:20170920:164140.772 received configuration data from server at "xx.xx.xx.xx", datalen 8172
 17516:20170920:164150.825 enabling Zabbix agent checks on host "nginx02": host became available

#检查proxy是否为一个进程

[root@nginx02~]# ps -ef|grep proxy
zabbix   17503     1  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy -c /etc/zabbix/zabbix_proxy.conf
zabbix   17504 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: configuration syncer [synced config 13741 bytes in 0.079034 sec, idle 3600 sec]
zabbix   17505 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: heartbeat sender [sending heartbeat message success in 0.014880 sec, idle 60 sec]
zabbix   17506 17503  0 15:41 ?        00:00:04 /usr/sbin/zabbix_proxy: data sender [sent 1 values in 0.018079 sec, sending data]
zabbix   17507 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: housekeeper [deleted 2169 records in 0.034788 sec, idle for 1 hour(s)]
zabbix   17508 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: http poller #1 [got 0 values in 0.000464 sec, idle 5 sec]
zabbix   17509 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: discoverer #1 [processed 0 rules in 0.000326 sec, idle 60 sec]
zabbix   17510 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: history syncer #1 [synced 0 items in 0.000001 sec, idle 1 sec]
zabbix   17511 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: history syncer #2 [synced 0 items in 0.000001 sec, idle 1 sec]
zabbix   17512 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: history syncer #3 [synced 1 items in 0.008008 sec, idle 1 sec]
zabbix   17513 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: history syncer #4 [synced 0 items in 0.000001 sec, idle 1 sec]
zabbix   17514 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: self-monitoring [processed data in 0.000004 sec, idle 1 sec]
zabbix   17515 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: task manager [processed 0 task(s) in 0.000326 sec, idle 5 sec]
zabbix   17516 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: poller #1 [got 0 values in 0.000003 sec, idle 1 sec]
zabbix   17517 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: poller #2 [got 0 values in 0.000003 sec, idle 1 sec]
zabbix   17518 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: poller #3 [got 1 values in 0.000417 sec, idle 1 sec]
zabbix   17519 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: poller #4 [got 0 values in 0.000003 sec, idle 1 sec]
zabbix   17520 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: poller #5 [got 0 values in 0.000003 sec, idle 1 sec]
zabbix   17521 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: unreachable poller #1 [got 0 values in 0.000004 sec, idle 5 sec]
zabbix   17522 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: trapper #1 [processed data in 0.000000 sec, waiting for connection]
zabbix   17523 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: trapper #2 [processed data in 0.020794 sec, waiting for connection]
zabbix   17524 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: trapper #3 [processed data in 0.000000 sec, waiting for connection]
zabbix   17525 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: trapper #4 [processed data in 0.000713 sec, waiting for connection]
zabbix   17526 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: trapper #5 [processed data in 0.000000 sec, waiting for connection]
zabbix   17527 17503  0 15:41 ?        00:00:00 /usr/sbin/zabbix_proxy: icmp pinger #1 [got 0 values in 0.000005 sec, idle 5 sec]
root     31094 31000  0 18:22 pts/0    00:00:00 grep --color=auto proxy

刚配置提示的错误

17506:20170920:154253.213 cannot send proxy data to server at "xx.xx.xx.xx": proxy "Zabbix proxy final" not found

 17506:20170920:154254.228 cannot send proxy data to server at "xx.xx.xxx.xx": proxy "Zabbix proxy final" not found

web方面操作

第一个步骤配置agent代理程序

第二个步骤配置自动注册

配置完毕,所有经过proxy添加的主机,都会自动配置,不用手动一个一个添加了。

原文链接:http://blog.51cto.com/yanconggod/1967387

编辑于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏散尽浮华

mysql主从同步(3)-percona-toolkit工具(数据一致性监测、延迟监控)使用梳理

在mysql工作中接触最多的就是mysql replication,mysql在复制方面还是会有一些常规问题,比如主库宕机或者从库宕机有可能会导致复制中断,通常...

49810
来自专栏乐沙弥的世界

Oracle 闪回特性(FLASHBACK DATABASE)

闪回技术通常用于快速简单恢复数据库中出现的认为误操作等逻辑错误,从闪回的方式可以分为基于数据库级别闪回、表级别闪回、事务

1234
来自专栏数据和云

深入原理:Consistent Reads 与 buffer cache

黄玮(Fuyuncat) 资深Oracle DBA,个人网www.HelloDBA.com,致力于数据库底层技术的研究,其作品获得广大同行的高度评价. 编辑手记...

3657
来自专栏我的博客

TP入门第八天

[小型留言板-增删查改] 1、先建立数据库lyb,然后建立表lyb_notes 建表代码如下: CREATE TABLE `lyb_notes` ( `id` ...

3538
来自专栏醉生梦死

MySQL管理工具 mysqladmin 原

1251
来自专栏清风

MySQL数据库 原

其中“/yourpath/crontab_mysql.sql”为需要执行的sql语句。

933
来自专栏乐沙弥的世界

MySQL 二进制日志(Binary Log)

    同大多数关系型数据库一样,日志文件是MySQL数据库的重要组成部分。MySQL有几种不同的日志文件,通常包括错误日志文件,二进制日志,通用日志,慢查询日...

962
来自专栏散尽浮华

mysql操作命令梳理(4)-grant授权和revoke回收权限

在mysql维护工作中,做好权限管理是一个很重要的环节。下面对mysql权限操作进行梳理: mysql的权限命令是grant,权限撤销的命令时revoke; g...

2805
来自专栏后端技术探索

mysql问题排查实例

最近遇到应用频繁的响应缓慢,无法正常访问。帮忙一起定位原因,最后定位到的问题说起来真的是很小的细节问题,但是就是这些小细节导致了服务不稳定,真是细节决定成败。这...

1092
来自专栏开发技术

cassandra简单介绍与基本操作

  项目中用到了cassandra,用来存储海量数据,且要有高效的查询;本博客就进行简单的介绍和进行一些基本的操作

952

扫码关注云+社区

领取腾讯云代金券