zabbix

zabbix简介

zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。zabbix由2部分构成,zabbix server与可选组件zabbix agent。zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。

zabbix的主要特点

  • 安装与配置简单,学习成本低
  • 支持多语言(包括中文)
  • 免费开源
  • 自动发现服务器与网络设备
  • 分布式监视以及WEB集中管理功能
  • 可以无agent监视
  • 用户安全认证和柔软的授权方式
  • 通过WEB界面设置或查看监视结果
  • 告警通知:微信、QQ、Email等发送消息,打电话
  • 开箱即用的模板库
  • 无限数据预处理

zabbix主要功能

  • 系统监控
    内存使用率
    硬盘使用率
    CPU使用率
  • 网络监控
    流量
    网卡
  • 硬件监控 IPMI
    电源
    CPU温度
    硬盘温度
  • 业务监控
    进程
    日志

zabbix配置文件

服务器端默认配置文件(/usr/local/etc/zabbix_server.conf)
客户端默认配置文件(/usr/local/etc/zabbix_agentd.conf)
zabbix代理默认配置文件(/usr/local/etc/zabbix_proxy.conf)

服务器端配置文件zabbix_server.conf常用配置参数:

参数作用
LogFile设置服务端日志文件存放路径
ListenIP设置服务端监听IP
ListenPort设置服务端监听的端口号
PidFile设置服务端进程号文件存放路径
DBHost指定zabbix的数据库服务器IP
DBName指定zabbix使用的数据库库名
DBUser指定zabbix数据库登录用户
DBPassword指定zabbix数据库登录密码
DBPort指定zabbix数据库端口号
User设置zabbix以什么用户的身份运行
AlertScriptsPath设置告警脚本存放路径
ExternalScripts外部脚本存放路径

客户端配置文件zabbix_agentd.conf常用配置参数:

