首页 > 代码库 > zabbix 使用进阶(六)
zabbix 使用进阶(六)
zabbix 分布式监控
===============================================================================
概述
===============================================================================
zabbix proxy:
---可选组件,常用于分布式监控环境中,代理Server收集部分被监控数据并统一发往Server端;
★安装配置过程:
(1)准备数据库服务器;
(2)安装
zabbix-proxy-mysql-3.0.2-1.el7.x86_64.rpm zabbix-get-3.0.2-1.el7.x86_64.rpm
(3)生成数据库
sql脚本位置:/usr/share/doc/zabbix-proxy-mysql-3.0.2/schema.sql.gz
mysql zabbix_proxy < /usr/share/doc/zabbix-proxy-mysql-3.0.2/schema.sql
(4)配置启动;
(5)在server端添加此proxy;
(6)添加hosts时,选择使用指定的proxy进行监控;
演示:
操作环境:新添加一台CentOS 7.2-4的虚拟主机配置zabbix-proxy,然后代理server端监控CentOS 7.2-3 主机;
-----------------------------------------------------------------------------------------
1.设置zabbix database,创建一个数据库,并授权一个用户有权限连接并使用zabbix-proxy的数据库
1)mariadb安装,配置,及启动
# 在CentOS 7 安装mariadb数据库,使用前要首先编辑其配置文件/etc/my.cnf,添加跳过名称解析等 [root@centos7 ~]# vim /etc/my.cnf skip_name_resolve = ON innodb_file_per_table = ON # 启动数据库,可以设置开机自启动 [root@centos7 ~]# systemctl start mariadb.service [root@centos7 ~]# systemctl enabled mariadb.service
2)创建zabbix database数据库,并授权一个用户可以远程和本地登录此数据库;
[root@centos7 ~]# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 3 Server version: 5.5.44-MariaDB MariaDB Server Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. MariaDB [(none)]> create database zabbix_proxy charset ‘utf8‘; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> GRANT ALL ON zabbix.* TO ‘zbxproxy‘@‘10.1.%.%‘ IDENTIFIED BY ‘zbxpass‘; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> GRANT ALL ON zabbix.* TO ‘zbxproxy‘@‘127.0.0.1‘ IDENTIFIED BY ‘zbxpass‘; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mydb | | mysql | | performance_schema | | test | | zabbix_proxy | +--------------------+ 6 rows in set (0.05 sec)
----------------------------------------------------------------------------------------
2.安装服务器端
1)下载zabbix相关的所有程序包
[root@centos7 ~]# ls zabbix-proxy zabbix-get-3.0.2-1.el7.x86_64.rpm zabbix-proxy-mysql-3.0.2-1.el7.x86_64.rpm
2)安装server端的程序包:zabbix-server-mysql和zabbix-get
[root@centos7 zabbix-proxy]# yum install zabbix-proxy-mysql-3.0.2-1.el7.x86_64.rpm zabbix-get-3.0.2-1.el7.x86_64.rpm -y [root@centos7 ~]# rpm -ql zabbix-proxy-mysql /etc/logrotate.d/zabbix-proxy /etc/zabbix/zabbix_proxy.conf //主配置文件 /usr/lib/systemd/system/zabbix-proxy.service //Unit File文件 /usr/lib/tmpfiles.d/zabbix-proxy.conf /usr/lib/zabbix/externalscripts /usr/sbin/zabbix_proxy_mysql /usr/share/doc/zabbix-proxy-mysql-3.0.2 /usr/share/doc/zabbix-proxy-mysql-3.0.2/AUTHORS /usr/share/doc/zabbix-proxy-mysql-3.0.2/COPYING /usr/share/doc/zabbix-proxy-mysql-3.0.2/ChangeLog /usr/share/doc/zabbix-proxy-mysql-3.0.2/NEWS /usr/share/doc/zabbix-proxy-mysql-3.0.2/README /usr/share/doc/zabbix-proxy-mysql-3.0.2/schema.sql.gz //sql脚本,导入数据库使用 /usr/share/man/man8/zabbix_proxy.8.gz /var/log/zabbix /var/run/zabbix
----------------------------------------------------------------------------------------
3.导入数据库脚本,以生成数据库环境
[root@centos7 ~]# cp /usr/share/doc/zabbix-proxy-mysql-3.0.2/schema.sql.gz zabbix-proxy/ [root@centos7 ~]# gzip -d zabbix-proxy/schema.sql.gz //复制脚本到本地,并解压缩 [root@centos7 ~]# cd zabbix-proxy [root@centos7 zabbix-proxy]# ls schema.sql # 导入数据库脚本 [root@centos7 zabbix-proxy]# mysql -uzbxproxy -h127.0.0.1 -pzbxpass zabbix_proxy < schema.sql [root@centos7 zabbix-proxy]# mysql -uzbxproxy -h127.0.0.1 -pzbxpass Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 11 Server version: 5.5.44-MariaDB MariaDB Server Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | test | | zabbix_proxy | +--------------------+ 3 rows in set (0.00 sec) MariaDB [(none)]> use zabbix_proxy Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MariaDB [zabbix_proxy]> show tables; //查看导入脚本后生成的表 +----------------------------+ | Tables_in_zabbix_proxy | +----------------------------+ | acknowledges | | actions | | alerts | | application_discovery | | application_prototype | | application_template | | applications | | auditlog | | auditlog_details | | autoreg_host | | conditions | | config |
----------------------------------------------------------------------------------------
4.zabbix-proxy配置启动
1)配置说明
[root@centos7 ~]# grep "^####" /etc/zabbix/zabbix_proxy.conf //获取配置段大概信息 ############ GENERAL PARAMETERS ################# ######### PROXY SPECIFIC PARAMETERS ############# ############ ADVANCED PARAMETERS ################ ####### LOADABLE MODULES ####### ####### TLS-RELATED PARAMETERS #######
2)编辑配置如下:
[root@centos7 ~]# vim /etc/zabbix/zabbix_proxy.conf Server= Hostname=zbxproxy.CentOS7.2-4 DBHost= DBName=zabbix_proxy DBUser=zbxproxy DBPassword=zbxpass ConfigFrequency=120 //zabbix-server端多长时间将proxy配置推送给proxy端 DataSenderFrequency=1 //proxy端每多长时间把数据发送给zabbix-server端
3)启动zabbix-proxy服务,查看端口10051
---------------------------------------------------------------------------------------
5.在server端添加此proxy
6.添加hosts时,选择使用指定的proxy进行监控;
zabbix 使用进阶(六)