• zabbix配置server,proxy,agent架构


    author: headsen  chen

    date:2018-10-30  19:49:50

    环境:

    centos 6.8_x86_64
    zabbix-server: 192.168.1.130
    zabbix-proxy : 192.168.1.131
    zabbix-agent: 192.168.1.138

     

    1,zabbix-server配置                                                                                                                                                           

    安装依赖包(若报错加上: --skip-broken):

    #yum -y install  lrzsz   gcc*   libxml2-devel net-snmp*  curl-devel unixODBC-devel libssh2-devel openldap openldap-devel OpenIPMI ncurses-devel OpenIPMI-devel  livevent-devel  libpcre*  libpcre-devel pcre* libevent* 

    安装MySQL

    #yum -y install mysql mysql-server  mysql-devel
    #vim /etc/ld.so.conf   在后面加一行
      /usr/local/mysql/lib/
    #ldconfig  (重新加载)
    #service mysqld  start
    #chkconfig mysqld on

    新建zabbix用户:

    useradd zabbix
    mkdir /a;cd /a
    
    #上传zabbix安装包abbix-3.4.13.tar.gz到/mnt下面
    tar fx zabbix-3.4.13.tar.gz
    cd zabbix-3.4.13

    配置mysql

    创建mysql库
    mysql
    mysql>CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
    给zabbix用户授权,密码是123456:
    mysql>grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
    mysql>SHOW DATABASES;
    
    导入zabbix数据表结构
    mysql> use zabbix;
    mysql> source /a/zabbix-3.4.13/database/mysql/schema.sql;
    mysql> source /a/zabbix-3.4.13/database/mysql/data.sql;
    mysql> source /a/zabbix-3.4.13/database/mysql/images.sql;
    mysql>SHOW DATABASES;
    mysql> quit

    安装HTTP和PHP5.6:

    rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
    yum -y install httpd php56w php56w-gd php56w-mysqlnd php56w-bcmath php56w-mbstring php56w-xml php56w-ldap  net-snmp-devel
    # vim /etc/php.ini
    post_max_size = 16M max_execution_time = 300 max_input_time = 300 date.timezone = Asia/Shanghai always_populate_raw_post_data = -1
    # vim /etc/httpd/conf/httpd.conf
    DocumentRoot "/var/www/html/zabbix" <Directory "/var/www/html/zabbix"> ServerName 127.0.0.1 DirectoryIndex index.html index.html.var index.php
    # 安装zabbix-server
    mkdir /var/www/html/zabbix
    cd /a
    cp -rp zabbix-3.4.13/frontends/php/ /var/www/html/zabbix/
    chown -R apache:apache /var/www/html/zabbix/
    chkconfig httpd on
    chmod +x /var/www/html/zabbix/php/setup.php
    
    cd /a/zabbix-3.4.13
    ./configure --enable-server --enable-agent --with-mysql --with-proxy --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl --prefix=/usr/local/zabbix
    make && make install
    echo $?
    #修改zabbix-server的配置,注意三个参数
    #vim /usr/local/zabbix/etc/zabbix_server.conf
      DBName=zabbix
      DBUser=zabbix
      DBPassword=123456

    配置zabbix-server的启动文件

    cp /a/zabbix-3.4.13/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
    cp /a/zabbix-3.4.13/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd
    
    vim /etc/init.d/zabbix_server
    
    在#!/bin/sh下面一行添加
    #chkconfig: 345 95 95       ##这里再配置文件里面行首“#”表示注释
    #description: Zabbix_Server     ##这里再配置文件里面行首“#”表示注释
    
    vim /etc/init.d/zabbix_agentd
    
    在#!/bin/sh下面一行添加
    #chkconfig: 345 95 95       ##这里是在配置文件里面行首“#”表示注释,
    #description: Zabbix_agentd     ##这里再配置问价里面行首“#”表示注释
    
    修改这两个文件的BASEDIR的绝对路径(下面的命令无效。手动修改):
    sed -i 's#BASEDIR=/usr/local/#BASEDIR=/usr/local/zabbix#g' /etc/init.d/zabbix_{server,agentd}
    添加到开机自启动里:
    chkconfig --add /etc/init.d/zabbix_server
    chkconfig --add /etc/init.d/zabbix_agentd
    chkconfig zabbix_server on
    chkconfig zabbix_agentd on

    验证 :

    [root@zabbix-self conf]# ss -tunl
    Netid  State      Recv-Q Send-Q                           Local Address:Port                             Peer Address:Port
    tcp    LISTEN     0      128                                         :::10050                                      :::*     
    tcp    LISTEN     0      128                                          *:10050                                       *:*     
    tcp    LISTEN     0      128                                         :::10051                                      :::*     
    tcp    LISTEN     0      128                                          *:10051                                       *:*     
    tcp    LISTEN     0      50                                           *:3306                                        *:*     
    tcp    LISTEN     0      128                                         :::80                                         :::*     
    tcp    LISTEN     0      128                                         :::22                                         :::*     
    tcp    LISTEN     0      128                                          *:22                                          *:*     
    tcp    LISTEN     0      100                                        ::1:25                                         :::*     
    tcp    LISTEN     0      100                                  127.0.0.1:25                                          *:*     

    通过web端继续配置:

    http://10.101.93.230/php/setup.php
    在web页面里有个:Zabbix server name  : zabbix-server
    登陆:Admin/zabbix

    更换字体:

    [root@zabbix-test fonts]# rz -E   (上传字体到: /var/www/html/zabbix/php/fonts/ )
    [root@zabbix-test fonts]# cd /var/www/html/zabbix/php/fonts/
    [root@zabbix-test fonts]# mv STKAITI.TTF DejaVuSans.ttf
    mv: overwrite `DejaVuSans.ttf'? yes
    [root@zabbix-test fonts]# chown apache. DejaVuSans.ttf
    [root@zabbix-test fonts]# service httpd restart

    2,proxy端的配置                                                                                                                                               

    proxy机器的IP:192.168.1.131,主机名:zabbix-proxy

    源码包安装:

    yum install gcc mysql-community-devel libxml2-devel unixODBC-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-devel pcre pcre-devel
    yum -y install mysql mysql-server mysql-devel
    service mysqld start
    useradd zabbix
    tar fx  zabbix-3.2.1.tar.gz

    配置mysql

    mysql>
    create database zabbix_proxy; 授权: grant all on zabbix_proxy.
    * to 'zabbix'@'host' identified by 'zabbix'; grant all on zabbix_proxy.* to 'zabbix'@'zabbix-proxy' identified by 'zabbix'; grant all on zabbix_proxy.* to 'zabbix'@'192.168.1.131' identified by 'zabbix'; grant all on zabbix_proxy.* to 'zabbix''@'%' identified by 'zabbix'; flush privileges; mysql zabbix_proxy < zabbix-3.2.1/database/mysql/schema.sql  #proxy端只需要导入这个文件

    安装 zabbix-proxy

    cd zabbix-3.2.1
    ./configure --prefix=/usr/local/zabbix --enable-proxy --enable-agent --with-mysql --with-net-snmp --with-libcurl
    make
    make install

    配置zabbix-proxy

    vim /usr/local/zabbix/etc/zabbix_proxy.conf
    
    Server=IP                      #zabbix服务端IP
    Hostname=Zabbix_proxy          #必须和WEB页面添加代理时设置的名称一致
    LogFile=/tmp/zabbix_proxy.log    #日志文件路径
    DBHost=IP                      #数据库IP
    DBName=zabbix_proxy              #数据库名
    DBUser=user                    #数据库用户名
    DBPassword=password            #数据库密码
    ConfigFrequency=60               #配置文件同步间隔
    DataSenderFrequency=5            #数据同步间隔

    配置zabbix-proxy上的agent的配置文件

    vim /usr/local/zabbix/etc/zabbix_angetd.conf  (修改一下两处配置)
       Server=192.168.1.130  (IP写成zabbix- server端的IP)
       ServerActive=192.168.1.130   (IP写成zabbix- server端的IP)
    cp /mnt/zabbix-3.1.12/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
    sed -i 's#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g' /etc/init.d/zabbix_agentd
    chmod +x /etc/init.d/zabbix_agentd
    
    启动zabbix proxy服务
    /usr/local/zabbix/sbin/zabbix_proxy
    
    启动zabbix agent服务
    /etc/init.d/zabbix_agentd start 

     

    3,zabbix-agent的配置(IP:192.168.1.138)                                                                                                                

    客户端安装zabbix:

    yum -y install gcc gcc-c++ make lrzsz  pcre*
    useradd zabbix
    tar fx zabbix-3.4.13.tar.gz
    cd zabbix-3.4.13
    ./configure --enable-agent --prefix=/usr/local/zabbix
    make && make install

    配置zabbix-agent

    cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
    sed -i 's#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g' /etc/init.d/zabbix_agentd
    chmod +x /etc/init.d/zabbix_agentd
    sed -i 's#Server=127.0.0.1#Server=10.101.51.17#g' /usr/local/zabbix/etc/zabbix_agentd.conf
    sed -i 's#ServerActive=127.0.0.1#ServerActive=10.101.51.17#g' /usr/local/zabbix/etc/zabbix_agentd.conf
    /etc/init.d/zabbix_agentd start

    在zabbix-server上的web端上进行操作:

    新建代理服务器

    填写代理服务器主机名称和监控的主机(注:选择的主机的配置文件zabbix_agent.conf要把Server项指向proxy的IP)

    新建客户端主机添加到proxy
    配置agent端的配置文件(安装成功前提)

    新建监控主机->填写相关信息后,选择监控模板

    页面往下拉选择,选择代理服务器:

    等待十分钟,最后“监控灯”绿色


  • 相关阅读:
    事务(进程 ID 133)与另一个进程被死锁在 锁 资源上,并且已被选作死锁牺牲品的解决方案
    Waiting for cache lock
    Win11系统将软件安装在C盘后,打开软件会有无法正常读写C盘下文件的问题
    SharePoint 2010 微软学习教程
    Oracle 远程连接配置文件
    如何优化操作大数据量数据库(几十万以上数据)(二。改善SQL语句)
    SQL BI Microsoft MSDN
    Oracle 错误:ORA06413: Connection not open 解决办法
    2008R2Win7管理一创建域和加入域
    学生表 课程表 成绩表 教师表 50个常用sql语句
  • 原文地址:https://www.cnblogs.com/kaishirenshi/p/9879249.html
Copyright © 2020-2023  润新知