zoukankan      html  css  js  c++  java
  • Zabbix 监控服务介绍

    Zabbix 监控服务介绍

    一、Zabbix 监控服务介绍

    1.1.1 Zabbix 监控服务介绍

    1. Zabbix 监控介绍

    1、Zabbix 由 Alexei Vladishev 创建,目前由其成立的公司—— Zabbix SIA 积极的持续开发更新维护, 并为用户提供技术支持服务。
    2、Zabbix 是一个企业级分布式开源监控解决方案。
    3、Zabbix 软件能够监控众多网络参数和服务器的健康度、完整性。Zabbix 使用灵活的告警机制,允许用户为几乎任何事件配置基于邮件的告警。这样用户可以快速响应服务器问题。Zabbix基于存储的数据提供出色的报表和数据可视化功能。这些功能使得 Zabbix 成为容量规划的理想选择。
    4、Zabbix 支持主动轮询(polling)和被动捕获(trapping)。Zabbix所有的报表、统计数据和配置参数都可以通过基于 Web 的前端页面进行访问。基于 Web 的前端页面确保您可以在任何地方访问您监控的网络状态和服务器健康状况。适当的配置后,Zabbix 可以在监控 IT基础设施方面发挥重要作用。无论是对于有少量服务器的小型组织,还是拥有大量服务器的大企业而言,同样适用。
    5、Zabbix 是免费的。Zabbix 是根据 GPL 通用公共许可证的第二版编写和发布的。这意味着产品源代码是免费发布的,可供公共使用。

    1. Zabbix 功能介绍
    概述
    
    Zabbix 是一个高度成熟完善得网络监控解决方案,一个的软件包中包含了多种功能。
    数据采集
    
        可用性和性能检查
        支持SNMP(包括主动轮询和被动捕获),IPMI,JMX,VMware监控;
        自定义检查
        按照自定义的时间间隔采集需要的数据
        通过Server、Proxy和Agents来执行数据采集
    
    灵活的阈值定义
    
        您可以参考后端数据库定义非常灵活的告警阈值,即触发器
    
    高度可配置的告警
    
        可以更具递增计划,接受者,媒介类型自定义发送告警通知
        使用宏变量可以使告警通知变得更加高效有用
        自动操作包含远程执行命令
    
    实时图型
    
        使用内置图形功能可以将监控项实时绘制成图形。
    
    Web监控功能
    
        Zabbix 可以追踪模拟鼠标在Web网站上的点击操作,来检查Web网站的功能和响应时间。
    
    丰富的可视化选项
    
        可以组合多个监控项到单个视图中,创建自定义图表。
        网络拓扑图
        以仪表盘样式展现自定义聚合图形和幻灯片演示;
        报表
        监控资源的更高层次展示视图(业务视图);
    
    历史数据存储
    
        存储在数据库中的数据
        历史配置
        内置数据管理机制(housekeeping)
    
    配置简单
    
        将被监控设备添加为主机
        主机一旦添加到数据库中,就会采集数据用于监控
        将模板用于监控设备
    
    使用模板
    
        模板中分组检查
        模板可以关联模板,继承已关联模板的属性
    
    网络发现
    
        自动发现网络设备
        Zabbix Agent 发现设备后自动注册
        自动发现文件系统,网络接口和Snmp OIDs值。
    
    快捷的Web界面
    
        基于PHP的Web前段;
        可以从任何地方访问
        您可以定制自己的操作方式
        您可以通过审计日志来查看您的操作
    
    Zabbix API
    
        Zabbix API 为Zabbix 提供可编程接口,用于批量操作,第三方软件集成和其他用途.
    
    权限管理系统
    
        安全的用户身份验证
        指定的用户只能查看指定的权限范围内的视图;
    
    功能强大且易于扩展的Zabbix Agent
    
        部署于被监控对象上
        支持Linux和Windows;
    
    二进制守护进程
    
        为了更好的性能和更少的内存占用,采用C语言编写;
        便于移植.
    
    适用更复杂的环境
    
        适用Zabbix Proxy代理,可以轻松实现分布式远程监控.
    
    Zabbix 概述
    架构
    
    Zabbix 由几个主要的功能组成,其功能介绍如下所示
    Server
    
    Zavvix server 是Zabbix软件的核心组件,agent向其报告可用性,系统完善性信息和统计信息.server也是存储所有配置信息,统计信息和操作信息的核心存储库.
    数据库
    
    所有配置信息以及Zabbix 采集的数据都被存储在数据库中
    Web 界面
    
    所有配置信息以及Zabbix 采集到的数据都被存储在数据库中;
    Proxy
    
    Zabbix agents 部署在被监控目标上,用于主动监控本地资源和应用程序,并将收集数据发送给Zabbix server;
    Agent
    
    Zabbix agent 部署在被监控目标上,用于主动监控本地资源和应用程序,并将收集的数据发送给Zabbix server.
    数据流
    
    另外,回过头来整体的了解下Zabbix的内部的数据流对Zabbix 的使用也很重要.首先,为了创建一个采集数据的监控项,您就必须要先创建主机.其次,在任务的另外一端,必须要有监控项才能创建触发器(trigger),必须要有触发器来创建动作(action).因此,如果您想要收到 “X个server上CPU负载过高” 这样的告警,您必须首先为Server X创建一个主机条目,其次创建一个用于监控器CPU的监控项,最后创建一个触发器,用来触发CPU负载过高这个动作,并将其发送到您的邮箱中.虽然这些步骤看起来很繁琐,但是使用模板的话,实际操作非常简单.也正是由于这种设计,使得Zabbix的配置变得更加灵活易用.
    
    更多内容请看官方文档:https://www.zabbix.com/documentation/4.0/zh/manual
    

    1.1.2 如何去做监控

    1. 如何去做监控
    初级:
    1、识别监控对象
    3、理解监控对象
    3、细分监控对象指标
    4、确定告警的基准线
    5、工具化和监控分离
    6、监控对象的分类
          ----硬件监控 (机房巡检、IPMI、SNMP)
          ----系统监控  (对象:CPU、内存、IO【磁盘、网络】)
          ----软件服务监控(对象:各类软件服务(Nginx|Tomcat|RabbitMQ|MySQL等))
          ----日志监控(方法:Elastic stack)
          ----网络监控(方法:第三方:Smokeping)
          ----流量监控(工具:Piwik等)
          ----其它监控(APP监控、安全监控、业务监控等)
          ----APM应用性能管理监控 (开源的APM应用性能管理工具:pinpoint)
    3、掌握一个监控工具:如Zabbix
    中级:
    0、标准化监控(标准化的脚本、模板、....。)
    1、分布式监控(主动、被动、分布式)
    2、自动化监控(自动发现、自动注册(Agent主动注册、server主动添加API))
    3、性能优化(数据采集、数据存储、数据查询)
    4、二次开发(定制报表、API调用)
    
    进阶:
    1、动态告警
    2、智能告警:1.告警去重 2.依赖
    3、故障自愈
    4、大规模(集群)(时间驱动、主动控制)
    

    1.13 硬件监控

    1. 硬件监控(IPMI)
    文档地址:https://www.ibm.com/developerworks/cn/linux/l-ipmi/index.html
              https://blog.csdn.net/ygqygq2/article/details/53264993
    yum install OpenIPMI ipmitool -y
    
    1. 硬件监控(SNMP)
    文档参考:http://www.ttlsa.com/zabbix/zabbix-snmp-install/
              https://www.cnblogs.com/zoulongbin/p/7792772.html
    [root@zabbix ~]# yum -y install net-snmp net-snmp-libs net-snmp-utils
    编辑配置文件
    [root@zabbix ~]# cp /etc/snmp/snmpd.conf{,.back} 
    [root@zabbix ~]# ll /etc/snmp/snmpd.conf{,.back} 
    -rw------- 1 root root 18861 Jun 23 23:39 /etc/snmp/snmpd.conf
    -rw------- 1 root root 18861 Jul  8 00:26 /etc/snmp/snmpd.conf.back
    
    修改如下:(测试操作,不代表生产)
    [root@zabbix ~]# grep  "^[a-z]" /etc/snmp/snmpd.conf
    com2sec admin  default       admin
    group    admin v2c                    admin
    view     admin         included   .1 80
    access  admin ""      any       noauth    exact  admin admin none
    
    启动SNMP服务:
    [root@zabbix ~]# systemctl start snmpd
    [root@zabbix ~]# systemctl enable snmpd
    Created symlink from /etc/systemd/system/multi-user.target.wants/snmpd.service to /usr/lib/systemd/system/snmpd.service.
    
    默认监听udp的161端口
    [root@zabbix ~]# ss -luntp|grep snmp
    udp    UNCONN     0      0         *:161                   *:*                   users:(("snmpd",pid=1445,fd=6))
    tcp    LISTEN     0      128    127.0.0.1:199                   *:*                   users:(("snmpd",pid=1445,fd=7))
    
    5分钟的负载
    [root@zabbix ~]# snmpget -v 2c -c admin 10.4.7.62 .1.3.6.1.4.1.2021.10.1.3.1
    UCD-SNMP-MIB::laLoad.1 = STRING: 0.00
    10分钟的负载
    [root@zabbix ~]# snmpget -v 2c -c admin 10.4.7.62 .1.3.6.1.4.1.2021.10.1.3.2
    UCD-SNMP-MIB::laLoad.2 = STRING: 0.01
    15分钟的负载
    [root@zabbix ~]# snmpget -v 2c -c admin 10.4.7.62 .1.3.6.1.4.1.2021.10.1.3.3
    UCD-SNMP-MIB::laLoad.3 = STRING: 0.05
    
    如果不知道3后面有哪些节点可以用这个命令查看
    [root@zabbix ~]# snmpwalk -v 2c -c admin 10.4.7.62 .1.3.6.1.4.1.2021.10.1.3 #3后面不能加支节点
    UCD-SNMP-MIB::laLoad.1 = STRING: 0.00
    UCD-SNMP-MIB::laLoad.2 = STRING: 0.01
    UCD-SNMP-MIB::laLoad.3 = STRING: 0.05
    
    内存查看:
    [root@zabbix ~]# snmpget -v 2c -c admin 10.4.7.62 .1.3.6.1.2.1.25.2.2.0
    HOST-RESOURCES-MIB::hrMemorySize.0 = INTEGER: 2027924 KBytes
    
    SNMP OID列表 监控需要用到的OID:http://www.ttlsa.com/monitor/snmp-oid/
    

    1.1.4 系统监控

    1. CPU监控
    [root@zabbix ~]# top
    top - 22:28:36 up  2:18,  1 user,  load average: 0.01, 0.02, 0.05
    Tasks:  86 total,   2 running,  84 sleeping,   0 stopped,   0 zombie
    %Cpu(s):  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    KiB Mem :  2027924 total,  1829364 free,    91704 used,   106856 buff/cache
    KiB Swap:  1048572 total,  1048572 free,        0 used.  1802536 avail Mem 
    
       PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                                                         
      1378 root      20   0  227984  10872   6500 S  0.0  0.5   0:02.96 snmpd        
      
    top - 22:28:36 up  2:18,    1 user,      load average: 0.01, 0.02, 0.05
    命令  系统当前时间 启动时间 当前使用用户  当前1 5 15分钟的负载情况
    
    Tasks:  86 total,   2 running,      84 sleeping,   0 stopped,   0 zombie
    任务    当前任务     正在运行的任务  睡眠的任务    停止的任务    僵死的任务
    
    %Cpu(s):  0.0 us,  0.0 sy,  0.0 ni,         100.0 id,   0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    CPU        用户态   内核态  优先级为负数     资源闲置率   IO等待    硬中断    软中断    
    
    KiB Mem :  2027924 total,  1829364 free,    91704 used,   106856 buff/cache  内存
    KiB Swap:  1048572 total,  1048572 free,        0 used.  1802536 avail Mem   交换分区
    
    PID    USER      PR           NI    VIRT              RES               SHR              S     %CPU         %MEM           TIME+ COMMAND    
    进程ID  用户     进程优先级         进程占的虚拟内存  进程占的常驻内存  进程占的共享内存      进程占用的CPU 进程占用的内存  进程占用CPU的总时间
    
    按1 显示所有CPU使用情况
    按P 按CPU使用率从大到小排序
    按M 按内存使用率从大到小排序
    负载:单位时间内运行队列中就绪等待的进程数平均值
    
    [root@zabbix ~]# cat /proc/loadavg 
    0.00 0.01 0.05 1/94 14013
    
    常用监控命令的安装包:sysstat
    [root@zabbix ~]# yum install sysstat -y
    
    内存监控
    [root@zabbix ~]# vmstat 1 5
    procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
     r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
     0  0      0 1750660   3140 176912    0    0    12     5   26   42  0  0 99  0  0
     2  0      0 1749620   3140 176912    0    0     0     0   48   79  0  0 100  0  0
     0  0      0 1748792   3140 177008    0    0     0     0  103  335  1  2 97  0  0
     0  0      0 1748792   3140 177008    0    0     0     0   46   76  0  1 99  0  0
     0  0      0 1748792   3140 177008    0    0     0     0   54   88  0  0 100  0  0
    
    CPU监控
    [root@zabbix ~]# mpstat 1 5
    Linux 3.10.0-1062.18.1.el7.x86_64 (zabbix) 	07/08/2020 	_x86_64_	(1 CPU)
    
    11:10:25 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
    11:10:26 PM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
    11:10:27 PM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
    11:10:28 PM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
    11:10:29 PM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
    11:10:30 PM  all    0.00    0.00    0.00    0.00    0.00    0.99    0.00    0.00    0.00   99.01
    Average:     all    0.00    0.00    0.00    0.00    0.00    0.20    0.00    0.00    0.00   99.80
    
    [root@zabbix ~]# lscpu
    Architecture:          x86_64
    CPU op-mode(s):        32-bit, 64-bit
    Byte Order:            Little Endian
    CPU(s):                1
    On-line CPU(s) list:   0
    Thread(s) per core:    1
    Core(s) per socket:    1
    Socket(s):             1
    NUMA node(s):          1
    Vendor ID:             GenuineIntel
    CPU family:            6
    Model:                 142
    Model name:            Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
    Stepping:              9
    CPU MHz:               2904.003
    BogoMIPS:              5808.00
    Hypervisor vendor:     VMware
    Virtualization type:   full
    L1d cache:             32K
    L1i cache:             32K
    L2 cache:              256K
    L3 cache:              4096K
    NUMA node0 CPU(s):     0
    Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid rdseed adx smap clflushopt xsaveopt xsavec arat spec_ctrl intel_stibp flush_l1d arch_capabilities
    
    1. MEM&IO监控
    [root@zabbix ~]# cat /proc/meminfo 
    [root@zabbix ~]# free -h
                  total        used        free      shared  buff/cache   available
    Mem:           1.9G         94M        1.7G        9.4M        176M        1.7G
    Swap:          1.0G          0B        1.0G
    
    [root@zabbix ~]# vmstat 1 5
    procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
     r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
     0  0      0 1750192   3140 177336    0    0    11     5   25   41  0  0 99  0  0
     0  0      0 1750168   3140 177336    0    0     0     0   25   35  0  0 100  0  0
     0  0      0 1750168   3140 177336    0    0     0     0   23   27  0  0 100  0  0
     0  0      0 1750168   3140 177336    0    0     0     0   24   35  0  0 100  0  0
     0  0      0 1750168   3140 177336    0    0     0     0   16   24  0  0 100  0  0
    
    不使用交换分区
    [root@zabbix ~]# cat /proc/sys/vm/swappiness 
    60
    [root@zabbix ~]# cat  0 >/proc/sys/vm/swappiness  #mysql数据库建议设为0
    永久生效
    [root@zabbix ~]# vim /etc/sysctl.conf 
    swappiness=0
    [root@zabbix ~]# sysctl -p /etc/sysctl.conf 
    
    -w  临时改变某个指定参数的值
    -a  显示所有的系统参数
    -p  从指定的文件加载系统参数,如不指定即从/etc/sysctl.conf中加载
    
    IO监控
    [root@zabbix ~]# iotop
    Total DISK READ :	0.00 B/s | Total DISK WRITE :       0.00 B/s
    Actual DISK READ:	0.00 B/s | Actual DISK WRITE:       0.00 B/s
       PID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN     IO>    COMMAND                                                              
         1 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % systemd --switched-root --system --deserialize 22
         2 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kthreadd]
       515 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % systemd-journald
         4 be/0 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kworker/0:0H]
         5 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kworker/u256:0]
         6 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [ksoftirqd/0]
         7 rt/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [migration/0]
         8 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [rcu_bh]
         9 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [rcu_sched]
        10 be/0 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [lru-add-drain]
    
    IO 调度算法
    [root@zabbix ~]# cat /sys/block/sda/queue/scheduler 
    noop [deadline] cfq 
    
    sas盘c7 默认 c6调成[deadline] 
    ssd盘c7  c6 调成noop
    
    echo noop >/sys/block/sda/queue/scheduler
    想永久的更改I/O调度方法:
    修改内核引导参数,加入elevator=调度程序名
    vi /boot/grub/menu.lst
    更改到如下内容:
    kernel /boot/vmlinuz-2.6.18-8.el5 roroot=LABEL=/ elevator=deadline rhgb quiet
    
    [root@zabbix ~]# iostat 
    Linux 3.10.0-1062.18.1.el7.x86_64 (zabbix) 	07/09/2020 	_x86_64_	(1 CPU)
    
    avg-cpu:  %user   %nice %system %iowait  %steal   %idle
               0.04    0.01    0.19    0.20    0.00   99.57
    
    Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
    sda               0.66         7.94         3.52     137736      61043
    scd0              0.00         0.06         0.00       1028          0
    dm-0              0.64         7.19         3.40     124794      58995
    dm-1              0.01         0.19         0.00       3236          0
    
    [root@zabbix ~]# iftop  
    interface: eth0
    IP address is: 10.4.7.62
    MAC address is: 00:0c:29:b2:85:39
    
     性能监视和分析工具 nmon (本地单机监控) 这个工具可以与 nmon 分析程序一同使用,后者将加载 nmon 的输出文件并自动地创建大量的图形。这个可以做报表用
     参考文档:https://www.jianshu.com/p/7858803b0e18
               https://www.cnblogs.com/wnfindbug/p/5719181.html
    
    1. 网络监控
    监控流量
    [root@zabbix ~]# iftop 
    interface: eth0
    IP address is: 10.4.7.62
    MAC address is: 00:0c:29:b2:85:39
    
                              12.5Kb                     25.0Kb                    37.5Kb                     50.0Kb               62.5Kb
    └─────────────────────────┴──────────────────────────┴─────────────────────────┴──────────────────────────┴──────────────────────────
    zabbix                                               => 10.4.7.1                                               944b   1.01Kb  2.40Kb
                                                         <=                                                        184b    184b    294b
    zabbix                                               => dns.google                                               0b      0b     80b
                                                         <=                                                          0b      0b     90b
    
    
    
    
    
    
    
    
    
    
    
    
    ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    TX:             cum:   6.20KB   peak:	12.7Kb                                                       rates:    944b   1.01Kb  2.48Kb
    RX:                     961B            1.95Kb                                                                 184b    184b    384b
    TOTAL:                 7.14KB           14.6Kb                                                                1.10Kb  1.19Kb  2.86Kb
    
    TX 发送流量
    RX 接受流量
    TOTAL 总流量
    
    iftop 常用参数
    参数含义                                                      示   例
    
    -i指定需要监测的网卡                                           iftop –i em1
    -n将输出的主机信息都通过IP显示,不进行DNS反向解析                 iftop -n
    -B将输出以bytes为单位显示网卡流量,默认是bits                    iftop –B
    -p以混杂模式运行iftop,此时iftop可以作为网络嗅探器使用            iftop –p
    -N只显示连接端口号,不显示端口对应的服务名称                      iftop –N
    -P显示主机以及端口信息,这个参数非常有用                          iftop –P
    -F显示特定网段的网卡进出流量                                    iftop –F 192.168.12.0/24
    
    
    显示每个进程的流量
    [root@zabbix ~]# nethogs 
    Ethernet link detected
                          Ethernet link detected
                                                Waiting for first packet to arrive (see sourceforge.net bug 1019381)
    NetHogs version 0.8.5
    
        PID USER     PROGRAM                                                                         DEV        SENT      RECEIVED       
      13759 root     sshd: root@pts/0                                                                eth0        0.166	 0.059 KB/sec
          ? root     unknown TCP                                                                                 0.000	 0.000 KB/sec
    
      TOTAL                                                                                                      0.166       0.059 KB/sec
    
    网站测速 ping测速
    免费网站地址:http://tool.chinaz.com/speedtest.aspx
    smokeping开源的网络监控工具 官网地址:https://oss.oetiker.ch/smokeping/
    

    二、Zabbix 监控环境部署

    2.1.1 Zabbix 监控环境部署

    1. Zabbix环境部署
      监控项:

      Zabbix组件:
    官方文档:https://www.zabbix.com/documentation/4.0/zh/manual
    MySQL 安装
    ### 1.1.1 安装Mysql数据库    
    1) 创建用户
    
    [root@web01 ~]# useradd -M -s /sbin/nologin mysql
    [root@web01 ~]# id mysql
    uid=1001(mysql) gid=1001(mysql) groups=1001(mysql)
    

    2.上传mysql安装包
    下载地址:https://downloads.mysql.com/archives/community/

    [root@web01 /server/tools]# rz -E
    rz waiting to receive.
    [root@web01 /server/tools]# ll
    total 630768
    -rw-r--r-- 1 root  root  644869837 Oct 28  2019 mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
    drwxr-xr-x 9 mysql mysql       186 May  9 21:25 nginx-1.16.0
    -rw-r--r-- 1 root  root    1032345 Apr 23  2019 nginx-1.16.0.tar.gz
    

    3.解压安装

    [root@web01 /server/tools]# tar zxf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz 
    [root@web01 /server/tools]# ll
    total 630768
    drwxr-xr-x 9 root  root        129 May 11 22:22 mysql-5.7.26-linux-glibc2.12-x86_64
    -rw-r--r-- 1 root  root  644869837 Oct 28  2019 mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
    drwxr-xr-x 9 mysql mysql       186 May  9 21:25 nginx-1.16.0
    -rw-r--r-- 1 root  root    1032345 Apr 23  2019 nginx-1.16.0.tar.gz
    #因为mysql是二进制安装,所以解压就可以用
    

    4.移动到第三方软件目录下

    [root@web01 /server/tools]# mv mysql-5.7.26-linux-glibc2.12-x86_64 /application/mysql-5.7.26
    [root@web01 /server/tools]# ll /application/mysql-5.7.26
    total 36
    drwxr-xr-x  2 root root   4096 May 11 22:22 bin
    -rw-r--r--  1 7161 31415 17987 Apr 13  2019 COPYING
    drwxr-xr-x  2 root root     55 May 11 22:22 docs
    drwxr-xr-x  3 root root   4096 May 11 22:21 include
    drwxr-xr-x  5 root root    230 May 11 22:22 lib
    drwxr-xr-x  4 root root     30 May 11 22:21 man
    -rw-r--r--  1 7161 31415  2478 Apr 13  2019 README
    drwxr-xr-x 28 root root   4096 May 11 22:22 share
    drwxr-xr-x  2 root root     90 May 11 22:22 support-files
    
    1. 做个软链接
    [root@web01 /server/tools]# ln -s /application/mysql-5.7.26 /application/mysql
    [root@web01 /server/tools]# ls -ls /application/mysql
    0 lrwxrwxrwx 1 root root 25 May 11 22:33 /application/mysql -> /application/mysql-5.7.26
    

    6.创建件配置文件

    [root@web01 /server/tools]# vim /etc/my.cnf
    [root@web01 /server/tools]# cat /etc/my.cnf
    [mysqld]
    basedir = /application/mysql/
    datadir = /application/mysql/data/
    socket = /tmp/mysql.sock
    #socket=/var/lib/mysql/mysql.sock
    server_id = 1
    port = 3306
    log_error = /application/mysql/data/mysql.err
    pid_ile = /application/mysql/mysql.pid
    log_bin=/data/binlog/mysql-bin
    sync_binlog=1 
    binlog_format=row
    skip-name-resolve
    server-id=52
    gtid-mode=on
    enforce-gtid-consistency=true
    log-slave-updates=1
    relay_log_purge=0
    max_connections=1024
    back_log=128
    wait_timeout=60
    interactive_timeout=7200
    key_buffer_size=16M
    query_cache_size=64M
    query_cache_type=1
    query_cache_limit=50M
    max_connect_errors=20
    sort_buffer_size=2M
    max_allowed_packet=32M
    join_buffer_size=2M
    thread_cache_size=200
    innodb_buffer_pool_size=1024M
    innodb_flush_log_at_trx_commit=1
    innodb_flush_method=O_DIRECT
    innodb_log_buffer_size=32M
    innodb_log_file_size=128M
    innodb_log_files_in_group=3
    binlog_cache_size=2M
    max_binlog_cache_size=8M
    max_binlog_size=512M
    expire_logs_days=7
    read_buffer_size=2M
    read_rnd_buffer_size=2M
    bulk_insert_buffer_size=8M
    [client]
    socket=/tmp/mysql.sock  
    

    7.创建数据存放目录data

    [root@web01 /server/tools]# mkdir /application/mysql/data
    [root@web01 /server/tools]# chown mysql.mysql /application/mysql
    #注意如果这里实在生产环境中的话是添加磁盘做raid10或者raid5格式化分区的磁盘
    

    8.初始化数据库

    [root@web01 /application/mysql]# /application/mysql/bin/mysqld --initialize-insecure --user=mysql  --basedir=/application/mysql/ --datadir=/application/mysql/data
    #注意不要执行第二遍。否则会报错
    
    1. 报错
    [root@web01 /application/mysql]# /application/mysql/bin/mysqld --initialize-insecure --user=mysql --group=mysql  --basedir=/application/mysql/ --datadir=/application/mysql/data/
    2020-05-11T15:16:51.309166Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2020-05-11T15:16:51.311402Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
    2020-05-11T15:16:51.311793Z 0 [ERROR] Aborting
    #解决方法
    [root@web01 /application/mysql]# rm -rf data/*
    再初始化一遍
    

    10 用system来管理mysql

    [root@web01 /application/mysql]# cp /usr/lib/systemd/system/sshd.service /usr/lib/systemd/system/mysqld.service
    [root@web01 /application/mysql/data]# cat /usr/lib/systemd/system/mysqld.service
    [Unit]
    Description=MYSQL server 
    Documentation=https://dev.mysql.com/doc/refman/
    After=network.target 
    After=syslog.target 
    
    
    [Service]
    User=mysql
    Group=mysql
    EnvironmentFile=/etc/my.cnf
    ExecStart=/application/mysql/bin/mysqld --defaults-file=/etc/my.cnf
    limitNOFILE=5000
    
    [Install]
    WantedBy=multi-user.target
    

    11.启动成功

    [root@web01 /application/mysql]# systemctl start mysqld
    [root@web01 /application/mysql]# systemctl status mysqld
    ● mysqld.service - MYSQL server
       Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
       Active: active (running) since Tue 2020-05-12 00:36:14 CST; 12s ago
         Docs: https://dev.mysql.com/doc/refman/
     Main PID: 2103 (mysqld)
       CGroup: /system.slice/mysqld.service
               └─2103 /application/mysql/bin/mysqld --defaults-file=/etc/my.cnf
    
    May 12 00:36:14 web01 systemd[1]: [/usr/lib/systemd/system/mysqld.service:14] Unknown lvalue 'limitNOFILE' in section 'Service'
    May 12 00:36:14 web01 systemd[1]: Started MYSQL server.
    [root@web01 /application/mysql]# systemctl enable mysqld
    Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service.
    
    1. 检查mysql是否启动成功
    [root@web01 /application/mysql]# netstat -luntp|grep mysqld
    tcp6       0      0 :::3306                 :::*                    LISTEN      2608/mysqld 
    
    1. 配置环境变量
    [root@web01 /application/mysql]# echo "export PATH=/application/mysql/bin:$PATH" >>/etc/profile
    [root@web01 /application/mysql]# tail -1 /etc/profile
    export PATH=/application/mysql/bin:/application/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin
    [root@web01 /application/mysql]# . /etc/profile
    
    1. 进入mysql并利用mysqladmin设置用户和密码
    [root@web01 ~]# mysql
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 3
    Server version: 5.7.26 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql>exit 
    Bye
    
    #退出设置用户和密码
    [root@web01 ~]# mysqladmin -u root password '密码'
    mysqladmin: [Warning] Using a password on the command line interface can be insecure.
    Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
    
    1. 再次登录就需要指定用户和密码了
    [root@web01 ~]# mysql -uroot -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 9
    Server version: 5.7.26 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> 
    

    16.创建zabbix用户

    db01 [(none)]>grant all privileges on zabbix.* to zabbix@'10.4.7.%' identified by 'zabiix';
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    db01 [mysql]>use mysql;select user,host from user where user='zabbix';
    Database changed
    +--------+----------+
    | user   | host     |
    +--------+----------+
    | zabbix | 10.4.7.% |
    +--------+----------+
    1 row in set (0.02 sec)
    

    2.1.2 Zabbix环境部署(Nginx+PHP部署)

    1)下载Nginx到到本我服务器

    [root@web01 ~]# mkdir -p /server/tools/
    [root@web01 ~]# cd /server/tools/
    [root@web01 /server/tools]# wget http://nginx.org/download/nginx-1.16.0.tar.gz
    --2020-05-09 21:06:13--  http://nginx.org/download/nginx-1.16.0.tar.gz
    Resolving nginx.org (nginx.org)... 95.211.80.227, 62.210.92.35, 2001:1af8:4060:a004:21::e3
    Connecting to nginx.org (nginx.org)|95.211.80.227|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 1032345 (1008K) [application/octet-stream]
    Saving to: ‘nginx-1.16.0.tar.gz’
    
    100%[===========================================================================================>] 1,032,345   7.08KB/s   in 1m 54s 
    
    2020-05-09 21:08:08 (8.85 KB/s) - ‘nginx-1.16.0.tar.gz’ saved [1032345/1032345]
    
    [root@web01 /server/tools]# ls
    nginx-1.16.0.tar.gz
    

    2)yum下载依赖环境

    [root@web01 /server/tools]# yum install pcre  pcre-devel openssl openssl-devel make gcc gcc-c++ -y
    

    3)创建www用户

    [root@web01 /server/tools]# useradd -M -s /sbin/nologin www
    [root@web01 /server/tools]# id www
    uid=888(www) gid=888(www) groups=888(www)
    

    4)解压Nginx并编译安装

    [root@web01 /server/tools]# tar zxf nginx-1.16.0.tar.gz 
    [root@web01 /server/tools]# cd nginx-1.16.0/
    [root@web01 /server/tools/nginx-1.16.0]# ./configure --help #编译帮助命令
    [root@web01 /server/tools/nginx-1.16.0]# ./configure --prefix=/application/nginx-1.16.0 --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-pcre
    [root@web01 /server/tools/nginx-1.16.0]# make && make install
    

    5)做个软连接去掉版本号

    [root@web01 /server/tools/nginx-1.16.0]# ln -s /application/nginx-1.16.0/ /application/nginx
    [root@web01 /server/tools/nginx-1.16.0]# ls /application/nginx
    conf  html  logs  sbin
    [root@web01 /server/tools/nginx-1.16.0]# ls -l /application/nginx
    lrwxrwxrwx 1 root root 26 May  9 21:29 /application/nginx -> /application/nginx-1.16.0/
    
    1. 查看你版本和编译的参数
    [root@web01 /server/tools/nginx-1.16.0]# cd /application/nginx
    [root@web01 /application/nginx]# sbin/nginx -V
    nginx version: nginx/1.16.0
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
    built with OpenSSL 1.0.2k-fips  26 Jan 2017
    TLS SNI support enabled
    configure arguments: --prefix=/application/nginx-1.16.0 --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-pcre
    
    1. 启动Nginx服务
    [root@web01 /application/nginx]# sbin/nginx 
    [root@web01 /application/nginx]# ps -ef|grep nginx
    root      27669      1  0 21:33 ?        00:00:00 nginx: master process sbin/nginx
    www       27670  27669  0 21:33 ?        00:00:00 nginx: worker process
    root      27672  24853  0 21:33 pts/0    00:00:00 grep --color=auto nginx
    [root@web01 /application/nginx]# ss -luntp|grep 80
    tcp    LISTEN     0      511       *:80                    *:*                   users:(("nginx",pid=27670,fd=6),("nginx",pid=27669,fd=6))
    [root@web01 /application/nginx]# lsof -i :80
    COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
    nginx   27669 root    6u  IPv4 210139      0t0  TCP *:http (LISTEN)
    nginx   27670  www    6u  IPv4 210139      0t0  TCP *:http (LISTEN)
    
    创建zabbix配置问价和代码目录
    [root@web01 /application/nginx/conf]# mkdir extra
    [root@web01 ~]# cd /application/nginx/conf/
    [root@web01 /application/nginx/conf]# cd extra/
    [root@web01 /application/nginx/conf/extra]# cat zabbix.conf 
    server {
            listen       80;
            server_name  10.4.7.7;
    
            #charset koi8-r;
    
            access_log  logs/access_www.log  main;
    
            location / {
                root   html/zabbix;
                index  index.php index.html index.htm;
           }
    
            location ~ .php$ {
                root           html/zabbix;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                    include        fastcgi_params;
            }
    
    #error_page  404              /404.html;
    
    # redirect server error pages to the static page /50x.html
    #
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
    
    }
    [root@web01 /application/nginx/html]# /application/nginx/sbin/nginx -t
    nginx: the configuration file /application/nginx-1.16.0/conf/nginx.conf syntax is ok
    nginx: configuration file /application/nginx-1.16.0/conf/nginx.conf test is successful
    
    将zabbix配置文件加入主配置文件
    [root@web01 /application/nginx/conf/extra]# vim ../nginx.conf
    include extra/*.conf; #添加在http模块中
    
    创建zabbix代码文件目录
    [root@web01 /application/nginx/html]# mkdir zabbix
    [root@web01 /application/nginx/html]# chown -R www.www zabbix/
    

    PHP安装
    1.环境依赖安装

    [root@web01 ~]# yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel   freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel mcrypt mhash re2c bison  libmcrypt-devel -y
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * epel: mirror2.totbb.net
    Package zlib-devel-1.2.7-18.el7.x86_64 already installed and latest version
    No package libiconv-devel available.
    
    2.下载字符编码的库文件
    下载地址:http://www.gnu.org/software/libiconv/
    旧版本:https://ftp.gnu.org/gnu/libiconv/
    
    3.PHP的下载
    官网地址:https://www.php.net
    

    4.编译安装字符编码库文件

    [root@web01 ~]# cd /server/tools/
    [root@web01 /server/tools]# ls 
    libiconv-1.16.tar.gz  mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz  nginx-1.16.0  nginx-1.16.0.tar.gz  php-7.3.5.tar.gz
    [root@web01 /server/tools]# tar zxf libiconv-1.16.tar.gz
    [root@web01 /server/tools]# cd libiconv-1.16/
    [root@web01 /server/tools/libiconv-1.16]# ./configure  --prefix=/application/libiconv
    [root@web01 /server/tools/libiconv-1.16]# make && make install
    

    5.编译安装PHP(因为PHP还做他用所以编译参数较多)

    [root@web01 /server/tools]# tar zxf php-7.3.5.tar.gz 
    [root@web01 /server/tools]# cd php-7.3.5/
    [root@web01 /server/tools/php-7.3.5]# ./configure 
    --prefix=/application/php-7.3.5 
    --enable-mysqlnd  
    --with-mysqli=mysqlnd 
    --with-pdo-mysql=mysqlnd 
    --with-iconv-dir=/application/libiconv 
    --enable-xml 
    --disable-rpath 
    --enable-bcmath 
    --enable-shmop 
    --enable-sysvsem 
    --enable-inline-optimization 
    --with-curl 
    --enable-mbregex 
    --enable-fpm 
    --enable-mbstring 
    --with-gd 
    --with-openssl 
    --with-mhash 
    --enable-pcntl 
    --enable-sockets 
    --with-xmlrpc 
    --enable-soap 
    --enable-short-tags 
    --enable-static 
    --with-xsl 
    --with-fpm-user=www 
    --with-fpm-group=www 
    --enable-ftp 
    --enable-opcache=no 
    --with-freetype-dir 
    --with-jpeg-dir 
    --with-png-dir 
    --with-zlib 
    --with-libxml-dir=/usr 
    --enable-xml 
    --disable-rpath 
    --enable-bcmath 
    --enable-shmop 
    --enable-sysvsem 
    --enable-inline-optimization 
    --with-curl 
    --enable-mbregex 
    --enable-fpm 
    --enable-mbstring 
    --with-gd 
    --with-openssl 
    --with-mhash 
    --enable-pcntl 
    --enable-sockets 
    --with-xmlrpc 
    --enable-soap 
    --enable-short-tags 
    --enable-static 
    --with-xsl 
    --with-fpm-user=www 
    --with-fpm-group=www 
    --enable-ftp 
    --with-gettext 
    --enable-opcache=no
    [root@web01 /server/tools/php-7.3.5]# make && make install
    

    6.创建软连接

    [root@web01 /server/tools/php-7.3.5]# ln -s /application/php-7.3.5/  /application/php
    [root@web01 /server/tools/php-7.3.5]# ls -ld /application/php
    lrwxrwxrwx 1 root root 23 May 14 00:03 /application/php -> /application/php-7.3.5/
    

    7.配置php.ini(PHP解析器配置文件)

    #这个配置文件在PHP的解压源码包里面
    [root@web01 /application/php/etc]# ll /server/tools/php-7.3.5/php.ini*
    -rw-r--r-- 1 root root 71648 Apr 30  2019 /server/tools/php-7.3.5/php.ini-development   #开发环境
    -rw-r--r-- 1 root root 71920 Apr 30  2019 /server/tools/php-7.3.5/php.ini-production    #生产环境
    [root@web01 /application/php/etc]# cp  /server/tools/php-7.3.5/php.ini-production /application/php/lib/php.ini
    [root@web01 /application/php/etc]# ll /application/php/lib/php.ini
    -rw-r--r-- 1 root root 71920 May 14 00:43 /application/php/lib/php.ini
    
    post_max_size = 16M  (8改成16)
    max_execution_time = 300  (30改300)
    max_input_time = 300     (60改300)
    date.timezone = Asia/Shanghai (去掉注释 改为亚洲上海)
    always_populate_raw_post_data -1 (改为-1)
    
    1. 配置PHP FPM
    [root@web01 /application/php/etc]# ll
    total 12
    -rw-r--r-- 1 root root 1321 May 13 23:58 pear.conf
    -rw-r--r-- 1 root root 5417 May 13 23:58 php-fpm.conf.default
    drwxr-xr-x 2 root root   30 May 13 23:58 php-fpm.d
    [root@web01 /application/php/etc]# cp php-fpm.conf.default php-fpm.conf
    [root@web01 /application/php/etc]# ll
    total 20
    -rw-r--r-- 1 root root 1321 May 13 23:58 pear.conf
    -rw-r--r-- 1 root root 5417 May 14 00:49 php-fpm.conf
    -rw-r--r-- 1 root root 5417 May 13 23:58 php-fpm.conf.default
    drwxr-xr-x 2 root root   30 May 13 23:58 php-fpm.d
    [root@web01 /application/php/etc]# cd php-fpm.d/
    [root@web01 /application/php/etc/php-fpm.d]# ll
    total 20
    -rw-r--r-- 1 root root 19240 May 13 23:58 www.conf.default
    [root@web01 /application/php/etc/php-fpm.d]# cp www.conf.default www.conf
    [root@web01 /application/php/etc/php-fpm.d]# ll
    total 40
    -rw-r--r-- 1 root root 19240 May 14 00:50 www.conf
    -rw-r--r-- 1 root root 19240 May 13 23:58 www.conf.default
    

    9.启动PHP

    [root@web01 /application/php/etc/php-fpm.d]# /application/php/sbin/php-fpm 
    [root@web01 /application/php/etc/php-fpm.d]# netstat -luntp|grep php
    tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      8943/php-fpm: maste   #9000端口启动成功
    

    10.配置开机自启动

    [root@web01 /application/php/etc/php-fpm.d]# echo "/application/php/sbin/php-fpm" >>/etc/rc.local 
    [root@web01 /application/php/etc/php-fpm.d]# chmod +x /etc/rc.d/rc.local
    

    11.编写测试文件检查是否成功

    [root@web01 /application/php/etc/php-fpm.d]# vim /application/nginx/html/blog/index.php
    [root@web01 /application/php/etc/php-fpm.d]# cat /application/nginx/html/blog/index.php
    <?php
    phpinfo();
    ?>
    

    2.1.3 Zabbix环境部署(zabbix—server)

    1. Zabbix环境部署
    官方下载地址:https://www.zabbix.com/
    环境依赖安装:yum install libevent-devel  gcc gcc-c++  net-snmp-devel libxml2-devel libcurl-devel mysql-devel java-devel -y
    [root@zabbix /server/tools]# ll
    total 16752
    -rw-r--r-- 1 root root 17153389 Jan 27 23:14 zabbix-4.0.16.tar.gz
    [root@zabbix /server/tools]# mkdir /application
    [root@zabbix /server/tools]# tar zxf zabbix-4.0.16.tar.gz -C /application/
    [root@zabbix /server/tools]# ll /application/
    total 4
    drwxr-xr-x 13 1001 1001 4096 Dec 20  2019 zabbix-4.0.16
    
    创建件zabbix用户
    [root@zabbix /application/zabbix-4.0.16]# useradd -M -s /sbin/nologin zabbix
    [root@zabbix /application/zabbix-4.0.16]# id zabbix
    uid=1001(zabbix) gid=1001(zabbix) groups=1001(zabbix)
    
    [root@zabbix /application/zabbix-4.0.16]# ./configure --prefix=/application/zabbix-4.0.16 --enable-agent --enable-server --enable-java --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2l
    [root@zabbix /application/zabbix-4.0.16]# make && make install
    
    [root@zabbix /application/zabbix-4.0.16]# ln -s /application/zabbix-4.0.16/ /application/zabbix
    
    1. 配置zabbix.conf
    [root@zabbix /application/zabbix-4.0.16]# grep "^[A-Z]" /application/zabbix/conf/zabbix_server.conf 
    LogFile=/application/zabbix/zabbix_server.log  #日志文件
    DBHost=10.4.7.51                               #数据库
    DBName=zabbix                                  #数据库名
    DBUser=zabbix                                  #数据库用户
    DBPassword=zabbix                              #数据库密码
    DBPort=3306                                    #端口
    Timeout=4                                      #超时时间
    AlertScriptsPath=/application/zabbix/alertscripts #监控脚本存放路径
    ExternalScripts=/application/zabbix/externalscripts 
    LogSlowQueries=3000                               #慢查询
    
    [root@zabbix /application/zabbix-4.0.16]# chown -R zabbix.zabbix /application/zabbix
    
    
    1. 在源码包中拷贝mysql数据到db01主机
    [root@zabbix /application/zabbix-4.0.16]# cd database/mysql/
    [root@zabbix /application/zabbix-4.0.16/database/mysql]# ll
    total 6092
    -rw-r--r-- 1 zabbix zabbix 4079073 Dec 20  2019 data.sql
    -rw-r--r-- 1 zabbix zabbix 1978341 Dec 20  2019 images.sql
    -rw-r--r-- 1 root   root     15351 Jul 10 02:32 Makefile
    -rw-r--r-- 1 zabbix zabbix     392 Dec 20  2019 Makefile.am
    -rw-r--r-- 1 zabbix zabbix   15711 Dec 20  2019 Makefile.in
    -rw-r--r-- 1 zabbix zabbix  140265 Dec 20  2019 schema.sql
    [root@zabbix /application/zabbix-4.0.16/database/mysql]# scp -rp *.sql 10.4.7.51:/root/
    The authenticity of host '10.4.7.51 (10.4.7.51)' can't be established.
    ECDSA key fingerprint is SHA256:bbt9sjPOENs3zK9cw7YmIo0ABuFkZnTxXbOaIdpSOo0.
    ECDSA key fingerprint is MD5:e5:3b:15:2e:6c:82:4b:b1:f8:45:dc:80:72:de:11:47.
    Are you sure you want to continue connecting (yes/no)? y
    Please type 'yes' or 'no': yes
    Warning: Permanently added '10.4.7.51' (ECDSA) to the list of known hosts.
    root@10.4.7.51's password: 
    data.sql                                                                                           100% 3983KB  23.7MB/s   00:00    
    images.sql                                                                                         100% 1932KB  31.6MB/s   00:00    
    schema.sql                                                                                         100%  137KB  22.7MB/s   00:00    
    
    在db01导入zabbix数据
    db01 [mysql]>create database zabbix charset utf8mb4;
    db01 [mysql]>show databases like 'zabbix';
    +-------------------+
    | Database (zabbix) |
    +-------------------+
    | zabbix            |
    +-------------------+
    1 row in set (0.00 sec)
    
    db01 [zabbix]>source /root/schema.sql
    db01 [zabbix]>source /root/images.sql
    db01 [zabbix]>source /root/data.sql
    
    db01 [zabbix]>show tables;
    +----------------------------+
    | Tables_in_zabbix           |
    +----------------------------+
    
    
    1. 在源码中拷贝代码到web01 代码zabbix目录下
    [root@zabbix /application/zabbix-4.0.16]# scp -rp frontends/php/* 10.4.7.7:/application/nginx/html/zabbix/
    [root@web01 /application/nginx/html]# chown -R www.www zabbix/
    [root@web01 /application/nginx/html]# systemctl restart nginx
    
    1. 启动zabbix
    [root@zabbix /application/zabbix-4.0.16]# /application/zabbix/sbin/zabbix_server -c /application/zabbix/conf/zabbix_server.conf 
    [root@zabbix /application/zabbix-4.0.16]# /application/zabbix/sbin/zabbix_agentd
    [root@zabbix /application/zabbix-4.0.16]# ss -luntp|grep 10051
    [root@zabbix /application/zabbix-4.0.16]# ps -ef |grep zabbix
    
    1. web网页配置zabbix





    2. 解决中文字体乱码问题

    在web(nginx)端上传字体
    [root@web01 ~]# cd /application/nginx/html/zabbix/assets/fonts/
    [root@web01 /application/nginx/html/zabbix/assets/fonts]# ll
    total 10268
    -rw-r--r-- 1 mysql mysql  756072 Dec 20  2019 DejaVuSans.ttf.back #将原字体文件备份
    -rw-r--r-- 1 root  root  9753388 Mar  2  2019 simhei.ttf
    
    编辑配置字体的PHP文件:
    [root@web01 /application/nginx/html/zabbix/assets/fonts]# vim  ../../include/defines.inc.php
    :%s/DejaVuSans/simhei.ttf/g  #快捷替换
    
    重启Nginx服务
    [root@web01 /application/nginx/html/zabbix/assets/fonts] systemctl restart nginx
    重启zabbix服务
    [root@zabbix ~]# systemctl restart zabbix-server.service 
    [root@zabbix ~]# systemctl status zabbix-server.service 
    
    刷新web页面即可
    

  • 相关阅读:
    Java Mail学习整理
    @RequestBody, @ResponseBody 注解详解(转)
    @RequestMapping 用法详解之地址映射(转)
    理解static关键字
    ClassLoader如何加载class
    请说出作用域public,private,protected,以及不写时的区别
    分页语句-取出sql表中第31到40的记录(以自动增长ID为主键)
    Java构造器和方法的区别
    8月收到的最新更新附近的人交友系统源码,自动打招呼,自动发视频通话+自动聊天多功能机器人交友源码
    8月新亲测完美短视频点赞系统支持抖音+快手+刷宝+微视等所有主流短视频点赞/关注/评论系统源码
  • 原文地址:https://www.cnblogs.com/woaiyunwei/p/13277320.html
Copyright © 2011-2022 走看看