0. 概述
作为一款流行的监控软件,grafana 具有丰富的图形展示功能,本文将介绍一下如何安装和设置 Grafana
1. 设置 repo
[root@liqiang.io]# cat >/etc/yum.repos.d/grafana.repo << EOF
[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
EOF
2. 安装 grafana
[root@liqiang.io]# yum install -y grafana nginx
3. 配置 grafana
[root@liqiang.io]# cat >/etc/grafana/grafana.ini <<EOF
[server]
protocol = http
http_addr = 127.0.0.1
http_port = 3000
domain = grafana.liqiang.io
enforce_domain = true
serve_from_sub_path = true
root_url = http://%(domain)s:%(http_port)s/grafana
EOF
[root@liqiang.io]# mkdir -p /etc/nginx/grafana
[root@liqiang.io]# cat> /etc/nginx/grafana/grafana.conf << EOF
location /grafana {
proxy_pass http://127.0.0.1:3000;
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;
}
EOF
[root@liqiang.io]# cat> /etc/nginx/conf.d/grafana.conf << EOF
server {
listen 80;
listen [::]:80;
server_name grafana.liqiang.io;
include /etc/nginx/grafana/*.conf;
}
EOF
4. 运行 grafana
[root@liqiang.io]# systemctl enable grafana-server.service
[root@liqiang.io]# systemctl start grafana-server.service
[root@liqiang.io]# nginx -s reload
5. 访问 grafana
打开浏览器:http://grafana.liqiang.io/grafana,然后就看到这个界面了:
图 1:Grafana 登陆界面 |
---|
grafana 的默认帐号密码是:
- 用户名:admin
- 密码:admin
6. Kubernetes 默认密码
[root@liqiang.io]# kubectl get secret --namespace default my-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo