zoukankan      html  css  js  c++  java
  • linux(centos8):lnmp环境编译安装zabbix5.0

    一,zabbix的用途:

    zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案

    zabbix能监视各种网络参数,保证服务器系统的安全运营;

    并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题

    zabbix由2部分构成:  zabbix server/运行在被监控端的zabbix agent

    说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

             对应的源码可以访问这里获取: https://github.com/liuhongdi/

    说明:作者:刘宏缔 邮箱: 371125307@qq.com

    二,准备好lnmp环境:

    1,需要的环境文档:

    https://www.zabbix.com/documentation/current/manual/installation/requirements

    2,需要的软件环境

    php:7.2.0及以上

    mysql: 5.5.62及以上

    需要的php扩展包括:

    gd: 2.0.28及以上
    bcmath
    ctype
    libXML: 2.6.15及以上
    session
    sockets
    mbstring
    gettext

    三,下载zabbix的源码安装包

    1,官方下载站:

    http://repo.zabbix.com/zabbix/

    清华的国内镜像站:

    https://mirrors.tuna.tsinghua.edu.cn/zabbix/

    2,创建下载目录:

    [root@blog zabbix]# mkdir /usr/local/source/zabbix

    3,下载:

    [root@blog zabbix]# wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.0.tar.gz

    四,安装zabbix5.0

    1,官方的安装文档地址:

    https://www.zabbix.com/documentation/current/manual/installation/install

    2,解压缩:

    [root@blog zabbix]# tar -zxvf zabbix-5.0.0.tar.gz 
    [root@blog zabbix]# cd zabbix-5.0.0/

    3,创建zabbix用户

    [root@blog zabbix-5.0.0]# groupadd --system zabbix
    [root@blog zabbix-5.0.0]# useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix

    4,创建zabbix账号的home目录

    [root@blog zabbix-5.0.0]# mkdir -m u=rwx,g=rwx,o= -p /usr/lib/zabbix
    [root@blog zabbix-5.0.0]# chown zabbix:zabbix /usr/lib/zabbix

    5,创建zabbix数据库

    创建数据库的文档地址

    https://www.zabbix.com/documentation/current/manual/appendix/install/db_scripts

    sql语句:

    创建数据库

    create database zabbix character set utf8 collate utf8_bin

    创建zabbix数据库账号

    create user 'zabbix'@'127.0.0.1' identified by 'zabbixpass';

    给zabbix数据库账号授权

    grant all privileges on zabbix.* to 'zabbix'@'127.0.0.1';

    刷新数据库权限数据

    flush PRIVILEGES;

    6,导入数据:

    说明:切换到源码目录/database/mysql/目录下后执行:

    [root@blog mysql]$ /usr/local/soft/mysql/bin/mysql -uzabbix -pzabbixpass zabbix < schema.sql
    mysql: [Warning] Using a password on the command line interface can be insecure.
    [root@blog mysql]$
    /usr/local/soft/mysql/bin/mysql -uzabbix -pzabbixpass zabbix < images.sql mysql: [Warning] Using a password on the command line interface can be insecure.
    [root@blog mysql]$
    /usr/local/soft/mysql/bin/mysql -uzabbix -pzabbixpass zabbix < data.sql mysql: [Warning] Using a password on the command line interface can be insecure.

    7,configure与安装

    在源码目录下执行configure

    [root@blog zabbix-5.0.0]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2  

    安装

    [root@blog zabbix-5.0.0]# make install

    说明:configure时报错的解决:

    报错1:

    configure: error: MySQL library not found

    解决:

    [root@blog zabbix-5.0.0]# dnf install mysql-devel

    报错2:

    configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config

    解决:

    [root@blog zabbix-5.0.0]# dnf install -y net-snmp-devel

    报错3:

    configure: error: Unable to use libevent (libevent check failed)

    解决:

    [root@blog zabbix-5.0.0]# dnf install libevent-devel  -y

    报错4:

    configure: error: Unable to use libpcre (libpcre check failed)

    解决:

    [root@blog zabbix-5.0.0]# dnf -y install pcre*

    8,查看安装效果:

    查看zabbix_server的版本

    [root@blog zabbix-5.0.0]# /usr/local/soft/zabbx-5.0.0/sbin/zabbix_server --version
    zabbix_server (Zabbix) 5.0.0
    Revision 9665d62db0 11 May 2020, compilation time: May 17 2020 09:37:03
    
    Copyright (C) 2020 Zabbix SIA
    License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
    This is free software: you are free to change and redistribute it according to
    the license. There is NO WARRANTY, to the extent permitted by law.

    查看zabbix_agentd的版本

    [root@blog zabbix-5.0.0]# /usr/local/soft/zabbx-5.0.0/sbin/zabbix_agentd --version
    zabbix_agentd (daemon) (Zabbix) 5.0.0
    Revision 9665d62db0 11 May 2020, compilation time: May 17 2020 09:37:03
    
    Copyright (C) 2020 Zabbix SIA
    License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
    This is free software: you are free to change and redistribute it according to
    the license. There is NO WARRANTY, to the extent permitted by law.

    五,配置zabbix_server

    编辑配置文件

    [root@blog etc]# vi zabbix_server.conf

    主要配置项:

    LogFile=/data/zabbix_server/logs/zabbix_server.log
    DBHost=localhost
    DBName=zabbix
    DBUser=zabbix
    DBPort=3306

    创建日志目录

    [root@blog etc]# mkdir /data/zabbix_server/logs

    六,配置zabbix_agentd

    编辑配置文件

    [root@blog etc]# vi zabbix_agentd.conf

    主要配置项:

    LogFile=/data/zabbix_agentd/logs/zabbix_agentd.log
    Server=127.0.0.1
    ServerActive=127.0.0.1 
    Hostname=jdweb

     创建日志目录

    [root@blog etc]# mkdir /data/zabbix_agentd/logs

    七,启动zabbix_server

    [root@blog etc]# /usr/local/soft/zabbx-5.0.0/sbin/zabbix_server

    八,启动zabbix_agentd

    [root@blog etc]# /usr/local/soft/zabbx-5.0.0/sbin/zabbix_agentd

    九,为nginx配置zabbix用来做web管理的虚拟主机

    创建网站root目录

    [root@blog conf.d]# mkdir /data/dweb/zabbix

    配置虚拟主机:

    [root@blog conf.d]# vi zabbix.conf 

    内容:

    server {
        listen       80;
        server_name  zabbix.lhdtest.net;
        root         /data/dweb/zabbix/html;
        index   index.php index.html index.shtml  index.htm;
        access_log      /data/logs/nginxlogs/zabbix.access_log;
        error_log       /data/logs/nginxlogs/zabbix.error_log;
    
        location / {
                try_files $uri $uri/ /index.php?$args;
        }
    
        location ~ .php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_buffer_size 32k;
            fastcgi_buffers 10240 32k;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }

    配置完成后重启nginx

    九,配置web界面

    1,复制ui目录下的文件到虚拟主机目录下

    [root@blog ui]# pwd
    /usr/local/source/zabbix/zabbix-5.0.0/ui
    [root@blog ui]# cp -axv ./ /data/dweb/zabbix/html/ 

    2,访问url

    http://zabbix.lhdtest.net/

    会自动跳转到:

    http://zabbix.lhdtest.net/setup.php

    看截图,点next step

    如果不满足zabbix配置的需求,更新php后重启php-fpm

    无问题后点next step

     

    数据库配置:输入数据库密码

     此处输入保持默认即可,点next step按钮继续

    这个页面显示我们配置的一个摘要,继续点 next step按钮

    看到这个页面,表示安装无问题,点finish结束

    3,如果安装过程中提示不能保存配置文件,

    修改conf目录的权限:

    [root@blog html]# chmod 766 /data/dweb/zabbix/html/conf/*

    4,跳转到登录界面后:

    用默认账号登录:

    The default user name is Admin, password zabbix.

    默认账号:

    用户名:Admin

    密码:zabbix

    十,登录后配置中文/解决中文乱码/修改默认密码

    1,配置中文,解决中文乱码,参见:

    https://www.cnblogs.com/architectforest/p/12911721.html

    2,web界面修改默认密码:

    用默认密码登录后

    左侧菜单->User settings->点 修改密码 按钮

    修改为自定义密码后

    点 更新 按钮即可

    十一,使用systemd管理zabbix-server的服务

    编辑zabbix-server的service文件

    [root@blog system]# vi /usr/lib/systemd/system/zabbix-server.service 

    内容:

    [Unit]
    Description=Zabbix Server
    After=network.target
    After=mysqld.service
    
    [Service]
    Environment="CONFFILE=/usr/local/soft/zabbx-5.0.0/etc/zabbix_server.conf"
    Type=forking
    Restart=on-failure
    PIDFile=/tmp/zabbix_server.pid
    KillMode=control-group
    ExecStart=/usr/local/soft/zabbx-5.0.0/sbin/zabbix_server -c $CONFFILE
    ExecStop=/bin/kill -SIGTERM $MAINPID
    RestartSec=10s
    TimeoutSec=0
    
    [Install]
    WantedBy=multi-user.target

    重新加载service文件

    [root@blog system]# systemctl daemon-reload

    启动命令:

    [root@blog system]# systemctl start zabbix-server.service

    停止命令:

    [root@blog system]# systemctl stop zabbix-server.service

    十二,查看centos版本:

    [root@blog nginxlogs]$ cat /etc/redhat-release
    CentOS Linux release 8.0.1905 (Core)
  • 相关阅读:
    bzoj 1057: [ZJOI2007]棋盘制作
    【NOIP2012】开车旅行
    bzoj 2326: [HNOI2011]数学作业
    一本通1527欧拉回路
    一本通1530 Ant Trip
    一本通1528单词游戏
    luogu1856
    CF1045G
    10.18模拟赛
    10.16模拟赛
  • 原文地址:https://www.cnblogs.com/architectforest/p/12912560.html
Copyright © 2011-2022 走看看