• Centos7+lnmp+zabbix4+分离mysql实验


    一、简介

      1、什么是zabbix

        zabbix是一个企业级的、开源的、分布式的监控套件。

        zabbix可以对网络和服务进行完整性,健康性的监控。zabbix利用灵活的告警机制,可以实验微信,短信和邮件自动报警,zabbix利用存储的监控数据提供监控报告及实现图形化显示。

        zabbix支持主动轮询和被动捕获,zabbix所有的报告、统计信息和配置参数都可以通过基于web的前端页面可以确保您从任何方面评估您的网络状态和服务器健康性

        重要的是zabbix还是免费的。   

      2、zabbix特性    

        zabbix是一个高度集成的网络监控套件,通过一个软件包即可提供如下特性

          数据收集

            可用性和性能检查

            支持SNMP(包括捕获和主动轮训),IPMI,JMX,VMware监控

            自定义检查

            按照自定义的间隔收集需要的数据

          灵活的阈值定义

            可以非常灵活的定义问题阈值,称之为触发器,触发器从后端数据库获取参考值

          高级告警配置

            可以根据升级计划,接收方和媒体类型来定制发送告警通知,使用宏变量可以是告警通知更有意义更高效,自动化动作包含执行远程命令

          实时绘图

            使用内置图表绘制功能可以将监控项的内容立即绘制成图表

          扩展的图形化显示

            能够自定义图形,图像中可将多个监控项组合在一个视图展示

            网络拓扑图

            以仪表盘的样式展现自定义的展现和幻灯片

            报告

            监控资源高级(业务)视图

          历史数据存储

            数据存储在数据库中

            可配置历史数据

            内置数据管理机制

          配置简单

            将被监控对象添加为主机

            主机被创建用于监控,在数据库中是唯一的

            应用模板来监控设备   

          模板使用

            在模板中分组检查

            模板可以关联其他模板

          网络自动发现

            自动发现网络设备

            监控代理自动注册

            发现文件系统,网络接口和snmp oid 值

          简介的web界面

            web前端基于php

            可从任何地方访问

            你可以定制自己的操作方式

            审核日志

          API

             提供了对外的可编程接口,用于批量操作,第三方软件集成和其他目的

          权限管理系统

            安全用户认证

            特定用户可以限制访问特定视图

          功能强大并易于扩展的监控代理

            部署在被监控对象上

            可以部署在linux和windows上

          二进制代码

            为了性能和更少内存的占用,用c语言编写

            便于移植

          为复杂环境准备

            使用zabbix proxy代理服务器,使得远程监控更简单

      3、zabbix监控组件及流程

        主要由三大部分组成zabbix server,zabbix proxy,agent客户端

        zabbix server包括web GUI、database、zabbix server。

        监控组件图示如下:

        

        zabbix监控流程如下图:

        

        zabbix监控的完整流程,agent安装在被监控的主机上,agent负责定期收集客户端各项数据,并发送到zabbix server端,zabbix server收到数据,将数据存储到数据库中,用户基于zabbix web 可以看到数据在前端展现的图像。

        4、zabbix官方文档

        https://www.zabbix.com/documentation/4.0/zh/manual/quickstart/login

        

    二、开始安装并配置

      1、架构

      

      2、环境

      zabbix server :192.168.216.51

      zabbix mysql: 192.168.216.52

      zabbix agent: 192.168.216.53

      

      3、web1安装软件,linux+nginx+php

        配置好epel源,zabbix源及关闭selinux,firewall

        

    1 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo   #下载最新的base 
    2 yum install epel-release                                         #安装epel
    3 yum install http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm #安装zabbix

        各软件版本

        2.1、安装nginx

        51 上部署nginx,zabbx,php-fpm

         zabbix-server-mysql  #主程序包及数据库文件

         zabbix-web-mysql    #Zabbix的web端会通过这些数据,来展示绘图

         zabbix-get        #为了便于agent端发起测试采集数据请求用得

           

            一些依赖的作用

           OpenIPMI-libs #即智能平台管理

           iksemel  #跨平台XML解析器

           fping  #用于向网络主机发送ICMP回应请求

    1 yum install nginx -y
    2 yum install zabbix-server-mysql zabbix-web-mysql zabbix-get
    3 yum install -y php php-devel php-fpm php-mysql php-common php-devel php-gd libjpeg* php-imap php-
    ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel

      各软件版本

     1 [root@web1 yum.repos.d]# rpm -qa |grep zabbix 
     2 zabbix-release-4.0-1.el7.noarch
     3 zabbix-server-mysql-4.0.4-1.el7.x86_64
     4 zabbix-web-mysql-4.0.4-1.el7.noarch
     5 zabbix-web-4.0.4-1.el7.noarch
     6 zabbix-get-4.0.4-1.el7.x86_64
     7 [root@web1 yum.repos.d]# rpm -qa |grep zabbix
     8 zabbix-release-4.0-1.el7.noarch
     9 zabbix-server-mysql-4.0.4-1.el7.x86_64
    10 zabbix-web-mysql-4.0.4-1.el7.noarch
    11 zabbix-web-4.0.4-1.el7.noarch
    12 zabbix-get-4.0.4-1.el7.x86_64
    13 [root@web1 yum.repos.d]# rpm -qa |grep php*
    14 php-process-5.4.16-46.el7.x86_64
    15 php-ldap-5.4.16-46.el7.x86_64
    16 php-xml-5.4.16-46.el7.x86_64
    17 hyphen-2.8.6-5.el7.x86_64
    18 php-mysql-5.4.16-46.el7.x86_64
    19 php-mcrypt-5.4.16-7.el7.x86_64
    20 libmspack-0.5-0.4.alpha.el7.x86_64
    21 php-gd-5.4.16-46.el7.x86_64
    22 php-bcmath-5.4.16-46.el7.x86_64
    23 php-pear-1.9.4-21.el7.noarch
    24 plymouth-graphics-libs-0.8.9-0.26.20140113.el7.centos.x86_64
    25 php-mbstring-5.4.16-46.el7.x86_64
    26 php-pdo-5.4.16-46.el7.x86_64
    27 php-imap-5.4.16-7.el7.x86_64
    28 php-xmlrpc-5.4.16-46.el7.x86_64
    29 libreoffice-graphicfilter-5.0.6.2-3.el7.x86_64
    30 gvfs-gphoto2-1.22.4-8.el7.x86_64
    31 graphite2-1.3.6-1.el7_2.x86_64
    32 php-common-5.4.16-46.el7.x86_64
    33 php-odbc-5.4.16-46.el7.x86_64
    34 php-fpm-5.4.16-46.el7.x86_64
    35 libgphoto2-2.5.2-3.el7.x86_64
    36 php-5.4.16-46.el7.x86_64
    37 php-devel-5.4.16-46.el7.x86_64
    38 php-cli-5.4.16-46.el7.x86_64
    39 python2-cryptography-1.3.1-3.el7.x86_64
    40 hyphen-en-2.8.6-5.el7.noarch
    41 [root@web1 yum.repos.d]# 

      

    1 Installed:
    2   zabbix-get.x86_64 0:4.0.4-1.el7  zabbix-server-mysql.x86_64 0:4.0.4-1.el7  zabbix-web-mysql.noarch 0:4.0.4-1.el7 
    3 
    4 Dependency Installed:
    5   OpenIPMI-libs.x86_64 0:2.0.23-2.el7     OpenIPMI-modalias.x86_64 0:2.0.23-2.el7     fping.x86_64 0:3.10-4.el7    
    6   iksemel.x86_64 0:1.4-2.el7.centos       zabbix-web.noarch 0:4.0.4-1.el7            
    7 
    8 Complete!

     

       2.2、部署数据库

        52 上部署

    yum install  -y mariadb-embedded mariadb-libs mariadb-bench mariadb mariadb-server

       

     1 Installed:
     2   mariadb.x86_64 1:5.5.60-1.el7_5  mariadb-bench.x86_64 1:5.5.60-1.el7_5  mariadb-embedded.x86_64 1:5.5.60-1.el7_5 
     3 
     4 Dependency Installed:
     5   perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7              perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7             
     6   perl-DBI.x86_64 0:1.627-4.el7                             perl-Data-Dumper.x86_64 0:2.145-3.el7                   
     7   perl-GD.x86_64 0:2.49-3.el7                               perl-IO-Compress.noarch 0:2.061-2.el7                   
     8   perl-Net-Daemon.noarch 0:0.48-5.el7                       perl-PlRPC.noarch 0:0.2020-14.el7                       
     9 
    10 Updated:
    11   mariadb-libs.x86_64 1:5.5.60-1.el7_5                                                                              
    12 
    13 Complete!
    14 [root@web2 yum.repos.d]# rpm -qa |grep mariadb
    15 mariadb-libs-5.5.60-1.el7_5.x86_64
    16 mariadb-embedded-5.5.60-1.el7_5.x86_64
    17 mariadb-bench-5.5.60-1.el7_5.x86_64
    18 mariadb-5.5.60-1.el7_5.x86_64
    19 [root@web2 yum.repos.d]# 

        忘记安装了mariadb-server,记得安装啊

    1 [root@web2 /]# rpm -qa |grep mariadb
    2 mariadb-embedded-5.5.60-1.el7_5.x86_64
    3 mariadb-5.5.60-1.el7_5.x86_64
    4 mariadb-server-5.5.60-1.el7_5.x86_64
    5 mariadb-bench-5.5.60-1.el7_5.x86_64
    6 mariadb-libs-5.5.60-1.el7_5.x86_64

      4、软件配置

       1)、配置nginx

        cat /etc/nginx/conf.d/default.conf 

     1 [root@web1 yum.repos.d]# cat /etc/nginx/conf.d/default.conf 
     2 server {
     3         listen 80;
     4         server_name 192.168.216.51;
     5         index index.html index.htm index.php;
     6         charset utf-8;
     7         root /usr/share/nginx/html;
     8 
     9         location ~.*.php$ {
    10                 fastcgi_pass unix:/dev/shm/php-fpm.sock;
    11                 fastcgi_index index.php;
    12                 fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    13                 include fastcgi_params;
    14                 try_files $uri = 404;
    15         }
    16 
    17         location ~.*.(gif|jpg|jpeg|png|bmp|swf|flv|mp3|wma)$ {
    18                 expires 30d;
    19         }
    20         location ~.*.(js|css)$ {
    21                 expires 12h;
    22         }
    23 
    24 
    25 }

       2)、配置php-fpm

        cat /etc/php-fpm.d/www.conf

        修改下面几项

    1 listen = /dev/shm/php-fpm.sock
    2 listen.owner = nobody
    3 listen.group = nobody
    4 user = nginx
    5 group = nginx

       启动nginx和php-fpm

     1 [root@web1 yum.repos.d]# systemctl start nginx 
     2 [root@web1 yum.repos.d]# systemctl start php-fpm
     3 [root@web1 yum.repos.d]# netstat -untlp |grep 80
     4 tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      13408/nginx: master 
     5 tcp6       0      0 :::80                   :::*                    LISTEN      13408/nginx: master 
     6 [root@web1 yum.repos.d]# netstat -untlp |grep php*
     7 [root@web1 yum.repos.d]# ps -aux |grep php*
     8 root      14058  0.0  0.7 417184 13444 ?        Ss   00:04   0:00 php-fpm: master process (/etc/php-fpm.conf)
     9 nginx     14060  0.0  0.3 419268  6468 ?        S    00:04   0:00 php-fpm: pool www
    10 nginx     14061  0.0  0.3 419268  6468 ?        S    00:04   0:00 php-fpm: pool www
    11 nginx     14062  0.0  0.3 419268  6468 ?        S    00:04   0:00 php-fpm: pool www
    12 nginx     14063  0.0  0.3 419268  6468 ?        S    00:04   0:00 php-fpm: pool www
    13 nginx     14064  0.0  0.3 419268  6468 ?        S    00:04   0:00 php-fpm: pool www
    14 root      14223  0.0  0.0 112652   968 pts/0    S+   00:18   0:00 grep --color=auto php*

        最后记得开机自启

        systemctl enable nginx

        systemctl enable php-fpm

        测试一下php,添加index.php,访问一下192.168.216.51

        

    1 [root@web1 html]# pwd
    2 /usr/share/nginx/html
    3 [root@web1 html]# cat index.php 
    4 <?php
    5         phpinfo();
    6 ?>
    7 
    8 [root@web1 html]# 

        

        没问题,进入下一步骤

        

      

       3)、配置数据库

        我们在52安装的数据库

        3.1、启动一下服务

     1 Installed:
     2   mariadb-server.x86_64 1:5.5.60-1.el7_5                                                                            
     3 
     4 Dependency Installed:
     5   perl-DBD-MySQL.x86_64 0:4.023-6.el7                                                                               
     6 
     7 Complete!
     8 [root@web2 yum.repos.d]# systemctl start  mariadb
     9 [root@web2 yum.repos.d]# netstat -untlp |grep 3306
    10 tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      5563/mysqld         
    11 [root@web2 yum.repos.d]# systemctl enable mariadb

        3.2、创建zabbix database,zabbix账户,修改root密码

     1 [root@web2 yum.repos.d]# mysql                   #进入数据库
     2 Welcome to the MariaDB monitor.  Commands end with ; or g.
     3 Your MariaDB connection id is 3
     4 Server version: 5.5.60-MariaDB MariaDB Server
     5 
     6 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
     7 
     8 Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
     9 
    10 MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin; #创建database
    11 Query OK, 1 row affected (0.00 sec)
    12 
    13 14 
    15 MariaDB [(none)]> GRANT all privileges ON *.* TO 'zabbix'@'%' IDENTIFIED BY 'admin123'; #建账户授权
    16 Query OK, 0 rows affected (0.00 sec)
    17 
    18 MariaDB [(none)]> flush privileges;            #刷新
    19 Query OK, 0 rows affected (0.00 sec)
    20 
    21 MariaDB [(none)]> use mysql;                
    22 Reading table information for completion of table and column names
    23 You can turn off this feature to get a quicker startup with -A
    24 
    25 Database changed
    26 MariaDB [mysql]> update user set password=password('admin123') where user='root';   #改root密码
    27 Query OK, 4 rows affected (0.00 sec)
    28 Rows matched: 4  Changed: 4  Warnings: 0
    29 
    30 MariaDB [mysql]> flush privileges;
    31 Query OK, 0 rows affected (0.00 sec)

          3.3、51上测试连接数据

    1 [root@web1 html]# mv index.php index.php.phpinfo
    2 [root@web1 html]# vim index.php 
    3 <?php
    4         $link=mysql_connect('192.168.216.52','zabbix','admin123');
    5         if($link) echo "<h1>The database connection was successful!</h1>";
    6         else echo "<h1>The database connection was Fail!!</h1>";
    7         mysql_close();
    8 ?>

          

        3.4、导入zabbix database 数据库脚本

        51上

        

     1 [root@web1 html]# rpm -ql zabbix-server-mysql-4.0.4-1.el7.x86_64
     2 /etc/logrotate.d/zabbix-server
     3 /etc/zabbix/zabbix_server.conf
     4 /usr/lib/systemd/system/zabbix-server.service
     5 /usr/lib/tmpfiles.d/zabbix-server.conf
     6 /usr/lib/zabbix/alertscripts
     7 /usr/lib/zabbix/externalscripts
     8 /usr/sbin/zabbix_server_mysql
     9 /usr/share/doc/zabbix-server-mysql-4.0.4
    10 /usr/share/doc/zabbix-server-mysql-4.0.4/AUTHORS
    11 /usr/share/doc/zabbix-server-mysql-4.0.4/COPYING
    12 /usr/share/doc/zabbix-server-mysql-4.0.4/ChangeLog
    13 /usr/share/doc/zabbix-server-mysql-4.0.4/NEWS
    14 /usr/share/doc/zabbix-server-mysql-4.0.4/README
    15 /usr/share/doc/zabbix-server-mysql-4.0.4/create.sql.gz  #就是要找这个数据库脚本
    16 /usr/share/man/man8/zabbix_server.8.gz
    17 /var/log/zabbix
    18 /var/run/zabbix

        

     1 [root@web1 zabbix-server-mysql-4.0.4]# gunzip create.sql.gz #解压缩
     2 [root@web1 zabbix-server-mysql-4.0.4]# ll 
     3 total 6736
     4 -rw-r--r-- 1 root root      98 Feb  4 17:57 AUTHORS
     5 -rw-r--r-- 1 root root  940849 Feb  4 17:57 ChangeLog
     6 -rw-r--r-- 1 root root   17990 Feb  4 17:57 COPYING
     7 -rw-r--r-- 1 root root 5920915 Feb  4 18:02 create.sql
     8 -rw-r--r-- 1 root root      52 Feb  4 17:57 NEWS
     9 -rw-r--r-- 1 root root    1062 Feb  4 17:57 README
    10 [root@web1 zabbix-server-mysql-4.0.4]# scp create.sql root@192.168.216.52:/   #发送到52上,数据库服务器

      52上,导入zabbix database脚本

      

      1 [root@web2 /]# mysql -uroot zabbix < /create.sql  -p
      2 Enter password: 
      3 [root@web2 /]# mysql -uroot -p
      4 Enter password: 
      5 Welcome to the MariaDB monitor.  Commands end with ; or g.
      6 Your MariaDB connection id is 8
      7 Server version: 5.5.60-MariaDB MariaDB Server
      8 
      9 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
     10 
     11 Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
     12 
     13 MariaDB [(none)]> use zabbix;
     14 Reading table information for completion of table and column names
     15 You can turn off this feature to get a quicker startup with -A
     16 
     17 Database changed
     18 MariaDB [zabbix]> show tables;
     19 +----------------------------+
     20 | Tables_in_zabbix           |
     21 +----------------------------+
     22 | acknowledges               |
     23 | actions                    |
     24 | alerts                     |
     25 | application_discovery      |
     26 | application_prototype      |
     27 | application_template       |
     28 | applications               |
     29 | auditlog                   |
     30 | auditlog_details           |
     31 | autoreg_host               |
     32 | conditions                 |
     33 | config                     |
     34 | corr_condition             |
     35 | corr_condition_group       |
     36 | corr_condition_tag         |
     37 | corr_condition_tagpair     |
     38 | corr_condition_tagvalue    |
     39 | corr_operation             |
     40 | correlation                |
     41 | dashboard                  |
     42 | dashboard_user             |
     43 | dashboard_usrgrp           |
     44 | dbversion                  |
     45 | dchecks                    |
     46 | dhosts                     |
     47 | drules                     |
     48 | dservices                  |
     49 | escalations                |
     50 | event_recovery             |
     51 | event_suppress             |
     52 | event_tag                  |
     53 | events                     |
     54 | expressions                |
     55 | functions                  |
     56 | globalmacro                |
     57 | globalvars                 |
     58 | graph_discovery            |
     59 | graph_theme                |
     60 | graphs                     |
     61 | graphs_items               |
     62 | group_discovery            |
     63 | group_prototype            |
     64 | history                    |
     65 | history_log                |
     66 | history_str                |
     67 | history_text               |
     68 | history_uint               |
     69 | host_discovery             |
     70 | host_inventory             |
     71 | hostmacro                  |
     72 | hosts                      |
     73 | hosts_groups               |
     74 | hosts_templates            |
     75 | housekeeper                |
     76 | hstgrp                     |
     77 | httpstep                   |
     78 | httpstep_field             |
     79 | httpstepitem               |
     80 | httptest                   |
     81 | httptest_field             |
     82 | httptestitem               |
     83 | icon_map                   |
     84 | icon_mapping               |
     85 | ids                        |
     86 | images                     |
     87 | interface                  |
     88 | interface_discovery        |
     89 | item_application_prototype |
     90 | item_condition             |
     91 | item_discovery             |
     92 | item_preproc               |
     93 | items                      |
     94 | items_applications         |
     95 | maintenance_tag            |
     96 | maintenances               |
     97 | maintenances_groups        |
     98 | maintenances_hosts         |
     99 | maintenances_windows       |
    100 | mappings                   |
    101 | media                      |
    102 | media_type                 |
    103 | opcommand                  |
    104 | opcommand_grp              |
    105 | opcommand_hst              |
    106 | opconditions               |
    107 | operations                 |
    108 | opgroup                    |
    109 | opinventory                |
    110 | opmessage                  |
    111 | opmessage_grp              |
    112 | opmessage_usr              |
    113 | optemplate                 |
    114 | problem                    |
    115 | problem_tag                |
    116 | profiles                   |
    117 | proxy_autoreg_host         |
    118 | proxy_dhistory             |
    119 | proxy_history              |
    120 | regexps                    |
    121 | rights                     |
    122 | screen_user                |
    123 | screen_usrgrp              |
    124 | screens                    |
    125 | screens_items              |
    126 | scripts                    |
    127 | service_alarms             |
    128 | services                   |
    129 | services_links             |
    130 | services_times             |
    131 | sessions                   |
    132 | slides                     |
    133 | slideshow_user             |
    134 | slideshow_usrgrp           |
    135 | slideshows                 |
    136 | sysmap_element_trigger     |
    137 | sysmap_element_url         |
    138 | sysmap_shape               |
    139 | sysmap_url                 |
    140 | sysmap_user                |
    141 | sysmap_usrgrp              |
    142 | sysmaps                    |
    143 | sysmaps_elements           |
    144 | sysmaps_link_triggers      |
    145 | sysmaps_links              |
    146 | tag_filter                 |
    147 | task                       |
    148 | task_acknowledge           |
    149 | task_check_now             |
    150 | task_close_problem         |
    151 | task_remote_command        |
    152 | task_remote_command_result |
    153 | timeperiods                |
    154 | trends                     |
    155 | trends_uint                |
    156 | trigger_depends            |
    157 | trigger_discovery          |
    158 | trigger_tag                |
    159 | triggers                   |
    160 | users                      |
    161 | users_groups               |
    162 | usrgrp                     |
    163 | valuemaps                  |
    164 | widget                     |
    165 | widget_field               |
    166 +----------------------------+
    167 144 rows in set (0.00 sec)

        ok已经成功导入

       

       4)、修改zabbix配置文件,设置权限

       vim /etc/zabbix/zabbix_server.conf

        ListenPort=10051

        DBHost=192.168.216.52

        DBName=zabbix

        DBUser=zabbix

        DBPassword=admin123

        DBPort=3306

         修改这几项应该就可以了

      

     1 [root@web1 zabbix-server-mysql-4.0.4]# systemctl restart zabbix-server    
     2 [root@web1 zabbix-server-mysql-4.0.4]# !net
     3 bash: !net: command not found...
     4 [root@web1 zabbix-server-mysql-4.0.4]# !net
     5 netstat -untlpo
     6 Active Internet connections (only servers)
     7 Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name     Timer
     8 tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd            off (0.00/0/0)
     9 tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      15347/nginx: master  off (0.00/0/0)
    10 tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      2192/dnsmasq         off (0.00/0/0)
    11 tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      884/sshd             off (0.00/0/0)
    12 tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      882/cupsd            off (0.00/0/0)
    13 tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2010/master          off (0.00/0/0)
    14 tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      15505/zabbix_server  off (0.00/0/0)
    15 tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd            off (0.00/0/0)
    16 tcp6       0      0 :::80                   :::*                    LISTEN      15347/nginx: master  off (0.00/0/0)
    17 tcp6       0      0 :::22                   :::*                    LISTEN      884/sshd             off (0.00/0/0)
    18 tcp6       0      0 ::1:631                 :::*                    LISTEN      882/cupsd            off (0.00/0/0)
    19 tcp6       0      0 ::1:25                  :::*                    LISTEN      2010/master          off (0.00/0/0)
    20 tcp6       0      0 :::10051                :::*                    LISTEN      15505/zabbix_server  off (0.00/0/0)
    21 udp        0      0 0.0.0.0:5353            0.0.0.0:*                           592/avahi-daemon: r  off (0.00/0/0)
    22 udp        0      0 0.0.0.0:58177           0.0.0.0:*                           592/avahi-daemon: r  off (0.00/0/0)
    23 udp        0      0 192.168.122.1:53        0.0.0.0:*                           2192/dnsmasq         off (0.00/0/0)
    24 udp        0      0 0.0.0.0:67              0.0.0.0:*                           2192/dnsmasq         off (0.00/0/0)
    25 udp        0      0 0.0.0.0:177             0.0.0.0:*                           897/lightdm          off (0.00/0/0)
    26 udp6       0      0 :::177                  :::*                                897/lightdm          off (0.00/0/0)
    27 [root@web1 zabbix-server-mysql-4.0.4]# 

          最后修改nginx配置文件

        51上

        cat /etc/nginx/conf.d/default.conf 

        修改下面一项即可

        root /usr/share/zabbix;

        systemctl restart nginx

        问题1、访问192.168.216.51 出错代码500

        cat /var/log/nginx/error.log

        tail -5 /var/log/nginx/error.log

    1  PHP Fatal error:  require_once(): Failed opening required '/etc/zabbix/web/maintenance.inc.php' (include_path='.:/usr/share/pear:/usr/share/php') in /usr/share/zabbix/include/classes/core/ZBase.php on line 276" while reading response header from upstream, client: 192.168.216.1, server: 192.168.216.51, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/dev/shm/php-fpm.sock:", host: "192.168.216.51"

        修改权限

        

    1 505 chown -R zabbix:zabbix /etc/zabbix
    2 506 chown -R zabbix:zabbix /usr/share/zabbix
    3 507 chown -R zabbix:zabbix /usr/lib/zabbix
    4 508 chmod -R 755 /etc/zabbix/web

        访问192.168.216.51

    三、正式开始web界面配置安装配置zabbix

        

       1、第一步welcome 点击下一步网页还是跳会第一步

        问题2、无法进行第2步

        有可能是php session没起作用

        修改php session 权限

        chmod -R 777 /var/lib/php/session/

       2、第二步 check of pre-requisites

          检查先决条件

      

          问题3、先把fail解决,修改php文件

          vim /etc/php.ini

          

    1 post_max_size = 32M
    2 
    3 max_execution_time = 300
    4 
    5 max_input_time = 300
    6 
    7 date.timezone = PRC

          systemctl restart php-fpm

          访问一下,好了,进行下一步,点击next step

        

       3、configure DB connection

        配置连接的数据库

      

          问题4、点击nextstep 出错,上一篇也遇到了这个问题

      

           查看nginx日志发现

    1 [root@web1 share]# !tail
    2 tail -5 /var/log/nginx/error.log
    3 2019/02/25 14:28:31 [error] 98806#0: *1 upstream sent too big header while reading response header from upstream, client: 192.168.216.1, server: 192.168.216.51, request: "GET /setup.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.216.51"
    4 2019/02/25 14:28:31 [error] 98806#0: *1 upstream sent too big header while reading response header from upstream, client: 192.168.216.1, server: 192.168.216.51, request: "GET /setup.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.216.51"
    5 2019/02/25 14:28:32 [error] 98806#0: *1 upstream sent too big header while reading response header from upstream, client: 192.168.216.1, server: 192.168.216.51, request: "GET /setup.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.216.51"
    6 2019/02/25 14:28:32 [error] 98806#0: *1 upstream sent too big header while reading response header from upstream, client: 192.168.216.1, server: 192.168.216.51, request: "GET /setup.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.216.51"
    7 2019/02/25 14:30:14 [error] 98804#0: *10 upstream sent too big header while reading response header from upstream, client: 192.168.216.1, server: 192.168.216.51, request: "GET /setup.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.216.51"
    8 [root@web1 share]# vim /etc/nginx/conf.d/default.conf 

        

        upstream sent too big header while reading response header from upstream
        是这个问题导致,在网站找好多方法,都不行,最后看到是因为fastcgi缓冲区设置过小,其实是header过大
        添加缓存区解决,编辑nginx 配置文件,添加两项
        fastcgi_buffers 8 16k;
        fastcgi_buffer_size 32k;
     1 [root@web1 share]# vim /etc/nginx/conf.d/default.conf 
     2 
     3                
     4 server {
     5         listen 80;
     6         server_name 192.168.216.51;
     7         index index.html index.htm index.php;
     8         charset utf-8;
     9         root /usr/share/zabbix;
    10         location / {
    11                 #max_fails=6;
    12                 #fail_timeout=60;
    13                 root /usr/share/zabbix;
    14         }
    15 
    16         location ~.*.php$ {
    17                 fastcgi_connect_timeout 300;
    18                 root /usr/share/zabbix;
    19                 fastcgi_send_timeout 300;
    20                 fastcgi_read_timeout 300;
    21                 fastcgi_buffers 8 16k;
    22                 fastcgi_buffer_size 32k;
    23                 #fastcgi_pass unix:/dev/shm/php-fpm.sock;
    24                 fastcgi_pass 127.0.0.1:9000;
    25                 fastcgi_index index.php;
    26                 fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    27                 include fastcgi_params;
    28                 try_files $uri = 404;
    29         }
    30 
    31         location ~.*.(gif|jpg|jpeg|png|bmp|swf|flv|mp3|wma)$ {
    32                 expires 30d;
    33         }
    34         location ~.*.(js|css)$ {
    35                 expires 12h;
    36         }
    37 
    38 
    39 }

      

      4、zabbix server details

        这个也可以默认配置,因为进入zabbix主页后是可以修改的

      

      

       5、pre-installation summary 

        就是安装配置的一个总结,检查看看有没有出错

       6、INSTALL  

        最后就是报错配置了

        问题5、Unable to create the configuration file.

        这里没来得及截图提示Unable to create the configuration file.

        /etc/zabbix/web没有权限导致,我选择第一项下载zabbix.conf.php 然后上传到相应目录,在点一下,就是如下页面了

        奇怪的是我点击login 然后用默认admin 密码zabbix 无法登陆

        

       

        其实zabbix 默认账户为Admin  密码zabbix,zabbix 的简单部署就到这里了,新的zabbix 监控页面如下:

    转载请注明出处:https://www.cnblogs.com/zhangxingeng/p/10414070.html 

  • 相关阅读:
    IIS 禁止自动回收
    误删除系统帐户且SA被禁用,如何修复?单用户模式登录可解决。
    不到100行代码实现SHELL环境下图形化的IP设置功能
    2021总结
    快排
    Windows 10 修改用户名及Users文件夹
    DATUM支持不同格式(JSON,CSV,SQL,XML等)的在线模拟数据生成器
    记:云服务器被暴破感染bioset
    前端项目修改npm/yarn配置文件来加速包下载
    十个前端常见手写功能
  • 原文地址:https://www.cnblogs.com/zhangxingeng/p/10414070.html
Copyright © 2020-2023  润新知