参数作用
Server指定zabbix服务器的IP或域名
ServerActive指定zabbix服务器的IP或域名
Hostname指定本机的主机名,此项必须与web界面配置项一致
UnsafeUserParameters是否启用自定义监控项,可选值为{1
UserParameter指定自定义监控脚本参数
LogFile设置客户端日志文件存放路径

部署zabbix

环境说明:

环境IP要安装的应用
服务器192.168.2159.167lamp架构 zabbix server zabbix agent

因为zabbix是用php语言开发的,所以必须先部署lamp架构,使其能够支持运行php网页

[root@167 ~]# useradd -rMs /sbin/nologin zabbix  //创建用户
[root@167 ~]# id zabbix 
uid=993(zabbix) gid=990(zabbix) groups=990(zabbix)
[root@167 ~]# dnf -y  install  libevent-devel mysql-devel golang-bin    //安装依赖包
//下载zabbix的压缩包
[root@167 ~]# wget https://cdn.zabbix.com/zabbix/sources/stable/6.2/zabbix-6.2.2.tar.gz
--2022-09-01 20:42:59--  https://cdn.zabbix.com/zabbix/sources/stable/6.2/zabbix-6.2.2.tar.gz
Resolving cdn.zabbix.com (cdn.zabbix.com)... 104.26.6.148, 172.67.69.4, 104.26.7.148, ...
Connecting to cdn.zabbix.com (cdn.zabbix.com)|104.26.6.148|:443... connected.
HTTP request sent, awaiting response... Read error (Success.) in headers.
Retrying.

--2022-09-01 20:43:15--  (try: 2)  https://cdn.zabbix.com/zabbix/sources/stable/6.2/zabbix-6.2.2.tar.gz
Connecting to cdn.zabbix.com (cdn.zabbix.com)|104.26.6.148|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 34995538 (33M) [application/octet-stream]
Saving to: 'zabbix-6.2.2.tar.gz'

zabbix-6.2.2.tar.gz 100%[===================>]  33.37M  9.93MB/s    in 3.4s    

2022-09-01 20:43:19 (9.93 MB/s) - 'zabbix-6.2.2.tar.gz' saved [34995538/34995538]

[root@167 ~]# ls
anaconda-ks.cfg  httpd.sh  php.sh  test.sh  zabbix-6.2.2.tar.gz
[root@167 ~]# 
//解压zabbix压缩包
[root@167 ~]# tar -xf zabbix-6.2.2.tar.gz 
[root@167 ~]# ls
anaconda-ks.cfg  httpd.sh  php.sh  test.sh  zabbix-6.2.2  zabbix-6.2.2.tar.gz
//配置zabbix数据库
[root@167 ~]# mysql -uroot -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 10.5.9-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.007 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
Query OK, 0 rows affected (0.005 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.005 sec)

MariaDB [(none)]> quit
Bye
[root@167 ~]# 
//导入数据
[root@167 ~]# cd zabbix-6.2.2/database/mysql/
[root@167 mysql]# mysql -uzabbix -p123456 zabbix < schema.sql
[root@167 mysql]# mysql -uzabbix -p123456 zabbix < images.sql
[root@167 mysql]# mysql -uzabbix -p123456 zabbix < data.sql
// 配置源代码
[root@167 mysql]# cd /root/zabbix-6.2.2/
[root@167 zabbix-6.2.2]# ./configure --enable-server --enable-agent --with-mysql --with-libcurl --with-libxml2
checking for a BSD-compatible install... /usr/bin/install -c
......
 Enable agent:          yes
  Agent details:
    TLS:                   no
    Modbus:                no
    Linker flags:                -rdynamic    
    Libraries:              -lz -lpthread    -lcurl -lm -ldl  -lresolv  -lpcre  
    Configuration file:    /usr/local/etc/zabbix_agentd.conf
    Modules:               /usr/local/lib/modules

  Enable agent 2:        no

  Enable web service:    no

  Enable Java gateway:   no

  LDAP support:          no
  IPv6 support:          no

***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*              <http://www.zabbix.com>                    *
***********************************************************

[root@167 zabbix-6.2.2]# make install

配置zabbix服务端

[root@167 zabbix-6.2.2]# cd /usr/local/etc/
[root@167 etc]# ls
zabbix_agentd.conf    zabbix_server.conf
zabbix_agentd.conf.d  zabbix_server.conf.d
[root@167 etc]# vim zabbix_server.conf
DBPassword=123456
//启动zabbix服务
[root@167 etc]# zabbix_server 
[root@167 etc]# zabbix_agentd 
[root@167 etc]# ss -antl
State   Recv-Q   Send-Q     Local Address:Port      Peer Address:Port  Process  
LISTEN  0        128            127.0.0.1:9000           0.0.0.0:*              
LISTEN  0        128              0.0.0.0:22             0.0.0.0:*              
LISTEN  0        128              0.0.0.0:10050          0.0.0.0:*              
LISTEN  0        128              0.0.0.0:10051          0.0.0.0:*              
LISTEN  0        80                     *:3306                 *:*              
LISTEN  0        128                    *:80                   *:*              
LISTEN  0        128                 [::]:22                [::]:*              
[root@167 etc]# 

zabbix服务端web界面安装与配置

[root@167 ~]# cp /usr/local/php-7.4.30/php.ini-development /etc/php.ini
[root@167 ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@167 ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@167 ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@167 ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
[root@167 ~]# vim /etc/php.ini 
mysqli.default_socket = /var/lib/mysql/mysql.sock
[root@167 ~]# /usr/local/php/bin/php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File:         /etc/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)
[root@167 ~]# systemctl restart php.service
[root@167 ~]# cp -a zabbix-6.2.2/ui/* /usr/local/apache/htdocs/homepage/
cp: overwrite '/usr/local/apache/htdocs/homepage/index.php'? y
[root@167 ~]# vim /usr/local/apache/conf/extra/httpd-vhosts.conf 
[root@167 ~]# cat /usr/local/apache/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
        DocumentRoot /usr/local/apache/htdocs/homepage
        ServerName www.zabbix.com
        ErrorLog logs/dummy-zabbix.example.com-error_log
        CustomLog logs/dummy-zabbix.example.com-access_log common
        ProxyRequests Off
        ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/homepage/
        <Directory /usr/local/apache/htdocs/homepage>
                Options none
                AllowOverride none
                Require all granted
        </Directory>
</VirtualHost>
[root@167 ~]# chown -R apache:apache /usr/local/apache/htdocs/
[root@167 ~]# chmod 777 /usr/local/apache/htdocs/homepage/conf/
[root@167 ~]# systemctl restart httpd.service 

web页面安装

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

恢复zabbix/conf目录的权限为755

[root@167 ~]# chmod 755 /usr/local/apache/htdocs/homepage/conf/
[root@167 ~]# ll -d /usr/local/apache/htdocs/homepage/conf/
drwxr-xr-x. 3 apache apache 117 91 21:02 /usr/local/apache/htdocs/homepage/conf/

在这里插入图片描述

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