05:zabbix-proxy和自动发现、注册

听起来挺高大上的,实际也就那么回事了mysql

1、先来个开胃菜:ansible批量安装客户端

话很少说,直接上内容(这里要注意一下:这里演示的是普通用户登录远程主机并切换到root用户进行安装,因此主机清单里要添加切换到root用户的密码):web

[root@cll-tianygqyyscbf-app-001 myplay]# pwd
/root/myplay
[root@cll-tianygqyyscbf-app-001 myplay]# tree
.
├── files
│   └── zabbix-agent-4.2.3-2.el6.x86_64.rpm
│   └── zabbix_agentd.conf
└── zabbix_agent_install.yml

1 directory, 3 files
[root@cll-tianygqyyscbf-app-001 myplay]# cat zabbix_agent_install.yml 
- hosts: test
  remote_user: vmuser

  tasks:
    - name: copy zabbix-agent rpm to server
      copy: src=files/zabbix-agent-4.2.3-2.el6.x86_64.rpm dest=/tmp/
#      when:
#        - ansible_distribution == "CentOS"
#        - ansible_distribution_major_version == "6"
    - name: install rpm package
      become: yes
      become_method: su
      shell: rpm -ivh /tmp/zabbix-agent-4.2.3-2.el6.x86_64.rpm
    - name: copy configure file
      become: yes
      become_method: su
      copy: src=files/zabbix_agentd.conf dest=/etc/zabbix/zabbix_agentd.conf backup=yes
      notify: restart zabbix_agent
    - name: start service
      become: yes
      become_method: su
      service: name=zabbix-agent state=started enabled=yes

  handlers:
    - name: restart zabbix_agent
      become: yes
      become_method: su
      service: name=zabbix-agent state=restarted
[root@cll-tianygqyyscbf-app-001 myplay]#

###########################################################################sql

[test]
192.168.23.3shell

[test:vars]
ansible_become_pass='root用户密码'数据库

 

2、zabbix_proxy安装配置使用

步骤:服务器

  • 安装代理软件和配置及启动服务(须要数据库支持:DBA绕过);

 

  • Web管理页面上添加proxy;

一、安装代理软件和配置及启动服务:app

 

1、安装代理软件和配置及启动服务:
1.1、安装zabbix_proxy(不会问我相关源如何配置吧):
# yum install zabbix-proxy-mysql

1.2、MySQL安装大体状况以下:
安装数据库    # yum install mariadb-server
启动服务器    # systemctl start mariadb.service
开机启动    # systemctl enable mariadb.service
建立库    > create database zabbix_proxy CHARACTER set utf8 COLLATE utf8_bin;
受权    >grant all on zabbix_proxy.* to zabbix@'localhost' identified by 'YourKey';
导入基础数据    # zcat /usr/share/doc/zabbix-proxy-mysql-3.0.8/schema.sql.gz|mysql -uzabbix -p123.Com zabbix_proxy

1.3、代理端配置文件以下:
[root@cll-tianygqyyscbf-app-001 zabbix]# grep ^[a-Z] /etc/zabbix/zabbix_proxy.conf
Server=zabbix_server端IP地址
Hostname=zms_proxy
LogFile=/var/log/zabbix/zabbix_proxy.log
LogFileSize=1024
PidFile=/var/run/zabbix/zabbix_proxy.pid
SocketDir=/var/run/zabbix
DBHost=127.0.0.1
DBName=zabbix_proxy
DBUser=zabbix
DBPassword=YourKey
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=15
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
[root@cll-tianygqyyscbf-app-001 zabbix]#

 

注:为了减轻zabbix_server端压力,proxy通常使用的是主动模式,因此这里Hostname特别重要(务必整个系统中全局惟一)ide

1.4、启动代理服务器:
启动服务    # /etc/init.d/zabbix-proxy start
开机自启    # chkconfig zabbix-proxy on

二、Web管理页面上添加proxy:spa

3、自动注册、自动发现

简介:3d

  • 自动注册:zabbix agent主动到zabbix Server上报到,登记;缺点agent有可能找不到Server(配置出错)
  • 自动发现:zabbix Server主动发现全部客户端,而后将客户端登记本身的小本本上,缺点zabbix server压力山大(网段大,客户端多),时间消耗多。

这里只演示自动注册

步骤:

  • 主机名和agent配置调整配置;
  • Web界面上配置;

一、主机名或zabbix_agentd.conf文件配置:
前提:

       自动注册的主机的主机名要有规律,zabbix_agentd.conf配置文件中HostMetadata值指定一个特征(主要目的是:加入这边10台机器,其中5台是作web的,另外五台是作DB的就能够配置两个注册动做——设置不一样的模板);下面给个具体示例:

二、Web界面上配置:

好了,就这么多……

相关文章
相关标签/搜索