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这个概念好像突然就 ...
随机推荐
- .Net性能调优-ArrayPool
定义 高性能托管数组缓冲池,可重复使用,用租用空间的方式代替重新分配数组空间的行为 好处 可以在频繁创建和销毁数组的情况下提高性能,减少垃圾回收器的压力 使用 获取缓冲池实例:Create/Share ...
- 九、Abp vNext 基础篇丨评论聚合功能
介绍 评论本来是要放到标签里面去讲的,但是因为上一章东西有点多了,我就没放进去,这一章单独拿出来,内容不多大家自己写写就可以,也算是对前面讲解的一个小练习吧. 相关注释我也加在代码上面了,大家看看代码 ...
- 浅谈一种浮标浮岛式水质监测“智能哨兵”助力水质监测,多环境应用ke轻松测水!
浮岛式水质监测站能够在实际使用中,安装方便,能够采集多种参数,溶解氧 氨氮 电导率 盐分 pH值 COD 水位 节省时间和人工,浮标水质监测站是设立在河流.湖泊.水库.近岸海域等流 域内的 ...
- POJ1861 Network (Kruskal算法 +并查集)
Network Description Andrew is working as system administrator and is planning to establish a new net ...
- PHP中一个好玩的性别判断扩展
今天我们来学习的一个扩展同时它也是非常小众的一个扩展,其实说白了,或许是根本没什么人用过得扩展.当然,我们也只是出于学习的目的来看看这个扩展到底是什么东西,有什么好玩的地方. 扩展说明 Gender ...
- 关于python如何构造测试数据
参考资料:https://www.cnblogs.com/miaoxiaochao/p/13234589.html 一.Faker模块是什么? 一个Python第三方模块,主要用来创建伪数据 无需再手 ...
- Jmeter集合点技术
集合点简介 好比小学时候做广播体操,先让大家集合,等到时间统一开始做体操. 创建集合点 同步定时器 同时签到 注意:作用域 参数设置 用户数 为0 具体数值,不能大于 超时时间 为0,没有超时时间 具 ...
- hadoop生态之面试题篇
一.hdfs的高可用 1.先说下自己的理解, 正常的hdfs有namenode,datanode,secondnamenode,但是second name node 不是真正意义上的namenode备 ...
- [转载]CentOS 7安装配置Samba服务器
假设我们有这样一个场景 共享名路径权限SHAREDOC/smb/docs所有人员包括来宾均可以访问RDDOCS/smb/tech仅允许特定组的用户进行读写访问 特定组的组名为RD,目前的Alice.J ...
- Windows与MAC使用差异有感(还会不断更新体验)
Windows与MAC使用差异有感(还会不断更新体验) 关于键盘 这上是MAC与Windows的⌨️按键区别 我们现在都是USB键盘,而PS/2键盘是已经淘汰掉的(插头是圆孔的),看上图会发现Comm ...