這篇文章主要講解了“Grafana的安裝與配置教程”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“Grafana的安裝與配置教程”吧!
一: 簡介
Grafana 是一個開源儀表盤工具,它可用于Graphite、InfluxDB與 OpenTSDB 一起使用。最新的版本還可以用于其他的數據源,比如Elasticsearch。
從本質上說,它是一個功能豐富的Graphite-web 替代品,能幫助用戶更簡單地創建和編輯儀表盤。它包含一個獨一無二的Graphite目標解析器,從而可以簡化度量和函數的編輯
二: 安裝與配置
1.安裝
yum install https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.5.2-1.x86_64.rpm
2.開機啟動配置
systemctl daemon-reload
systemctl start grafana-server
systemctl status grafana-server
3.相關文件目錄
Installs binary to /usr/sbin/grafana-server
Copies init.d script to /etc/init.d/grafana-server
Installs default file (environment vars) to /etc/sysconfig/grafana-server
Copies configuration file to /etc/grafana/grafana.ini
Installs systemd service (if systemd is available) name grafana-server.service
The default configuration uses a log file at /var/log/grafana/grafana.log
The default configuration specifies an sqlite3 database at /var/lib/grafana/grafana.db
4.應用頁面 http://ip:3000 用戶名/密碼:admin/admin
三:配置
1.通過rpm安裝,配置信息在/etc/grafana/grafana.ini文件中,通過安裝包安裝配置文件在/usr/share/grafana/conf/目錄下。
通過啟動日志可以看到,會讀取defaults.ini和grafana.ini的配置信息, 因此如果要修改訪問端口(如3000改成3001)需要修改defaults.ini
配置文件中的信息,感覺有點奇怪。
2.dashboards配置
編輯配置文件/etc/grafana/grafana.ini,修改dashboards.json段落下兩個參數的值:
[dashboards.json]
enabled = true
path = /var/lib/grafana/dashboards
一定要去掉開頭的分號(“;”)否則配置不起作用
安裝儀表盤(Percona提供),重新啟動應用
$ git clone https://github.com/percona/grafana-dashboards.git
$ cp -r grafana-dashboards/dashboards /var/lib/grafana/
systemctl restart grafana-server
四:同prometheus一起監控Mysql
1.Prometheus安裝 請參考上一篇博文
2.配置文件
點擊(此處)折疊或打開
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
labels:
instance: prometheus
- job_name: linux
static_configs:
- targets: ['10.10.0.186:9100']
labels:
instance: db1
- job_name: mysql
static_configs:
- targets: ['10.10.0.186:9104']
labels:
instance: db1
3.部署node_exporters和mysqld_exporters
點擊(此處)折疊或打開
$ wget https://github.com/prometheus/node_exporter/releases/download/v0.14.0/node_exporter-0.14.0.linux-amd64.tar.gz -O node_exporter-0.14.0.linux-amd64.tar.gz
$ wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.10.0/mysqld_exporter-0.10.0.linux-amd64.tar.gz -O mysqld_exporter-0.10.0.linux-amd64.tar.gz
$ mkdir /usr/local/services/prometheus_exporters
$ tar zxf node_exporter-0.14.0.linux-amd64.tar.gz -C /usr/local/services/prometheus_exporters --strip-components=1
$ tar zxf mysqld_exporter-0.10.0.linux-amd64.tar.gz -C /usr/local/services/prometheus_exporters --strip-components=1
$ cd /usr/local/services/prometheus_exporters
$ ./node_exporter
$ cd /usr/local/services/prometheus_exporters
$ cat << EOF > .my.cnf
[client]
user=prom
password=abc123
EOF
$ ./mysqld_exporter -config.my-cnf=".my.cnf"
查看Prometheus http://ip:9090
4.Grafana中創建Prometheus數據源
5.服務器監控結果畫面
6.Mysql數據庫監控結果畫面
感謝各位的閱讀,以上就是“Grafana的安裝與配置教程”的內容了,經過本文的學習后,相信大家對Grafana的安裝與配置教程這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。