普拉多VX

人生一路,不问来时,不知归期

0%

Grafana 7.0 安装文档记录

grafana介绍

Grafana是一个通用的可视化工具并且开源跨平台,可以通过将采集的数据查询后作数据可视化展示。grafana使用go开发也是目前最流行的架构和监控分析的数据可视化工具,并且支持非常多的数据源。
它目前已经更新到第7版本了。

参考grafana官网文档:https://grafana.com/docs/
预览grafana: https://play.grafana.org/
github: https://github.com/grafana/grafana

特点

  • 开源版/企业版
  • 动态仪表盘
  • 多数据源
  • 警告通知
  • 注释
  • 过滤器
  • 多插件
  • 可视化

下载安装

下载网站:https://grafana.com/grafana/download

Ubuntu and Debian

1
2
3
sudo apt-get install -y adduser libfontconfig1
wget https://dl.grafana.com/oss/release/grafana_7.2.0_amd64.deb
sudo dpkg -i grafana_7.2.0_amd64.deb

Centos/RHEL/Red Hat

1
2
wget https://dl.grafana.com/oss/release/grafana-7.2.0-1.x86_64.rpm
sudo yum install grafana-7.2.0-1.x86_64.rpm

OpenSUSE and SUSE

1
2
wget https://dl.grafana.com/oss/release/grafana-7.2.0-1.x86_64.rpm
sudo rpm -i --nodeps grafana-7.2.0-1.x86_64.rpm

源码安装

1
2
wget https://dl.grafana.com/oss/release/grafana-7.2.0.linux-amd64.tar.gz
tar -zxvf grafana-7.2.0.linux-amd64.tar.gz

文件配置

1
2
3
4
5
6
7
8
/usr/sbin/grafana-server   #二进制文件位置
/etc/grafana/grafana.ini #配置文件
/var/run/grafana/grafana-server.pid #默认pid文件
/etc/init.d/grafana-server #启动脚本
/etc/sysconfig/grafana-server #默认环境变量
/var/log/grafana/grafana.log #日志文件
/var/lib/grafana/grafana.db #默认指定的sqlite3数据库
/var/lib/grafana/plugins #插件目录

运行

以下在centos 7下运行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[root@iZ2zecgq3cou36re3sxh4bZ ~]# systemctl start grafana-server #启动服务
[root@iZ2zecgq3cou36re3sxh4bZ ~]# systemctl status grafana-server
● grafana-server.service - Grafana instance
Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; disabled; vendor preset: disabled)
Active: active (running) since Sun 2020-09-27 15:35:18 CST; 7s ago
Docs: http://docs.grafana.org
Main PID: 19491 (grafana-server)
CGroup: /system.slice/grafana-server.service
└─19491 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-server.pid --packaging=rpm cfg:default.paths.logs...

Sep 27 15:35:18 iZ2zecgq3cou36re3sxh4bZ grafana-server[19491]: t=2020-09-27T15:35:18+0800 lvl=info msg="Executing migration" logger=migrator id="add uniqu...h_token"
Sep 27 15:35:18 iZ2zecgq3cou36re3sxh4bZ grafana-server[19491]: t=2020-09-27T15:35:18+0800 lvl=info msg="Executing migration" logger=migrator id="add uniqu...h_token"
Sep 27 15:35:18 iZ2zecgq3cou36re3sxh4bZ grafana-server[19491]: t=2020-09-27T15:35:18+0800 lvl=info msg="Executing migration" logger=migrator id="create ca...a table"
Sep 27 15:35:18 iZ2zecgq3cou36re3sxh4bZ grafana-server[19491]: t=2020-09-27T15:35:18+0800 lvl=info msg="Executing migration" logger=migrator id="add uniqu...che_key"
Sep 27 15:35:18 iZ2zecgq3cou36re3sxh4bZ grafana-server[19491]: t=2020-09-27T15:35:18+0800 lvl=info msg="Created default admin" logger=sqlstore user=admin
Sep 27 15:35:18 iZ2zecgq3cou36re3sxh4bZ grafana-server[19491]: t=2020-09-27T15:35:18+0800 lvl=info msg="Starting plugin search" logger=plugins
Sep 27 15:35:18 iZ2zecgq3cou36re3sxh4bZ grafana-server[19491]: t=2020-09-27T15:35:18+0800 lvl=info msg="Registering plugin" logger=plugins name="Direct Input"
Sep 27 15:35:18 iZ2zecgq3cou36re3sxh4bZ grafana-server[19491]: t=2020-09-27T15:35:18+0800 lvl=info msg="External plugins directory created" logger=plugins.../plugins
Sep 27 15:35:18 iZ2zecgq3cou36re3sxh4bZ systemd[1]: Started Grafana instance.
Sep 27 15:35:18 iZ2zecgq3cou36re3sxh4bZ grafana-server[19491]: t=2020-09-27T15:35:18+0800 lvl=info msg="HTTP Server Listen" logger=http.server address=[::... socket=
Hint: Some lines were ellipsized, use -l to show in full.
[root@iZ2zecgq3cou36re3sxh4bZ ~]#
[root@iZ2zecgq3cou36re3sxh4bZ ~]# systemctl enable grafana-server # 开机启动
Created symlink from /etc/systemd/system/multi-user.target.wants/grafana-server.service to /usr/lib/systemd/system/grafana-server.service.
[root@iZ2zecgq3cou36re3sxh4bZ ~]#

默认启动端口3000

1
2
3
[root@iZ2zecgq3cou36re3sxh4bZ ~]# netstat -nlpt | grep grafana
tcp6 0 0 :::3000 :::* LISTEN 19491/grafana-serve
[root@iZ2zecgq3cou36re3sxh4bZ ~]#

访问http://ip:3000端口,输入默认用户密码admin/admin

第一次登陆后需要修改密码

登录成功

插件安装

插件安装工具 grafana-cli

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@iZ2zecgq3cou36re3sxh4bZ ~]# grafana-cli plugins
NAME:
Grafana CLI plugins - Manage plugins for grafana

