• centos7.9环境下编译安装zabbix5.0.9版本


    centos7.9环境下安装zabbix5.0.9版本

    zabbix最新是5.2版本的,看了下官方的介绍发现5.0才是长期支持版,于是安装5.0,方便后续升级
    打算用yum直接rpm安装省得麻烦,发现各种奇葩问题于是放弃,改用源码编译安装


    zabbix5.0 + mysql + nginx + php7.4

    服务器上本身安装了mysql,nginx所以就省去了安装步骤,这个可以直接通过yum进行安装


    1.zabbix服务端的编译安装

    # 安装依赖

    yum -y install gcc gcc-c++ unixODBC-devel mysql-devel libcurl libcurl-devel libevent libevent-devel fping curl-devel libxml2  libxml2-devel snmpd net-snmp-devel net-snmp

    # 获取源码

    wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.9.tar.gz
    
    tar xf zabbix-5.0.9.tar.gz
    cd zabbix-5.0.9
    ./configure --prefix=/usr/local/zabbix/zabbix-server --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --enable-java

    # 采用多核编译加快编译速度

    make -j 4 && make install

    #参数说明
    --prefix              #编译安装路径
    --enable-server       #启动server端
    --enable-agent        #启动agent端
    --with-mysql          #编译连接mysql相关依赖包
    --with-net-snmp       #启动snmp相关,用于snmp监控设备
    --with-libcurl        #启动curl相关
    --with-libxml2        #启动xml相关
    --with-unixodbc       #启动odbc相关用于监控数据库
    --enable-java         #启动java-agent 用于监控java类

    2.前端的安装

    将前端放在 /data/www/vhosts 目录下

    cp /usr/local/src/zabbix-5.0.9/ui/* /data/www/vhosts/pixzabbix.chinasoft/

    3.创建数据库,导入数据结构

    create database zabbix character set utf8 collate utf8_bin;
    create user zabbix@localhost identified by 'zabbix';
    
    mysql -uroot -p'pass' zabbix < /usr/local/src/zabbix-5.0.9/database/mysql/schema.sql
    mysql -uroot -p'pass' zabbix < /usr/local/src/zabbix-5.0.9/database/mysql/images.sql
    mysql -uroot -p'pass' zabbix < /usr/local/src/zabbix-5.0.9/database/mysql/data.sql

    4.编辑配置文件
    # vi /usr/local/zabbix/zabbix-server/etc/zabbix_server.conf

    LogFile=/tmp/zabbix_server.log
    DBHost=localhost
    DBName=zabbix
    DBUser=zabbix
    DBPassword=zabbix
    Timeout=4
    LogSlowQueries=3000
    StatsAllowedIP=127.0.0.1

    5.安装php7.4

    rpm -ivh http://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm
    yum install wphp74 -y

    安装完成修改配置,修改监听用户和启动用户

    # vi /usr/local/php/etc/php-fpm.conf

    启动 php-fpm

    /etc/init.d/php-fpm74 restart

    # 配置nginx
    # cat /usr/local/nginx/conf//vhost.d/pixzabbix.chinasoft.conf

    server
    {
        listen      80;
        server_name  pixzabbix.chinasoft 47.88.16.249;
        index index.php index.html index.htm;
        root   /data/www/vhosts/pixzabbix.chinasoft;
        access_log /data/www/logs/zabbix/access_zabbix.log  combined;
        error_log  /data/www/logs/zabbix/error_zabbix.log; 
    
        #expires                         
        location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
        {
        expires 30d;
        }
    
        location ~ .*.(js|css)?$
        {
            expires      24h;
        }    
    
        location /webstatus {
            stub_status on;
            access_log off;
        }
    
    
    
        location ~ [^/].php(/|$){
            fastcgi_pass    unix:/tmp/php-fpm74.sock;
            fastcgi_index   index.php;
            include         fastcgi.conf;
        }
    
    }

    # 本地绑定hosts访问pixzabbix.chinasoft 进行zabbix的配置



    6.启动服务端

    /usr/local/zabbix/zabbix-server/sbin/zabbix_server -c  /usr/local/zabbix/zabbix-server/etc/zabbix_server.conf

    补充:

    zabbix日志 /tmp/zabbix_server.log 报错

    1188:20210311:221304.687 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

    解决办法:
    mkdir -p /var/lib/mysql/
    ln -s  /tmp/mysql.sock  /var/lib/mysql/mysql.sock           #创建一个软连接
    chown mysql.mysql /var/lib/mysql/mysql.sock

  • 相关阅读:
    Objective-C 学习记录--toches、Motion/Size/Rect/Point/CGFloat/protocol
    Objective-C 学习记录6--dictionary
    Objc基础学习记录5
    第四篇:web之前端之jquery
    第三篇:web之前端之JavaScript基础
    第二篇:web之前端之css
    第一篇:web之前端之html
    第三篇:杂项之年终总结
    第二篇:杂项之图像处理pillow
    第一篇:杂项之pymysql连接池
  • 原文地址:https://www.cnblogs.com/reblue520/p/14526578.html
Copyright © 2020-2023  润新知