Grafana部署

Grafana介绍

官方文档:https://grafana.com/docs/

Grafana是一款基于go语音开发的通用可视化工具,支持从多种不同的数据源加载并展示数据,可作为其数据源的部分存储系统如下所示:

  • TSDB:Prometheus、IfluxDB、OpenTSDB和Graphit
  • 日志和文档存储:Loki和ElasticchSearch
  • 分布式请求跟踪:Zipkin、Jaeger和Tempo
  • SQL DB:mysql、PostgreSQL

Grafana基础

  • 默认监听于TCP协议的3000端口,支持集成其它认证服务,且能够通过/metrics输出内建指标;
  • 几个基本概念:
    • 数据源(Data Source):提供用于展示的数据的存储系统
    • 仪表盘(Dashboard):组织和管理数据的可视化面板(Panel)
    • 团队和用户:提供了面向企业组织层级的管理能力
  • 默认账号密码:admin/admim

部署Grafana

官方部署文档:https://grafana.com/docs/grafana/latest/installation/?pg=docs

Grafana下载地址:https://grafana.com/grafana/download

ubuntu安装Grafana

root@k8s-deploy:~# apt-get install -y adduser libfontconfig1
root@k8s-deploy:~# wget https://dl.grafana.com/oss/release/grafana_8.2.4_amd64.deb
root@k8s-deploy:~# dpkg -i grafana_8.2.4_amd64.deb

centos 安装Grafana

yum install -y https://dl.grafana.com/oss/release/grafana-10.1.2-1.x86_64.rpm

查看Grafana配置文件

root@k8s-deploy:~# ls -l /etc/grafana/
total 52
-rw-r----- 1 root grafana 42837 Nov 16 23:37 grafana.ini
-rw-r----- 1 root grafana  2270 Nov 16 23:37 ldap.toml
drwxr-xr-x 7 root grafana  4096 Nov 16 23:37 provisioning

设置开启启动

root@k8s-deploy:~# systemctl enable grafana-server
Synchronizing state of grafana-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable grafana-server
Created symlink /etc/systemd/system/multi-user.target.wants/grafana-server.service → /lib/systemd/system/grafana-server.service.
root@k8s-deploy:~# systemctl start grafana-server
root@k8s-deploy:~# systemctl status grafana-server
● grafana-server.service - Grafana instance
     Loaded: loaded (/lib/systemd/system/grafana-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-11-16 23:38:12 CST; 12s ago
       Docs: http://docs.grafana.org
   Main PID: 2369 (grafana-server)
      Tasks: 9 (limit: 2245)
     Memory: 29.4M
     CGroup: /system.slice/grafana-server.service
             └─2369 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/run/grafana/grafana-server.pid -->

Nov 16 23:38:13 k8s-deploy grafana-server[2369]: t=2021-11-16T23:38:13+0800 lvl=info msg="Executing migration" logger=migra>
Nov 16 23:38:13 k8s-deploy grafana-server[2369]: t=2021-11-16T23:38:13+0800 lvl=info msg="migrations completed" logger=migr>
Nov 16 23:38:13 k8s-deploy grafana-server[2369]: t=2021-11-16T23:38:13+0800 lvl=info msg="Created default admin" logger=sql>
Nov 16 23:38:13 k8s-deploy grafana-server[2369]: t=2021-11-16T23:38:13+0800 lvl=info msg="Created default organization" log>
Nov 16 23:38:13 k8s-deploy grafana-server[2369]: t=2021-11-16T23:38:13+0800 lvl=info msg="Starting plugin search" logger=pl>
Nov 16 23:38:13 k8s-deploy grafana-server[2369]: t=2021-11-16T23:38:13+0800 lvl=info msg="Registering plugin" logger=plugin>
Nov 16 23:38:13 k8s-deploy grafana-server[2369]: t=2021-11-16T23:38:13+0800 lvl=info msg="External plugins directory create>
Nov 16 23:38:14 k8s-deploy grafana-server[2369]: t=2021-11-16T23:38:14+0800 lvl=info msg="Live Push Gateway initialization">
Nov 16 23:38:14 k8s-deploy grafana-server[2369]: t=2021-11-16T23:38:14+0800 lvl=info msg="Writing PID file" logger=server p>
Nov 16 23:38:14 k8s-deploy grafana-server[2369]: t=2021-11-16T23:38:14+0800 lvl=info msg="HTTP Server Listen" logger=http.s>

登录grafana web界面

默认用户名密码:admin/admin

Grafana插件安装

在线安装

root@k8s-deploy:~# grafana-cli plugins install grafana-piechart-panel

离线安装

root@k8s-deploy:~# wget -nv https://grafana.com/api/plugins/grafana-piechart-panel/versions/latest/download -O /tmp/grafana-piechart-panel.zip
root@k8s-deploy:~# unzip -q /tmp/grafana-piechart-panel.zip -d /tmp
root@k8s-deploy:~# mv /tmp/grafana-piechart-panel-* /var/lib/grafana/plugins/grafana-piechart-panel
root@k8s-deploy:~# systemctl restart grafana-server

Grafana文件路径

  • Installs binary to /usr/sbin/grafana-server
  • Installs Init.d script to /etc/init.d/grafana-server
  • Creates default file (environment vars) to /etc/default/grafana-server
  • Installs configuration file to /etc/grafana/grafana.ini
  • Installs systemd service (if systemd is available) name grafana-server.service
  • The default configuration sets the log file at /var/log/grafana/grafana.log
  • The default configuration specifies a SQLite3 db at /var/lib/grafana/grafana.db
  • Installs HTML/JS/CSS and other Grafana files at /usr/share/grafana
posted @ 2021-11-16 23:42  小吉猫  阅读(552)  评论(0编辑  收藏  举报