Linux下Zabbix5.0 LTS监控基础原理及安装部署(图文教程)
Zabbix 是什么?
- zabbix 是一个基于 Web 界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。通过 C/S 模式采集数据,通过 B/S 模式在 Web 端展示和配置,能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
- zabbix 由2部分构成,zabbix server 与可选组件 zabbix agent;zabbix server 可以通过 SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能。zabbix agent 需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU 等信息的收集。
Zabbix监控系统运行大概流程:
Zabbix由zabbix server与可选组件zabbix agent两部分组成。
- Zabbix Server 可以通过 SNMP,Zabbix agent,Ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集功能,可以在运行 Linux,Solaris,HP-UX,AIX,FreeBSD,OpenBSD,OS X,Windows多平台。
- Zabbix Agent 安装在需要被监控的目标服务器上,主要完成对硬件信息与操作系统有关的内存,CPU 等信息收集。
- Zabbix Server可以单独监视远程服务器的服务状态,同时也可以与Zabbix Agent结合。可以轮询Zabbix Agent主动接收监视数据(trapping传递 方式),同时还可以被动接收Zabbix Agent发送的数据。
- 主动:agent请求server获取主动的监控项列表,并主动将监控项内需要检测的数据提交给server/proxy。
- 被动:server向agent请求获取监控项的数据,agent返回数据。
那实际监控中是用主动的还是被动的呢?这里主要涉及两个地方:
- (1) 新建监控项目时,选择的是zabbix代理还是zabbix端点代理程式(主动式),前者是被动模式,后者是主动模式。
- (2) agentd配置文件中StartAgents参数的设置,如果为0,表示禁止被动模式,否则开启。一般建议不要设置为0,因为监控项目很多时,可以部分使用主动,部分使用被动模式。
Zabbix监控常用架构:
- (1) server-agentd模式:这个是最简单的架构了,常用于监控主机比较少的情况下。
- (2) server-proxy-agentd模式:这个常用于比较多的机器,使用proxy进行分布式监控,有效的减轻server端的压力。

