• Zabbix安装配置


    #一 服务端配置
    #1.配置前先关闭iptables和SELINUX,避免安装过程中报错。
    service iptables stop
    chkconfig iptables off
    getenforce
    #Disabled
    setenforce 0

    #添加iptables防火墙放行
    iptables -I INPUT -p tcp -m multiport --destination-port 10050:10055 -j ACCEPT
    -A INPUT -p tcp --dport 80 -j ACCEPT

    一、查看SELinux状态命令:
    1、/usr/sbin/sestatus -v  ##如果SELinux status参数为enabled即为开启状态
    SELinux status:  enabled
    2、getenforce  ##也可以用这个命令检查
    二、关闭SELinux方法:
    1、临时关闭(不用重启机器):
    #复制代码
    #代码如下:
    #setenforce 0 #设置SELinux 成为permissive模式
    #setenforce 1 设置SELinux 成为enforcing模式
    2、修改配置文件需要重启机器:
    #修改/etc/selinux/config 文件
    #将SELINUX=enforcing改为SELINUX=disabled
    #重启机器即可


    #2.安装lamp环境
    yum install -y httpd mysql mysql-server mysql-devel php php-mysql php-common php-mbstring php-gd php-odbc php-xml php-pear

    #3.下载zabbix-2.0.6.tar.gz

    #4.安装zabbix组件
    yum install -y curl curl-devel net-snmp net-snmp-devel perl-DBI

    #5.创建用户账号(server,agent)
    useradd zabbix
    usermod -s /sbin/nologin zabbix


    #6.创建zabbix数据库并导入zabbix数据库(server)
    tar zxvf zabbix-2.0.6.tar.gz
    mysqladmin -u root password zxsoft
    mysql –uroot –pzxsoft

    mysql>
    #mysql下
    create database zabbix character set utf8;
    grant all on zabbix.* to zabbix@localhost identified by 'zxsoft';
    use zabbix;

    source /root/zabbix-2.2.6/database/mysql/schema.sql
    source /root/zabbix-2.2.6/database/mysql/images.sql
    source /root/zabbix-2.2.6/database/mysql/data.sql



    #7.编译安装,如果是客户端安装选择--enable-agent就行了。
    [root@zabbix ~]#cd /root/zabbix-2.0.6
    [root@zabbix zabbix-2.0.6]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl 
    #(可以用--prefix=/usr/local/ 指定安装目录)
    #报错: checking for main in -lmysqlclient... no
    #     configure: error: Not found mysqlclient library
    #解决:[root@zabbix zabbix-2.0.6]# ln -s /usr/lib64/mysql/libmysqlclient.so.16 /usr/lib64/mysql/libmysqlclient.so
    #***********************************************************
    #*            Now run 'make install'                       *
    #*            Thank you for using Zabbix!                  *
    #*              <http://www.zabbix.com>                    *
    #***********************************************************
    make install


    #8.编辑配置文件
    [root@zabbix zabbix-2.0.6]# grep -vE '(^#|" "|^$)' /usr/local/etc/zabbix_server.conf >> /usr/local/etc/zabbix_server.conf.bak
    [root@zabbix zabbix-2.0.6]# cd /usr/local/etc/
    [root@zabbix etc]# cp zabbix_server.conf.bak zabbix_server.conf
    [root@zabbix etc]# grep -vE '(^#|" "|^$)' zabbix_agentd.conf >> zabbix_agentd.conf.bak
    [root@zabbix etc]# cp zabbix_agentd.conf.bak zabbix_agentd.conf
    #提示 cp: overwrite `zabbix_agentd.conf'? y
    [root@zabbix etc]# more zabbix_server.conf 
    #服务端的配置
    LogFile=/var/log/zabbix_server.log
    DBHost=localhost
    DBName=zabbix
    DBUser=zabbix
    DBPassword=zabbix
    #我这查看的时候是空的,可能前面操作有问题吧,如果是空的,直接用vim编辑,把上面几行复制进去就行了
    [root@zabbix etc]# more zabbix_agentd.conf #客户端配置
    LogFile=/tmp/zabbix_agentd.log
    Server=127.0.0.1
    ServerActive=127.0.0.1
    Hostname=Zabbix server
    [root@zabbix etc]# touch /var/log/zabbix_server.log
    [root@zabbix etc]# touch /var/log/zabbix_agentd.log
    [root@zabbix etc]# chmod 777 /var/log/zabbix_*

    #9.启动服务(server,agent)
    [root@zabbix zabbix-2.0.6]# cp misc/init.d/tru64/zabbix_server /etc/init.d/
    [root@zabbix zabbix-2.0.6]# cp misc/init.d/tru64/zabbix_agentd /etc/init.d/
    [root@zabbix zabbix-2.0.6]# chmod +x /etc/init.d/zabbix_*
    #在文件头部#!/bin/bash下面分别添加两行
    #!/bin/sh
    #chkconfig: 35 95 95
    #description:zabbix Agent server
    #添加服务
    [root@zabbix zabbix-2.0.6]# chkconfig --add zabbix_server
    [root@zabbix zabbix-2.0.6]# chkconfig --add zabbix_agentd
    #设置服务器开机自动启动
    [root@zabbix ~]# chkconfig zabbix_server on
    [root@zabbix ~]# chkconfig zabbix_agentd on
    [root@zabbix ~]# /etc/init.d/zabbix_server start
    Zabbix server started.
    [root@zabbix ~]# /etc/init.d/zabbix_agentd start
    Zabbix agent started.
    [root@zabbix ~]# ps -ef |grep zabbix
    zabbix    1803     1  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_agentd
    zabbix    1805  1803  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_agentd
    zabbix    1806  1803  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_agentd
    zabbix    1807  1803  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_agentd
    zabbix    1808  1803  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_agentd
    zabbix    1814     1  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_server
    root      2043  2006  0 08:23 pts/0    00:00:00 grep zabbix
    [root@zabbix ~]# netstat -lantp |grep 10050
    tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      1803/zabbix_agentd
    [root@zabbix ~]# netstat -lantp |grep 10051
    tcp        0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      2308/zabbix_server


    #10.安装zabbix web界面(server)
    #复制php文件,zabbix的终端程序是用php写的,因此需要一个支持php脚本解析的web服务器。然后将frontends/php下面的php文件拷贝到web服务器html文件目录下面。
    [root@zabbix zabbix-2.0.6]# cp -r frontends/php /var/www/html/zabbix
    [root@zabbix html]#service httpd restart
    Stopping httpd: [  OK  ]
    Starting httpd: [  OK  ]

    #报错:根据提示修改/etc/php.ini文件里的参数
    [root@zabbix zabbix]# yum install -y php-bcmath
    #设置时区,修改php.ini,在php.ini中找到data.timezone =去掉它前面的;号,然后设置data.timezone = “Asia/Shanghai”;即可
    [root@zabbix zabbix]# /etc/init.d/httpd restart
    Stopping httpd: [  OK  ]
    Starting httpd: [  OK  ]


    #mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) [include/db.inc.php:77]
    #Error connecting to database [Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)]
    #连接数据库时报错  测试不成功
    port = 3306
    socket = /var/lib/mysql_data/mysql.sock
    #这个添加后,不行,重新启动mssqld服务又可以了,不知是不是有关

    #给/tmp/mysql.sock设置个软连接: 测试没有/tmp/mysql.sock 这个文件
    #ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock 
    #socket=/var/lib/mysql/mysql.sock

    #如果提示创建文件失败,更改目录权限就行了 下面是报错
    #Configuration file
    #"/var/www/html/zabbix/conf/zabbix.conf.php"
    #created: Fail

    #登陆时初始用户名admin密码zabbix

    web支持中文设置
    #vim /var/www/html/zabbix/include/locales.inc.php  
    #zh_CN false改为true

    图像无显示或乱码 修改zabbix页面管理的中文字体设置
    #找到本地C:WindowsFontssimkai.ttf(楷体)
    #sed -i ‘s/graphfont/simkai/g’ include/defines.inc.php
    [iyunv@zabbix-server zabbix-2.4.5]# vi /var/www/html/zabbix/include/defines.inc.php
    #修改如下2行
    define('ZBX_FONT_NAME', 'simkai');
    define('ZBX_GRAPH_FONT_NAME',  'simkai');


    zabbix simple check 配置
    #fping测试网卡存活
    #下载源码包编译安装
    wget http://www.fping.org/dist/fping-3.10.tar.gz
    tar zxvf fping-3.10.tar.gz
    cd fping-3.10
    ./configure --prefix=/usr/local/fping/
    make && make install
    #根据安装地址,可能需要更改配置文件
    修改zabbix_server.conf配置文件
    vim /usr/local/zabbix/etc/zabbix_server.conf
    把FpingLocation路径修改为刚安装的fping路径。
    FpingLocation=/usr/local/fping/sbin/fping
    如果不修改zabbix_server.conf配置件需要使用软连接到/usr/local/sbin/fping,zabbix默认fping的路径是/usr/sbin/fping
    ln -s /usr/sbin/fping /path/to/non-existant/fping
    ln -s /usr/sbin/fping6 /path/to/non-existant/fping6
    chmod 4755 /usr/local/sbin/fping
    service zabbix_server restart  #重启服务
    3.修改fping权限(如果不设下面权限,zabbix服务端会采集不到数据)
    # chown root:zabbix /usr/local/fping/sbin/fping
    # chmod 4710 /usr/local/fping/sbin/fping
    4.zabbix用户测试fping命令
    /usr/local/fping/sbin/fping www.baidu.com
    www.baidu.com is alive   # 说明命令返回成功。

    本地邮件服务器发送邮件告警
    #CentOS默认已安装postfix 开机自动启动
    #mailx版本12.4
    yum install mailx #版本12

    使用外部邮件发送告警,本地测试正常,zabbix测试失败
    vim /etc/mail.rc
    set from=malin@safefw.com smtp=smtp.exmail.qq.com
    set smtp-auth-user=malin@safefw.com smtp-auth-password=************ smtp-auth=login

  • 相关阅读:
    Linux下通过C++码来操作MySQL数据库
    Linux TCP/IP 实例
    Linux UDP C/S例子
    memcached: error while loading shared libraries: libevent-2.0.so.5: cannot o解决
    /etc/profile和/root/.bash_profile有什么区别
    双Y轴柱线结合图(FusionChart)
    分组柱状图(FusionChart)
    远程过程调用(RPC)
    软件系统开发中的数据交换协议
    RPC 远程过程调用协议
  • 原文地址:https://www.cnblogs.com/liuzt/p/6073770.html
Copyright © 2020-2023  润新知