安装部署 Grafana
0. 概述
作为一款流行的监控软件,grafana 具有丰富的图形展示功能,本文将介绍一下如何安装和设置 Grafana
1. 设置 repo
# 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
# yum install -y grafana nginx
3. 配置 grafana
# cat /etc/grafana/grafana.ini
[server]
protocol = http
http_addr = 127.0.0.1
http_port = 3000
domain = grafana.evescn.com
enforce_domain = true
root_url = %(protocol)s://%(domain)s:/grafana
......
[smtp]
enabled = true
host = smtp.163.com:25
user = xxxxxxxxxx@163.com
password = password
skip_verify = true
from_address = xxxxxxxxxx@163.com
from_name = Grafana
# cat /etc/nginx/nginx.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
# systemctl enable grafana-server.service
# systemctl start grafana-server.service
5. 运行nginx
# systemctl enable nginx
# systemctl start nginx
6. 访问 grafana
- grafana的默认帐号密码是
用户名:admin
密码:admin
转载文档
https://liqiang.io/post/install-and-deploy-grafana-cf9a5130
docker安装部署 Grafana
1.安装docker环境
自行搜索何如安装docker
2.运行grafana容器
docker run -d --name=grafana -p 3000:3000 grafana/grafana:6.7.1
直接运行容器,会导致每次删除容器后,数据丢失,密码恢复默认值,需要对grafana容器数据进行外挂和配置修改
3.修改grafana默认密码
配置文件grafana.ini中的选项可以使用语法使用环境变量进行覆盖,格式:
GF_<SectionName>_<KeyName>。
修改密码
docker run
-d --name grafana -p 3000:3000
-e "GF_SERVER_ROOT_URL=http://grafana.evescn.com"
-e "GF_SECURITY_ADMIN_PASSWORD=123456"
grafana/grafana:6.7.1 grafana
- 说明
- 设置服务的默认域名 :-e "GF_SERVER_ROOT_URL=http://grafana.evescn.com"
- 设置admin的密码为newpwd : -e "GF_SECURITY_ADMIN_PASSWORD=123456"
- 更多详细配置
https://grafana.com/docs/grafana/latest/installation/configuration/
4.外挂服务配置文件
docker run
-d --name grafana -p 3000:3000
-e "GF_SERVER_ROOT_URL=http://grafana.evescn.com"
-e "GF_SECURITY_ADMIN_PASSWORD=123456"
--volume "/opt/grafana/data:/var/lib/grafana"
grafana/grafana:6.7.1 grafana
5.编写shell脚本重启grafana
vim restart_granfana.sh
#!/bin/bash
basedir=$(cd `dirname $0`;pwd)
mkdir -p /opt/grafana/data # creates a folder for your data
ID=$(id -u) # saves your user id in the ID variable
docker stop grafana
docker rm grafana
docker run
-d --name grafana -p 3000:3000
-e "GF_SERVER_ROOT_URL=http://grafana.evescn.com"
-e "GF_SECURITY_ADMIN_PASSWORD=123456"
--user $ID --volume "/opt/grafana/data:/var/lib/grafana"
grafana/grafana:6.7.1 grafana
转载文档
https://www.jianshu.com/p/fc6a85d830ab