• zabbix server 端安装


    1、系统环境

    [root@crazy-acong ~]# cat /etc/redhat-release 
    CentOS release 6.6 (Final)
    [root@crazy-acong ~]# uname -a
    Linux crazy-acong 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
    [root@crazy-acong ~]# ifconfig eth0 | grep "inet addr" | awk -F : '{print $2}'| awk '{print $1}'
    192.168.1.105

    2、配置时间自动同步

    [root@crazy-acong ~]# crontab -l
    */5 * * * * /usr/sbin/ntpdate pool.ntp.org

    3、Zabbix-Server服务端安装

    这里我们采用 rpm 包进行安装,如果想使用源码包安装可以参考官方文档 https://www.zabbix.com/documentation/2.2/manual/installation/install

    3.1 安装Zabbix官方源和epel源

    [root@crazy-acong ~]# rpm -ivh http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm
    [root@crazy-acong ~]# rpm -ivh http://mirrors.zju.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm

    3.2 yum 安装 zabbix 服务端

    # yum 源在国外,安装的时候可能会比较慢
    [root@crazy-acong ~]# yum -y install zabbix zabbix-get zabbix-server zabbix-web-mysql zabbix-web 
    
    # zabbix 服务端也需要监控,也需要装 zabbix-agent
    [root@crazy-acong ~]# yum -y install zabbix-agent   

    3.2 安装配置 mysql

    # 安装
    [root@crazy-acong ~]# yum install -y mysql-server mysql mysql-devel
    
    # 修改 mysql 配置文件
    [root@crazy-acong ~]# cat /etc/my.cnf 
    [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    user=mysql
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    
    # 添加下面两行
    character-set-server=utf8    # 设置字符集为 utf8
    innodb_file_per_table=1        # 让 innodb 的每个表文件单独存储
    
    [mysqld_safe]
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    
    # 启动 mysql
    [root@crazy-acong ~]# /etc/init.d/mysqld start
    [root@crazy-acong ~]# chkconfig mysqld on
    
    [root@crazy-acong ~]# netstat -lnpt | grep 3306
    tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      1070/mysqld 
    
    # 设置mysql root用户的登录密码
    [root@crazy-acong ~]# mysqladmin -uroot password admin

    3.3 创建 zabbix 的数据库

    [root@crazy-acong ~]# mysql -uroot -padmin
    
    # 注意这里创建 zabbix 数据库的时候一定要设置字符集为 utf8,否则web界面会出现乱码
    mysql> create database zabbix character set utf8;
    mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
    mysql> flush privileges;

    3.4 导入 zabbix-server 数据库

    [root@crazy-acong ~]# mysql -uzabbix -pzabbix
    mysql> use zabbix;
    
    # 先自行查看一下是否存下面需要导入的文件,不同版本编号不一样
    mysql> source /usr/share/doc/zabbix-server-mysql-2.2.17/create/schema.sql;
    
    # 如果安装的是 zabbix-proxy,只需要导入 schema.sql 即可,下面的无需导入,否则 zabbix-proxy 无法正常工作
    
    mysql> source /usr/share/doc/zabbix-server-mysql-2.2.17/create/images.sql;
    
    mysql> source /usr/share/doc/zabbix-server-mysql-2.2.17/create/data.sql;  
    
    # 自行查看表结构
    mysql> show tables; 

    3.5 配置 zabbix_server.conf

    # 默认配置
    [root@crazy-acong ~]#  egrep -v "^#|^$" /etc/zabbix/zabbix_server.conf
    LogFile=/var/log/zabbix/zabbix_server.log
    LogFileSize=0
    PidFile=/var/run/zabbix/zabbix_server.pid
    DBName=zabbix
    DBUser=zabbix
    DBSocket=/var/lib/mysql/mysql.sock
    SNMPTrapperFile=/var/log/snmptt/snmptt.log
    AlertScriptsPath=/usr/lib/zabbix/alertscripts
    ExternalScripts=/usr/lib/zabbix/externalscripts
    # 修改完之后的配置
    [root@crazy-acong ~]# cat /etc/zabbix/zabbix_server.conf LogFile=/var/log/zabbix/zabbix_server.log LogFileSize=0 PidFile=/var/run/zabbix/zabbix_server.pid DBName=zabbix DBUser=zabbix DBSocket=/var/lib/mysql/mysql.sock SNMPTrapperFile=/var/log/snmptt/snmptt.log AlertScriptsPath=/etc/zabbix/alertscripts ExternalScripts=/etc/zabbix/externalscripts # 新增下面两条配置,用于设置连接数据的ip、端口、 密码 DBHost=localhost DBPort=3306 DBPassword=zabbix # 下面部分为性能参数,根据实际情况进行调整,默认只需要上面的配置项即可运行 StartPollers=5 StartIPMIPollers=10 StartPollersUnreachable=10 StartTrappers=10 StartPingers=10 StartDiscoverers=10 VMwareFrequency=60 VMwareCacheSize=8M ListenIP=127.0.0.1 MaxHousekeeperDelete=500 CacheSize=256M StartDBSyncers=40 HistoryCacheSize=128M TrendCacheSize=128M HistoryTextCacheSize=128M ValueCacheSize=128M Timeout=30 TrapperTimeout=300 UnreachablePeriod=45 UnavailableDelay=60 UnreachableDelay=15 FpingLocation=/usr/sbin/fping LogSlowQueries=10000 StartProxyPollers=50 ProxyConfigFrequency=3600

    创建配置文件中所需的目录

    [root@crazy-acong ~]# mkdir /etc/zabbix/alertscripts  /etc/zabbix/externalscripts

    3.6 启动 zabbix-server 服务

    [root@crazy-acong ~]# /etc/init.d/zabbix-server start
    Starting Zabbix server:                                    [确定]
    
    [root@crazy-acong ~]# netstat -lnpt | grep zabbix
    tcp        0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      1307/zabbix_server  
    tcp        0      0 :::10051                    :::*                        LISTEN      1307/zabbix_server 
    
    [root@crazy-acong ~]# chkconfig zabbix-server on

    3.7 启动 httpd 服务

    [root@crazy-acong ~]# /etc/init.d/httpd start
    [root@crazy
    -acong ~]# netstat -lnpt | grep httpd tcp 0 0 :::80 :::* LISTEN 1371/httpd [root@crazy-acong ~]# chkconfig httpd on

    3.8 防火墙配置

    [root@crazy-acong ~]# vim /etc/sysconfig/iptables
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 10051 -j ACCEPT
    -A OUTPUT -m state --state NEW -m tcp -p tcp --dport 10050 -j ACCEPT

    # 10050 是 Agetn 的端口,Agent 采用被动方式,Server 主动连接 Agent 的 10050 端口
    # 10051 是 Server 的端口,Agent 采用主动或 Trapper 方式,会连接 Server 的10051 端口 [root@crazy
    -acong ~]# /etc/init.d/iptables restart

    3.9 修改 http 配置文件

    [root@crazy-acong ~]# cat /etc/httpd/conf.d/zabbix.conf 
    #
    # Zabbix monitoring system php web frontend
    #
    
    Alias /zabbix /usr/share/zabbix
    
    <Directory "/usr/share/zabbix">
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    
        <IfModule mod_php5.c>
            php_value max_execution_time 300
            php_value memory_limit 128M
            php_value post_max_size 16M
            php_value upload_max_filesize 2M
            php_value max_input_time 300
            php_value date.timezone Asia/Shanghai
        </IfModule>
    </Directory>
    
    <Directory "/usr/share/zabbix/conf">
        Order deny,allow
        Deny from all
        <files *.php>
            Order deny,allow
            Deny from all
        </files>
    </Directory>
    
    <Directory "/usr/share/zabbix/api">
        Order deny,allow
        Deny from all
        <files *.php>
            Order deny,allow
            Deny from all
        </files>
    </Directory>
    
    <Directory "/usr/share/zabbix/include">
        Order deny,allow
        Deny from all
        <files *.php>
            Order deny,allow
            Deny from all
        </files>
    </Directory>
    
    <Directory "/usr/share/zabbix/include/classes">
        Order deny,allow
        Deny from all
        <files *.php>
            Order deny,allow
            Deny from all
        </files>
    </Directory>

    3.10 重启 httpd 服务

    [root@crazy-acong ~]# /etc/init.d/httpd restart

    3.11 Web 界面配置

    在浏览器中打开链接 http://ip/zabbix, 然后按照下面截图流程操作

     

     

  • 相关阅读:
    tar 只解压tar包中某个文件
    mui项目中如何使用原生JavaScript代替jquery来操作dom
    uploadify3.2.1的参数设置
    String扩展 让你在PadLeft和PadRight时不再受单双字节问题困扰
    Eziriz .NET Reactor(.net混淆器) v5.9 完美安装破解版(附破解文件)
    小程序要求的 TLS 版本必须大于等于 1.2
    如何在ASP.NET 网站项目中使用C# 6?
    XML 文档(1, 2)中有错误:不应有 <xml xmlns=''>
    导出toolStrip1中的图标
    windows media player 官方修复工具下载及修复方法
  • 原文地址:https://www.cnblogs.com/CongZhang/p/6557678.html
Copyright © 2020-2023  润新知