0. 概述

作为一款流行的监控软件,grafana 具有丰富的图形展示功能,本文将介绍一下如何安装和设置 Grafana

1. 设置 repo

[[email protected]]# cat /etc/yum.repos.d/grafana.repo
[grafana]
name=grafana
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt

2. 安装 grafana

[[email protected]]# yum install -y grafana

3. 配置 grafana

[[email protected]]# cat /etc/grafana/grafana.ini
[server]
protocol = http
http_addr = 127.0.0.1
http_port = 3000
domain = grafana.liqiang.io
enforce_domain = true
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana
[[email protected]]# cat /etc/nginx/default.d/grafana.conf 
location /grafana {
        proxy_pass              http://127.0.0.1:3000;
        rewrite  ^/grafana/(.*)  /$1 break;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        Host $host;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_http_version      1.1;
        proxy_set_header        Upgrade $http_upgrade;
        proxy_set_header        Connection "upgrade";
        proxy_redirect          off;
}

4. 运行 grafana

[[email protected]]# systemctl enable grafana-server.service
[[email protected]]# systemctl start grafana-server.service
[[email protected]]# nginx -s reload

5. 访问 grafana

打开浏览器:http://grafana.liqiang.io,然后就看到这个界面了:

图 1:Grafana 登陆界面

grafana 的默认帐号密码是:

6. Ref