USAGE:
Grafana CLI plugins command [command options] [arguments...]

COMMANDS:
install install <plugin id> <plugin version (optional)> # 安装插件
list-remote list remote available plugins #列出插件
list-versions list-versions <plugin id> # 列出插件版本
update, upgrade update <plugin id> #更新插件
update-all, upgrade-all update all your installed plugins # 更新所有已安装的插件
ls list all installed plugins # 列出已安装的插件
uninstall, remove uninstall <plugin id> #卸载插件
help, h Shows a list of commands or help for one command #帮助信息

OPTIONS:
--help, -h show help (default: false)
--version, -v print the version (default: false)

列出可用插件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@iZ2zecgq3cou36re3sxh4bZ ~]# grafana-cli plugins list-remote
id: abhisant-druid-datasource version: 0.0.5
id: aceiot-svg-panel version: 0.0.8
id: agenty-flowcharting-panel version: 0.9.0
id: aidanmountford-html-panel version: 0.0.1
id: akumuli-datasource version: 1.3.11
id: alexanderzobnin-zabbix-app version: 4.0.1
id: alexandra-trackmap-panel version: 1.2.5
id: andig-darksky-datasource version: 1.0.1
id: aquaqanalytics-kdbadaptor-datasource version: 1.0.1
id: ayoungprogrammer-finance-datasource version: 1.0.0
id: belugacdn-app version: 1.2.0
id: bessler-pictureit-panel version: 1.0.0
id: blackmirror1-singlestat-math-panel version: 1.1.7
id: blackmirror1-statusbygroup-panel version: 1.1.1

查看插件

在configuration->plugins

更多插件安装
https://grafana.com/grafana/plugins?utm_source=grafana_plugin_list

安装插件

选择一个插件,点击install,可以在预览里看到插件的效果

安装方式

1
2
3
4
5
6
7
8
9
10
[root@iZ2zecgq3cou36re3sxh4bZ ~]# grafana-cli plugins install grafana-clock-panel
installing grafana-clock-panel @ 1.1.1
from: https://grafana.com/api/plugins/grafana-clock-panel/versions/1.1.1/download
into: /var/lib/grafana/plugins

✔ Installed grafana-clock-panel successfully

Restart grafana after installing plugins . <service grafana-server restart>

[root@iZ2zecgq3cou36re3sxh4bZ ~]#

重启后查看安装的插件

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@iZ2zecgq3cou36re3sxh4bZ ~]# service grafana-server restart
Restarting grafana-server (via systemctl): [ OK ]
[root@iZ2zecgq3cou36re3sxh4bZ ~]# grafana-cli plugins ls
installed plugins:
grafana-clock-panel @ 1.1.1

Restart grafana after installing plugins . <service grafana-server restart>

[root@iZ2zecgq3cou36re3sxh4bZ ~]#
[root@iZ2zecgq3cou36re3sxh4bZ ~]# ll /var/lib/grafana/plugins/ #查看插件安装目录
total 4
drwxr-xr-x 5 root root 4096 Sep 27 16:13 grafana-clock-panel
[root@iZ2zecgq3cou36re3sxh4bZ ~]#

退出

参考