[TOC]
# 一、概述
## 1、Zabbix 4.0 LTS
2018年10月1日,Zabbix官方正式发布Zabbix 4.0 LTS版本,作为长期支持版本,意味着可以获得官方5年的支持。其中完全支持到2021年10月31日,以及有限支持到2023年10月31日,同时官方4.0文档已经更新。 最直观的感受就是重新设计了图形展示,新增了Kiosk模式实现真正意义上的全屏,可以直接做大屏展示,时间选择器做的和Kibana类似; Zabbix 4.0 LTS对分布式监控Proxy方式也做了优化,引入了与Proxy通信的压缩,大大减少了传输数据的大小。从而提高了性能。 Zabbix 4.0 LTS 详细了解优化及新增功能参考如下: 新增功能\[:https://www.zabbix.com/whats\_new\] 官方文档:\[https://www.zabbix.com/documentation/4.0/manual\]
## 2、Grafana
> grafana 是一款采用 go 语言编写的开源应用,主要用于大规模指标数据的可视化展现,是网络架构和应用分析中最流行的**时序数据展示**工具,目前已经支持绝大部分常用的时序数据库。最好的参考资料就是官网[https://grafana.com/docs/](https://grafana.com/docs/)
Grafana 详细了解优化及新增功能参考如下: 新增功能:[https://grafana.com/docs/](https://grafana.com/docs/)
## 3、部署环境准备
* 操作系统: CentOS Linux release 7.2..1511 (Core)
* zabbix版本: zabbix-release-4.0-1.el7.noarch.rpm
* 数据库: 5.5.60-MariaDB MariaDB Server
* grafana版本: grafana-6.2.5-1.x86_64.rpm
# 二、安装及配置 Zabbix server
## 1\. 配置YUM源
```
mkdir /app/tools -p && cd /app/tools
rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
```
## 2\. 安装Zabbix server, frontend, agent
```
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
```
## 3\. mariadb安装及配置数据库
centos自7版本后开始自带的Mariadb而不是MySQL,所以直接yum安装mariadb
```
yum -y install mariadb-server mariadb
```
启动mysql并设置开机启动,创建数据库,授权zabbix用户
```
systemctl enable mariadb
systemctl start mariadb
mysql -uroot -p
password #默认为空密码
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
mysql> quit;
```
## 4.将zabbix数据表导入数据库中
```
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
```
## 5.配置数据库zabbix server
```
vim /etc/zabbix/zabbix_server.conf
新增
DBPassword=zabbix
```
## 6.编辑Zabbix前端PHP配置,更改时区
```
vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
```
## 7.启动zabbix-server zabbix-agent httpd 并设置开机启动
```
systemctl enable zabbix-server zabbix-agent httpd
systemctl restart zabbix-server zabbix-agent httpd
```
[http://172.16.8.69/zabbix/setup.php](http://172.16.8.69/zabbix/setup.php)
![](https://s1.51cto.com/images/blog/201810/20/b5515070bd9ccddae4dd234a5f435ecb.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![](https://s1.51cto.com/images/blog/201810/20/df15cd8b4307f63dad82a4cdc05d3276.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![](https://s1.51cto.com/images/blog/201810/20/28cab6abeb6cca76a95dede1d4503f34.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![](https://s1.51cto.com/images/blog/201810/20/c44a056f723b1e01bd412d7475968abe.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![](https://s1.51cto.com/images/blog/201810/20/0611276633876a8e5d7c080f264cd076.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![](https://s1.51cto.com/images/blog/201810/20/5905d026cdaba7dcbba26e33a85df8b0.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
登陆,默认用户名**Admin**,密码zabbix
![](https://s1.51cto.com/images/blog/201810/20/5613f2a5743b5041ed02d50c629b0da8.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![](https://s1.51cto.com/images/blog/201810/20/bee985e8b47226cdffbb0d57e31e7705.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
## 8.中文显示乱码的问题
![](https://s1.51cto.com/images/blog/201810/20/cb1792fad803e22005244be0f9a2d549.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
将WIN10操作系统的华文细黑字体STXIHEI.TTF,C:\\Windows\\Fonts拷贝到/usr/share/zabbix/fonts(/usr/share/zabbix/assets/fonts/)目录下
```
mv STXIHEI.TTF stxihei.ttf
```
修改配置文件defines.inc.php
```
vim /usr/share/zabbix/include/defines.inc.php
#修改第70行 70 define('ZBX\_GRAPH\_FONT\_NAME', 'stxihei');
#修改第111行 111 define('ZBX\_FONT\_NAME', 'stxihei');
```
![](https://s1.51cto.com/images/blog/201810/20/9cd3e8a3d4fb5137cec87998f701ae3f.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
# 三、grafana5.3安装及配置
## 1.下载安装RPM包
```
wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.3.0-1.x86_64.rpm
```
## 2.安装grafana
```
yum -y install fontconfig freetype* urw-fonts
rpm -ivh grafana-5.3.0-1.x86_64.rpm
```
## 3.启动grafana并设置开机启动
```
systemctl enable grafana-server.service
systemctl start grafana-server.service
```
## 4.安装grafana-zabbix插件
![](https://s1.51cto.com/images/blog/201810/20/10603e871513e765f93d81a36d17cb52.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
```
grafana-cli plugins install alexanderzobnin-zabbix-app
```
## 5、安装完grafana-zabbix插件必须重新启动
```
systemctl restart grafana-server.service
```
## 6、默认登录地址ip:3000,账号admin,密码admin
## 7、Zabbix的API地址为
> 设置数据来自来自zabbix,Configuration/Data Sources
![](https://i.loli.net/2019/09/17/qMdAULOKBrhNbzT.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
填写
URL:[http://ip/zabbix/api\_jsonrpc.php](http://ip/zabbix/api_jsonrpc.php)
Username:Admin
Password:zabbix
点击【Save & Test】
成功会显示
Zabbix API version: 4.0.11
点击Dashboard>>Choose Visualization>>Add Panel>>Graph>>Edit
把数据源选成指定的zabbix监控主机