Msyql、Redis、MongoDB視覺化監控工具Grafana

語言: CN / TW / HK

基於docker安裝mysql、redis的視覺化監控工具

一、安裝Grafana

下載Grafana的Docker映象

[[email protected] ~]# docker pull grafana/grafana

啟動容器

[[email protected] docker]# docker run -p 3000:3000 --name grafana -d grafana/grafana
6a0540849952c4cf0a1d4012ed25410e80d3e14b0bf67108aea95dbc7b7bba9c

二、安裝prom

[[email protected] ~]# docker pull prom/prometheus
[[email protected] ~]# cd /docker/
[[email protected] docker]# mkdir prometheus
[[email protected] docker]# cd prometheus/
[[email protected] prometheus]# vim prometheus.yml

1.在/docker/prometheus下新建prometheus.yml配置檔案,新增以下內容

global:
  scrape_interval: 5s

2.啟動容器,把宿主機中的配置檔案prometheus.yml掛載到容器中去;

[[email protected] prometheus]# docker run -p 3001:3001 --name prometheus -v /docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml -d prom/prometheus
e35ede0a51c4cd85c0ce5f554b44e7f9da11ff9b978443e5f0a33c8c990861f3
[[email protected] prometheus]# docker ps
CONTAINER ID   IMAGE             COMMAND                  CREATED         STATUS         PORTS                                                 NAMES
e35ede0a51c4   prom/prometheus   "/bin/prometheus --c…"   2 seconds ago   Up 2 seconds   0.0.0.0:3001->3001/tcp, :::3001->3001/tcp, 9090/tcp   prometheus
6a0540849952   grafana/grafana   "/run.sh"                2 minutes ago   Up 2 minutes   0.0.0.0:3000->3000/tcp, :::3000->3000/tcp             grafana

三、在grafana安裝redis-datasource外掛

1.進入容器grafana

[[email protected] prometheus]# docker exec -it grafana bash
bash-5.1$ grafana-cli plugins install redis-datasource
✔ Downloaded redis-datasource v2.1.1 zip successfully

Please restart Grafana after installing plugins. Refer to Grafana documentation for instructions if necessary.

bash-5.1$ exit
exit

2.重啟grafana

[[email protected] prometheus]# docker restart grafana
grafana

四、登陸視覺化介面

1.瀏覽器訪問:http://192.168.2.252:3000/

預設賬號密碼admin:admin

登陸後修改原始密碼

2.新增資料來源

可以新增各種資料庫,記得address處填寫ip+埠

配置好後點擊下方【save&test】

3.mysql點選下面【Explore】,可以進行mysql相關的查詢

4.redis點選上面的【Dashboards】,再點選redis一欄後面對應的“import”,可以檢視相關的資料圖表