• 一步一步超级详细的zabbix安装教程


    安装说明
    1. 虚拟机上安装两台全新Linux: zabbix-server:192.168.255.128 zabbix-agent :192.168.255.129
    2. zabbix-server上要安装 apache mysql php zabbix-server zabbix-agent(可选组件)
    3. zabbix-agent上要安装 apache mysql php zabbix-agent
    4. 安装版本zabbix-2.2.2

    zabbix-server(192.168.255.128)上的操作
    1、安装基础环境Apache mysql php
    yum install -y httpd mysql mysql-server mysql-devel php php-mysql php-common php-mbstring php-gd php-odbc php-xml php-pear libXpm php-bcmath php-gd t1lib
    yum安装和二装的区进制包安别在于二进制包可以指定安装目录,yum可以解决依赖关系
    设置http开机启动 #chkconfig httpd on
    设置mysql开机启动 #chkconfig mysqld on
    启动http:#service httpd start
    启动数据库: #service mysqld start

    2、下载zabbix-2.2.2.tar.gz, 放到/root目录下
    tar -zxvf zabbix-2.2.2.tar.gz
    cd /root/zabbix-2.2.2

    3、初始化zabbix数据库
    zabbix server与proxy需要数据库,angent不需要。尤其要注意的是proxy只需要导入一个sql文件,而server一共要导入3个sql文件。我当时在搭建proxy的时候导入了3个sql,导致出现报错。后来才发现proxy只需要导入一个表结构即可。
    进入mysql: #mysql -uroot -p123456
    创建 zabbix库: mysql> create database zabbix character set utf8;
    退出数据库: mysql> exit
    按顺序导入三个sql文件【在配置文件Zabbix_server.conf中查看这三个sql文件介绍】
    /usr/bin/mysql -uroot -p123456 zabbix < /root/zabbix-2.2.2/database/mysql/schema.sql (表结构)
    #/usr/bin/mysql -uroot -p123456 zabbix < /root/zabbix-2.2.2/database/mysql/images.sql (图片库)
    #/usr/bin/mysql -uroot -p123456 zabbix < /root/zabbix-2.2.2/database/mysql/data.sql (初始脚本)
    在此再说另一种导入方法,两者均可:
    mysql> use zabbix;
    mysql> source /root/zabbix-2.2.2/database/mysql/schema.sql
    mysql> source /root/zabbix-2.2.2/database/mysql/images.sql
    mysql> source /root/zabbix-2.2.2/database/mysql/data.sql

    4、安装zabbix
    先安装必须的依赖组件
    yum install net-snmp-devel libxml2-devel libcurl-devel
    编译安装
    #./configure –prefix=/usr/local/zabbix-server –enable-server –enable-agent –with-mysql –with-net-snmp –with-libcurl –with-libxml2
    如果报错: configure: error: Not found mysqlclient library
    解决:yum install mysql-devel
    安装
    #make install 没有出现error就说明成功了

    4、配置zabbix开机启动
    配置zabbix_server开机启动
    cp /root/zabbix-2.2.2/misc/init.d/fedora/core/zabbix_server /etc/init.d/
    vim /etc/init.d/zabbix_server
    在文件头部#!/bin/bash下面添加两行,注意前面的‘#’不能取消掉
    #!/bin/sh
    #chkconfig: 35 95 95 (35代表不同的运行级别,第二个参数:启动序号,第三个参数:关闭序号)
    #description:zabbix_server
    并修改BASEDIR=/usr/local/zabbix-server //这是安装目录

    配置zabbix_agentd开机启动
    cp /root/zabbix-2.2.2/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
    vim /etc/init.d/zabbix_agentd
    在文件头部#!/bin/bash下面添加两行
    #!/bin/sh
    #chkconfig: 35 95 95
    #description:zabbix_agentd
    并修改BASEDIR=/usr/local/zabbix-server
    添加服务
    # chkconfig –add zabbix_server
    # chkconfig –add zabbix_agentd
    设置开机自动启动
    # chkconfig zabbix_server on
    # chkconfig zabbix_agentd on

    5、修改配置文件
    配置zabbix_server.conf
    vim /usr/local/zabbix-server/etc/zabbix_server.conf
    DBName=zabbix
    DBUser=root
    DBPassword=123456
    DBPort=3306

    配置zabbix_agentd.conf
    vim /usr/local/zabbix-server/etc/zabbix_agentd.conf
    Server=127.0.0.1
    Hostname=Zabbix Server //这个hostname要记住,后面有用处。

    6、启动前先创建zabbix用户
    为了安全考虑,zabbix只使用普通用户运行,假如你当前用户叫ttlsa,那么你运行他,他便使用ttlsa身份运行。但是如果你在root用户下运行zabbix,那么zabbix将会主动使用zabbix用户来运行。但是如果你的系统没有名叫zabbix的用户,启动zabbix-server时会报错,如下:
    zabbix_server [2332]: user zabbix does not exist
    zabbix_server [2332]: Cannot run as root!
    所以要创建zabbix用户
    # useradd zabbix

    7、启动服务
    #service zabbix_server start
    #service zabbix_agentd start

    8、创建web目录:
    #mkdir -p /var/www/html/zabbix
    #cp -r /root/zabbix-2.2.2/frontends/PHP/* /var/www/html/zabbix/
    授权:chown -R apache.apache /var/www/html/zabbix/

    9、修改php.ini文件中参数(不修改的话后面zabbix界面installation进行不下去的)
    vim /etc/php.ini,修改如下参数

    max_execution_time = 300
    memory_limit = 128M
    post_max_size = 16M
    upload_max_filesize = 2M
    max_input_time = 300
    date.timezone Asia/Shanghai #或者PRC

    修改完成后必须重启http才能生效 :service httpd restart

    10、zabbix-agent上的操作
    tar zxvf zabbix-2.2.2.tar.gz
    cd zabbix-2.2.2
    ./configure –prefix=/usr/local/zabbix-agent –enable-agent
    make install
    useradd zabbix

    vim /usr/local/zabbix-agent/etc/zabbix_agentd.conf
    Server=192.168.255.128
    ServerActive=192.168.255.128
    Hostname=zabbix.agent
    User=zabbix # 与上面创建的用户保持一致

    配置zabbix_agent开机启动
    vim /etc/init.d/zabbix_agentd
    在文件头部#!/bin/bash下面分别添加两行
    #!/bin/sh
    #chkconfig: 35 95 95
    #description:zabbix_agentd
    添加服务
    # chkconfig –add zabbix_agentd

    设置开机自动启动
    # chkconfig zabbix_agent on

    启动zabbix_agentd
    service zabbix_agentd start

    11、用浏览器访问http://192.168.255.128/zabbix,按照提示安装

    若zabbix界面显示报错:Zabbix server is not running:be information displayed may not be current.
    解决办法:修改服务端文件 vim /var/www/html/zabbix/conf/zabbix.conf.php
    $ZBX_SERVER = ‘localhost’; //修改localhost为zabbix-server的ip:192.168.255.128

    报错:13993:20170224:001412.667 Zabbix agent item “proc.num[]” on host “Zabbix server” failed: first network error, wait for 15 seconds
    13994:20170224:001427.902 resuming Zabbix agent checks on host “Zabbix server”: connection restored
    解决:关闭 iptables或者seLinux

    然后就可以通过web界面添加主机进行监控,这些内容不在本文叙述范围内

  • 相关阅读:
    老大叔开博感想
    模板
    Codeforces Round #685 (Div. 2) 题解
    CF830E Perpetual Motion Machine 题解
    THUWC2020游记
    数论
    后缀数组学习笔记
    Codeforces Round #466 (Div. 2)
    博客停写,搬家到www.54kaikai.com
    lda 主题模型--TOPIC MODEL--Gibbslda++结果分析
  • 原文地址:https://www.cnblogs.com/fanren224/p/8457259.html
Copyright © 2020-2023  润新知