Grafana可视化工具介绍

Grafana是一款可视化工具,大多使用在时序数据的监控方面,如同Kibana类似。Grafana的UI更加灵活,有丰富的插件,功能强大。我们在使用ClickHouse时,可以结合Grafana来监控集群状态,生成报表等。

1、Grafana软件安装

Grafana支持多种操作系统安装

Ubuntu & Debian(64 Bit)

wget https://dl.grafana.com/oss/release/grafana_6.0.1_amd64.deb 
sudo dpkg -i grafana_6.0.1_amd64.deb 


Redhat & Centos(64 Bit)

wget https://dl.grafana.com/oss/release/grafana-6.0.1-1.x86_64.rpm 
sudo yum localinstall grafana-6.0.1-1.x86_64.rpm 


Standalone Linux Binaries(64 Bit)

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


为了方便,直接使用编译好的安装包安装,环境为Centos(64 Bit)

grafana-6.0.1.linux-amd64.tar.gz


解压到指定目录/data/grafana-6.0.1

-rw-r--r--  1 root root  108 Oct 24 20:09 NOTICE.md
-rw-r--r--  1 root root  12K Oct 24 20:09 LICENSE.md
-rw-r--r--  1 root root 4.6K Oct 24 20:09 README.md
-rw-r--r--  1 root root    5 Oct 24 20:17 VERSION
drwxr-xr-x 12 root root 4.0K Oct 24 20:17 public
drwxr-xr-x  3 root root 4.0K Oct 24 20:17 tools
drwxr-xr-x  5 root root 4.0K Oct 24 20:17 scripts
drwxr-xr-x  6 root root 4.0K Nov  2 17:27 data
drwxr-xr-x  2 root root 4.0K Jan  8 10:03 bin
drwxr-xr-x  3 root root 4.0K Mar  7 11:48 conf


配置文件/data/grafana-6.0.1/conf/defaults.ini基本不用修改,如果使用mysql数据库,需要修改database部分,提前装好mysql并创建库和用户

[database]
type = mysql
host = 1.1.1.1:3358
name = grafana
user = grafana_user
password =grafana_passwd
url =mysql://grafana_user:[email protected]:3358/grafana
max_idle_conn = 2
max_open_conn =
conn_max_lifetime = 14400
log_queries =
ssl_mode = disable
ca_cert_path =
client_key_path =
client_cert_path =
server_cert_name =
path = grafana.db


参见官方说明http://docs.grafana.org/installation/configuration/

2、Grafana Server 启动

/data/grafana-6.0.1/bin/grafana-server start &
INFO[03-08|15:51:12] Starting Grafana                         logger=server version=6.0.1 commit=0c44a04 branch=HEAD compiled=2019-03-06T22:21:49+0800
INFO[03-08|15:51:12] Config loaded from                       logger=settings file=/data/grafana-6.0.1/conf/defaults.ini
INFO[03-08|15:51:12] Path Home                                logger=settings path=/data/grafana-6.0.1
INFO[03-08|15:51:12] Path Data                                logger=settings path=/data/grafana-6.0.1/data
INFO[03-08|15:51:12] Path Logs                                logger=settings path=/data/grafana-6.0.1/data/log
INFO[03-08|15:51:12] Path Plugins                             logger=settings path=/data/grafana-6.0.1/data/plugins
INFO[03-08|15:51:12] Path Provisioning                        logger=settings path=/data/grafana-6.0.1/conf/provisioning
INFO[03-08|15:51:12] Initializing ProvisioningService         logger=server
INFO[03-08|15:51:12] Initializing TracingService              logger=server
INFO[03-08|15:51:12] Initializing Stream Manager 
INFO[03-08|15:51:12] HTTP Server Listen                       logger=http.server address=0.0.0.0:3000 protocol=http subUrl= socket=


启动后,我们就可以http://localhost:3000访问页面了,如果想通过域名访问,我们可以安装nginx做代理。

3、安装nginx

下载安装包,这里只是简单安装,并没有做高可用

wget http://distfiles.macports.org/nginx/nginx-1.15.9.tar.gz
tar -xvf nginx-1.15.9.tar.gz
cd nginx-1.15.9
./configure --prefix=/usr/local/nginx 

 

drwxr-xr-x  2 root   root 4.0K Oct 26 20:57 sbin
drwx------  2 nobody root 4.0K Oct 26 20:59 uwsgi_temp
drwx------  2 nobody root 4.0K Oct 26 20:59 scgi_temp
drwx------  2 nobody root 4.0K Oct 26 20:59 fastcgi_temp
drwx------ 12 nobody root 4.0K Oct 29 11:25 proxy_temp
drwxr-xr-x  2 root   root 4.0K Oct 31 19:43 logs
drwxr-xr-x  2 root   root 4.0K Jan  8 13:35 html
drwxr-xr-x  2 root   root 4.0K Mar  7 11:46 conf
drwx------  2 nobody root 4.0K Mar  8 14:31 client_body_temp

修改配置文件vi /usr/local/nginx/conf/nginx.conf

gzip  on;
upstream learnmysql.com {
server 127.0.0.1:3000  weight=10 max_fails=2 fail_timeout=30s ;
}
server {
listen       80;
server_name  localhost grafana.learnmysql.com;
location / {
proxy_next_upstream     http_500 http_502 http_503 http_504 error timeout invalid_header;
proxy_set_header        Host  $host;
proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass              http://learnmysql.com;
expires                 0;
    }
error_page   500 502 503 504  /50x.html;
location = /50x.html {
root   html;
    }
}


测试配置文件是否正确

/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf


启动nginx

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf


停止nginx

/usr/local/nginx/sbin/nginx -s stop


访问页面 http://grafana.learnmysql.com

4、玩转Grafana

配置项说明

Data Source 数据源
Users 用户
Teams 用户组
Plugins 插件
Preference 自定义设置
API 接口

1. 添加数据源

选择数据源类型

配置数据源信息

2. 添加用户

由于没有配置邮件服务器,需要手动激活后就可以登录了

3. 添加用户组

4.添加插件

5. 添加仪表板

6. 添加格式

7. 页面展示

更多功能,可直接查看官网:http://docs.grafana.org/
————————————————
版权声明:本文为CSDN博主「MYSQL轻松学」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/liang_0609/article/details/88803261

你可能感兴趣的:(clickhouse列式数据库)