当前位置: 移动技术网 > 网络运营>服务器>Linux > 监控服务zabbix部署

监控服务zabbix部署

2020年07月23日  | 移动技术网网络运营  | 我要评论

1. zabbix介绍

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

zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。

zabbix由2部分构成,zabbix server与可选组件zabbix agent。

zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Ubuntu,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。

zabbix agent需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集。

zabbix agent需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集。

另外zabbix server还支持SNMP (v1,v2),可以与SNMP软件(例如:net-snmp)等配合使用。

2. zabbix特点

zabbix的主要特点:

  • 安装与配置简单,学习成本低
  • 支持多语言(包括中文)
  • 免费开源
  • 自动发现服务器与网络设备
  • 分布式监视以及WEB集中管理功能
  • 可以无agent监视
  • 用户安全认证和柔软的授权方式
  • 通过WEB界面设置或查看监视结果
  • email等通知功能

Zabbix主要功能:

  • CPU负荷
  • 内存使用
  • 磁盘使用
  • 网络状况
  • 端口监视
  • 日志监视

3. zabbix配置文件

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 外部脚本存放路径

4.部署zabbix

环境说明:

环境 ip 要安装的应用
服务端 192.168.214.200 lamp架构
zabbix server
zabbix agent
客户端 192.168.214.100 zabbix agent

4.1 zabbix服务端安装

[root@yanlei tmp]# tar xf zabbix-5.0.2.tar.gz 
[root@yanlei tmp]# useradd -r -g zabbix -M -s /sbin/nologin zabbix
useradd: group 'zabbix' does not exist
[root@yanlei tmp]# useradd -r  -M -s /sbin/nologin zabbix
[root@yanlei tmp]# mysql -uroot -p123456
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix123!';
Query OK, 0 rows affected, 2 warnings (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
[root@yanlei mysql]# mysql -uzabbix -pzabbix123! zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@yanlei mysql]# mysql -uzabbix -pzabbix123! zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@yanlei mysql]# mysql -uzabbix -pzabbix123! zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
>上面三个必须按顺序导入

[root@yanlei zabbix-5.0.2]# ./configure --enable-server \
> --enable-agent \
> --with-mysql \
> --with-net-snmp \
> --with-libcurl \
> --with-libxml2
configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config

[root@yanlei ~]# yum -y install net-snmp-devel
[root@yanlei zabbix-5.0.2]# ./configure --enable-server \
> --enable-agent \
> --with-mysql \
> --with-net-snmp \
> --with-libcurl \
> --with-libxml2
configure: error: Unable to use libevent (libevent check failed)

[root@yanlei ~]# yum  -y install libevent-devel  

[root@yanlei zabbix-5.0.2]# ./configure --enable-server \
> --enable-agent \
> --with-mysql \
> --with-net-snmp \
> --with-libcurl \
> --with-libxml2

[root@yanlei zabbix-5.0.2]# make install

4.2 zabbix服务端配置

[root@yanlei zabbix-5.0.2]# cd /usr/local/etc/
[root@yanlei etc]# vim zabbix_server.conf
DBPassword=zabbix123!
DBHost=localhost
[root@yanlei etc]# ss -antl
State      Recv-Q Send-Q    Local Address:Port                   Peer Address:Port              
LISTEN     0      128                   *:10051                             *:*                  
LISTEN     0      128           127.0.0.1:9000                              *:*                  
LISTEN     0      128                   *:22                                *:*                  
LISTEN     0      100           127.0.0.1:25                                *:*                  
LISTEN     0      80                   :::3306                             :::*                  
LISTEN     0      128                  :::80                               :::*                  
LISTEN     0      128                  :::22                               :::*                  
LISTEN     0      100                 ::1:25                               :::*
[root@yanlei etc]# zabbix_agentd
[root@yanlei etc]# ss -antl
State      Recv-Q Send-Q    Local Address:Port                   Peer Address:Port              
LISTEN     0      128                   *:10050                             *:*                  
LISTEN     0      128                   *:10051                             *:*                  
LISTEN     0      128           127.0.0.1:9000                              *:*                  
LISTEN     0      128                   *:22                                *:*                  
LISTEN     0      100           127.0.0.1:25                                *:*                  
LISTEN     0      80                   :::3306                             :::*                  
LISTEN     0      128                  :::80                               :::*                  
LISTEN     0      128                  :::22                               :::*                  
LISTEN     0      100                 ::1:25                               :::*
[root@yanlei ~]# cd /usr/src/zabbix-5.0.2/
oot@yanlei zabbix-5.0.2]# cp -r ui /usr/local/apache/htdocs/zabbix
[root@yanlei zabbix-5.0.2]# chown -R apache.apache /usr/local/apache/htdocs/

[root@yanlei~]# vim /etc/httpd24/extra/httpd-vhosts.conf
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/zabbix"
    ServerName www.example.com
    ProxyRequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1
    <Directory "/usr/local/apache/htdocs">
        Options none
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>
//设置zabbix/conf目录的权限,让zabbix有权限生成配置文件zabbix.conf.php
[root@yanlei ~]# cd /usr/local/apache/htdocs/zabbix/
[root@yanlei zabbix]# ll -d conf
drwxr-xr-x. 3 apache apache 94 Jul 20 02:16 conf
[root@yanlei zabbix]# chmod 777 conf
[root@yanlei zabbix]# apachectl stop
[root@yanlei zabbix]# apachectl start
[root@yanlei zabbix]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done
[root@yanlei zabbix]# service mysqld restart
Shutting down MySQL..... SUCCESS! 
Starting MySQL. SUCCESS! 

[root@yanlei zabbix]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@yanlei zabbix]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@yanlei zabbix]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@yanlei zabbix]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
[root@yanlei zabbix]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done

4.3 zabbix客户端配置

[root@localhost etc]# yum -y install vim wget
[root@localhost etc]# yum -y install gcc gcc-c++
[root@localhost ~]# tar xf zabbix-5.0.2.tar.gz
[root@localhost ~]# cd zabbix-5.0.2
[root@localhost zabbix-5.0.2]# ./configure --enable-agent
[root@localhost zabbix-5.0.2]# yum -y install pcre-devel
[root@localhost zabbix-5.0.2]# ./configure --enable-agent
[root@localhost zabbix-5.0.2]# make install
[root@localhost zabbix-5.0.2]# cd /usr/local/etc/
[root@localhost etc]# ls
[root@localhost etc]# vim zabbix_agentd.conf
[root@localhost etc]# ServerActive=192.168.214.200
[root@localhost etc]# Server=192.168.214.200
Hostname=YAN
useradd -r  -M -s /sbin/nologin zabbix
zabbix_agentd
[root@localhost etc]# ss -antl
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128      *:10050                *:*                  
LISTEN     0      128      *:22                   *:*                  
LISTEN     0      100    127.0.0.1:25                   *:*                  
LISTEN     0      128     :::22                  :::*                  
LISTEN     0      100    ::1:25                  :::*

在这里插入图片描述

在这里插入图片描述
密码为zabbix123!
在这里插入图片描述
密码:zabbix

本文地址:https://blog.csdn.net/aleihello/article/details/107444254

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网