Zabbix官方站点:【文档、源码包、rpm包】下载提供了两种版本:LTS版(Long Term Support)和标准版。
Zabbix YUM安装部署过程如下:
| 属性 | Zabbix Server | Zabbix Client |
| 节点 | ZabbixServer-01 | ZabbixClient-01 |
| 系统 | CentOS Linux release 7.5.1804 (Minimal) | CentOS Linux release 7.5.1804 (Minimal) |
| 内核 | 3.10.0-862.el7.x86_64 | 3.10.0-862.el7.x86_64 |
| SELinux | setenforce 0 | disabled | setenforce 0 | disabled |
| Firewlld | systemctl stop/disable firewalld | systemctl stop/disable firewalld |
| IP地址 | 172.16.70.37 |
172.16.70.171 |
- 第一部分:ZabbixServer-01 上操作。
# 准备环境
[root@ZabbixServer-01 ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@ZabbixServer-01 ~]# uname -r
3.10.0-862.el7.x86_64
[root@ZabbixServer-01 ~]# setenforce 0
[root@ZabbixServer-01 ~]# sed -i '7s#enforcing#disabled#' /etc/selinux/config
[root@ZabbixServer-01 ~]# systemctl stop firewalld && systemctl disable firewalld
[root@ZabbixServer-01 ~]# yum install -y vim net-tools lsof wget curl lrzsz # 安装zabbix noarch.rpm
[root@ZabbixServer-01 ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm # 修改/etc/yum.repos.d/zabbix.repo,将[zabbix-frontend]下的enabled改为1【注意项】
[root@ZabbixServer-01 ~]# sed -i.bak '11s#enabled=0#enabled=1#' /etc/yum.repos.d/zabbix.repo
[root@ZabbixServer-01 ~]# yum clean all
[root@ZabbixServer-01 ~]# yum repolist | grep zabbix
zabbix/x86_64 Zabbix Official Repository - x86_64 200
zabbix-frontend/x86_64 Zabbix Official Repository frontend - x86_64 183
zabbix-non-supported/x86_64 Zabbix Official Repository non-supported - x8 5 # 安装zabbix server和agent
[root@ZabbixServer-01 ~]# yum install -y zabbix-server-mysql zabbix-agent # 安装Software Collections便于后续安装高版本的php
[root@ZabbixServer-01 ~]# yum install -y centos-release-scl # 安装zabbix FE和相关环境
[root@ZabbixServer-01 ~]# yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl # 安装centos7默认的mariadb数据库
[root@ZabbixServer-01 ~]# yum install -y mariadb mariadb-server
[root@ZabbixServer-01 ~]# systemctl start mariadb && systemctl enable mariadb # 安全初始化mariadb并配置root密码
[root@ZabbixServer-01 ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here. Enter current password for root (enter for none): # 空密码,直接回车
OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation. Set root password? [Y/n] Y # 是否设置root密码
New password: # root密码
Re-enter new password: # 再次输入root密码
Password updated successfully!
Reloading privilege tables..
... Success! By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment. Remove anonymous users? [Y/n] Y # 是否删除匿名账号
... Success! Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] Y # 是否禁止root远程登录
... Success! By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment. Remove test database and access to it? [Y/n] Y # 是否删除test库和test库的访问权限
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success! Reloading the privilege tables will ensure that all changes made so far
will take effect immediately. Reload privilege tables now? [Y/n] Y # 是否刷新授权表使其立即生效
... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB
installation should now be secure. Thanks for using MariaDB! # 测试root登录,并授权
[root@ZabbixServer-01 ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 5.5.68-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.
# 创建zabbix数据库
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
# 创建zabbix用户
MariaDB [(none)]> create user zabbix@localhost identified by 'zabbix@01';
Query OK, 0 rows affected (0.00 sec)
# 授权zabbix权限
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)
# 刷新授权,使其立即生效
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit
Bye # 查看用户权限
MariaDB [(none)]> select user,host,password from mysql.user;
+--------+-----------+-------------------------------------------+
| user | host | password |
+--------+-----------+-------------------------------------------+
| root | localhost | *A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF |
| root | 127.0.0.1 | *A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF |
| root | ::1 | *A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF |
| zabbix | localhost | *A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF |
+--------+-----------+-------------------------------------------+
4 rows in set (0.00 sec) MariaDB [(none)]> show grants for zabbix@'localhost';
+---------------------------------------------------------------------------------------------------------------+
| Grants for zabbix@localhost |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'zabbix'@'localhost' IDENTIFIED BY PASSWORD '*A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF' |
| GRANT ALL PRIVILEGES ON `zabbix`.* TO 'zabbix'@'localhost' |
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.01 sec) # 测试zabbix用户登录
[root@ZabbixServer-01 ~]# mysql -u zabbix -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.68-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)]> show grants for current_user();
+---------------------------------------------------------------------------------------------------------------+
| Grants for zabbix@localhost |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'zabbix'@'localhost' IDENTIFIED BY PASSWORD '*A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF' |
| GRANT ALL PRIVILEGES ON `zabbix`.* TO 'zabbix'@'localhost' |
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec) # 导入zabbix数据库,zabbix数据库用户为zabbix,密码为zabbix@01
[root@ZabbixServer-01 ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix # 编辑配置文件/etc/zabbix/zabbix_server.conf,设置数据库密码
[root@ZabbixServer-01 ~]# sed -i.bak '/# DBPassword=/a\DBPassword=zabbix@01' /etc/zabbix/zabbix_server.conf # 编辑配置文件/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf,修改时区
[root@ZabbixServer-01 ~]# sed -i.bak '$c php_value[date.timezone] = Asia/Shanghai' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf # 重启服务并设置开启自启动
[root@ZabbixServer-01 ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@ZabbixServer-01 ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm [root@ZabbixServer-01 ~]# netstat -nutpl | grep -E 'zabbix|mysql|php|http'
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2120/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 2127/zabbix_server
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 2118/php-fpm: maste
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1991/mysqld
tcp6 0 0 :::10050 :::* LISTEN 2120/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 2127/zabbix_server
tcp6 0 0 :::80 :::* LISTEN 2117/httpd [root@ZabbixServer-01 ~]# hostname -I
172.16.70.37 浏览器访问 http://172.16.70.37/zabbix
- 首次访问时需要进行一些初始化的设置,我们按照提示操作即可,点击“Next setp”。

- 检查各个组件配置是否正常,全部显示“OK”,点击“Next setp”。


- 默认数据库端口3306,若在安装数据库自定义了端口,则需要在这修改,点击“Next setp”。

- 可选配置,当有多台ZabbixServer时,可在这设置“Name”,会显示在页面标签,以便区分,点击“Next setp”。

- 检查所填的信息,如有误点击“Back”返回修改,无误,点击“Next setp”。

- 点击“Finish”完成配置。

- 登录账号默认为 Admin,默认密码:zabbix

- 首页,仪表盘。

- 设置中文模式。


- 此时,页面已成为中文模式。

- 语言设置为中文时,页面乱码如图,有小方块,影响阅读。

- Windows10字体路径,选择想更换的字体,复制粘贴至桌面。

- 再次回到ZabbixServer-01机操作。
[root@ZabbixServer-01 ~]# cd /usr/share/zabbix/assets/fonts/
[root@ZabbixServer-01 fonts]# mv graphfont.ttf graphfont.ttf.bak
[root@ZabbixServer-01 fonts]# rz # 上传粘贴在桌面文字
[root@ZabbixServer-01 fonts]# ls
graphfont.ttf.bak simsun.ttc
[root@ZabbixServer-01 fonts]# mv simsun.ttc simsun.ttf # 修改拓展名
[root@ZabbixServer-01 fonts]# ls
graphfont.ttf.bak simsun.tt # 修改Zabbix的配置文件/usr/share/zabbix/include/defines.inc.php
[root@ZabbixServer-01 ~]# sed -i.bak 's/graphfont/simsun/g' /usr/share/zabbix/include/defines.inc.php
解析:将下面两行graphfont改为simsun
define('ZBX_GRAPH_FONT_NAME', 'graphfont'); // font file name
define('ZBX_FONT_NAME', 'graphfont');
[root@ZabbixServer-01 ~]# systemctl restart zabbix-server

- 第二部分:ZabbixClient-01 上操作。
# 准备环境
[root@ZabbixClient-01 ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@ZabbixClient-01 ~]# uname -r
3.10.0-862.el7.x86_64
[root@ZabbixClient-01 ~]# setenforce 0
[root@ZabbixClient-01 ~]# sed -i '7s#enforcing#disabled#' /etc/selinux/config
[root@ZabbixClient-01 ~]# systemctl stop firewalld && systemctl disable firewalld
[root@ZabbixClient-01 ~]# yum install -y vim net-tools lsof wget curl # 安装zabbix-agent/sender
[root@ZabbixClient-01 ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[root@ZabbixClient-01 ~]# yum install -y zabbix-agent zabbix-sender # 修改配置文件/etc/zabbix/zabbix_agentd.conf
[root@ZabbixClient-01 ~]# sed -i.bak '117s/Server=127.0.0.1/Server=172.16.70.37/;158s/ServerActive=127.0.0.1/ServerActive=172.16.70.37/' /etc/zabbix/zabbix_agentd.conf
[root@ZabbixClient-01 ~]#sed -i '169s/Hostname=Zabbix server/Hostname=ZabbixClient-01/' /etc/zabbix/zabbix_agentd.conf # 解析
Server=172.16.70.37 # Zabbix Server服务器IP(被动)
ServerActive=172.16.70.37 # Zabbix Server服务器IP(主动)
Hostname=ZabbixClient-01 # 本机能被server端识别的名称 # 启动服务
[root@ZabbixClient-01 ~]# systemctl start zabbix-agent
[root@ZabbixClient-01 ~]# netstat -nuptl | grep zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 4839/zabbix_agentd
tcp6 0 0 :::10050 :::* LISTEN 4839/zabbix_agentd
[root@ZabbixClient-01 ~]# ps -ef |grep zabbix
zabbix 4839 1 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix 4840 4839 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 4841 4839 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix 4842 4839 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix 4843 4839 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix 4844 4839 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
- Zabbix Web设置。







Linux下Zabbix5.0 LTS监控基础原理及安装部署(图文教程)的更多相关文章
- Linux下Zabbix5.0 LTS添加MySQL监控,实现邮件报警并执行预处理操作
依据前文:Linux下Zabbix5.0 LTS监控基础原理及安装部署(图文教程) 环境,继续添加MySQL应用集. 第一部分:添加Zabbix自带的MySQL应用集. 在ZabbixClient-0 ...
- Linux下Zabbix5.0 LTS添加自定义监控项
自定义监控项 zabbix本身提供了很多可选的监控项,可以满足绝大部分的监控需求.有时候由于业务需求,需要自定义监控项. 下面以创建mysql自定义监控项为例,分享如何创建zabbix自定义监控项. ...
- Linux下Zabbix5.0 LTS + Grafana8.2.2图形可视化
Grafana是一款开源的可视化软件,可以搭配数据源实现一个数据的展示和分析:Grafana功能强大,有着丰富的插件,但Grafana默认没有zabbix作为数据源,需要手动给zabbix安装一个插件 ...
- Linux下一键安装包的基础上安装SVN及实现nginx web同步更新
Linux下一键安装包的基础上安装SVN及实现nginx web同步更新 一.安装 1.查看是否安装cvs rpm -qa | grep subversion 2.安装 yum install sub ...
- Linux下tomcat6.0与jdk安装
Linux下tomcat6.0与jdk安装 步骤如下: 1. 上传apache-tomcat-6.0.37.tar.gz和jdk-6u13-linux-i586.bin至/usr/local 给这两个 ...
- Linux下的暴力密码在线破解工具Hydra安装及其组件安装-使用
Linux下的暴力密码在线破解工具Hydra安装及其组件安装-使用 hydra可以破解: http://www.thc.org/thc-hydra,可支持AFP, Cisco AAA, Cisco a ...
- linux下怎么卸载自带的JDK和安装想要的JDK
linux下怎么卸载自带的JDK和安装想要的JDK 安装linux系统后,系统有自带jdk的版本,因为系统中的有些软件需要使用此环境.但时候我们安装eclipse和tomcat的时候,使用此jdk ...
- Linux下使用 github+hexo 搭建个人博客02-hexo部署到Github Pages
之前的这篇文章<Linux下使用 github+hexo 搭建个人博客01-hexo搭建>,相信大家都知道怎么搭建 hexo ,怎么切换主题,并且完成了一篇博文的创建,以及 MarkDow ...
- Step by Step 真正从零开始,TensorFlow详细安装入门图文教程!帮你完成那个最难的从0到1
摘要: Step by Step 真正从零开始,TensorFlow详细安装入门图文教程!帮你完成那个最难的从0到1 安装遇到问题请文末留言. 悦动智能公众号:aibbtcom AI这个概念好像突然就 ...
随机推荐
- JS007. 深入探讨带浮点数运算丢失精度问题(二进制的浮点数存储方式)
复现与概述 当JS在进行浮点数运算时可能产生丢失精度的情况: 从肉眼可见的程度上观察,发生精度丢失的浮点数是没有规律的,但该浮点数丢失精度的问题会100%复现.经查阅,这个问题要追溯至浮点数的二进制存 ...
- 通过HttpURLConnection下载图片到本地--下载附件
一.背景说明 现在我做的系统中,需要有一个下载附件的功能,其实就是下载图片到本地中.相应的图片保存在多媒体系统中,我们只能拿到它的资源地址(url),而不是真实的文件. 这里记录的是下载单个图片.下篇 ...
- PTA 面向对象程序设计6-2 统计数字
对于给定的一个字符串,统计其中数字字符出现的次数. 类和函数接口定义: 设计一个类Solution,其中包含一个成员函数count_digits,其功能是统计传入的string类型参数中数字字符的个数 ...
- PHP中的PDO操作学习(四)查询结构集
关于 PDO 的最后一篇文章,我们就以查询结果集的操作为结束.在数据库的操作中,查询往往占的比例非常高.在日常的开发中,大部分的业务都是读多写少型的业务,所以掌握好查询相关的操作是我们学习的重要内容. ...
- mysql语句alter添加 字段
alter table ylh_coupon add is_reg int default 0 给数据表 ylh_coupon 添加一个字段 is_reg,,整型,默认值为0
- Mybatis中使用级联查询,一对多的查询
一.需求描述 自己在开发一个小程序的过程中,需要做的一个查询是稍微比较复杂的查询,根据用户信息去查询用户所对应的宠物信息. 一个用户可能对应多个宠物,所以在用户和宠物信息的对应关系就是一对多的关系. ...
- axios的简单的使用
Axios 是什么? Axios 是一个基于 promise 网络请求库,作用于node.js 和浏览器中. 它是 isomorphic 的(即同一套代码可以运行在浏览器和node.js中).在服务端 ...
- 『Python』整洁之道
1. 使用 assert 加一层保险 断言是为了告诉开发人员程序中发生了不可恢复的错误,对于可以预料的错误(如文件不存在),用户可以予以纠正或重试,断言并不是为此而生的. 断言用于程序内部自检,如声明 ...
- 防刷功能的实现(thinkphp5)
$seconds = '3'; //时间段[秒] $refresh = '3';//最大次数 $cur_time = time(); if(Session::get('refresh_times')) ...
- 鸿蒙内核源码分析(任务调度篇) | 任务是内核调度的单元 | 百篇博客分析OpenHarmony源码 | v4.05
百篇博客系列篇.本篇为: v04.xx 鸿蒙内核源码分析(任务调度篇) | 任务是内核调度的单元 | 51.c.h .o 任务管理相关篇为: v03.xx 鸿蒙内核源码分析(时钟任务篇) | 触发调度 ...