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 并配置即可
1
2
3
|
#安装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
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#安装数据库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
|
1
2
3
4
5
6
7
|
###创建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;
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#数据库导入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)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#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
|
1
2
3
4
5
6
7
8
9
10
|
#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 日志
1
2
3
4
5
6
7
8
9
10
11
12
13
|
#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日志
1
2
3
4
5
6
|
#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是否为一个进程
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
[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添加的主机,都会自动配置,不用手动一个一个添加了。
本文转自 yanconggod 51CTO博客,原文链接:http://blog.51cto.com/yanconggod/1967387