prometheus + grafana 安裝 監控 redis mysql mongodb Linux服務器

prometheus:

              Prometheus是一個開源的系統監控和報警的工具包,最初由SoundCloud發佈。         node

組件介紹:mysql

1 Prometheus 主程序,主要是負責存儲、抓取、聚合、查詢方面。
2 Alertmanager 程序,主要是負責實現報警功能。 3 Pushgateway 程序,主要是實現接收由Client push過來的指標數據,在指定的時間間隔,由主程序來抓取。 4 *_exporter 這類是不一樣系統已經實現了的集成。

 

下載地址:linux

1 軟件下在地址 https://github.com/prometheus/prometheus/releases/download/v2.17.1/prometheus-2.17.1.linux-amd64.tar.gz
2 報警插件下載地址  https://github.com/prometheus/alertmanager/releases/download/v0.20.0/alertmanager-0.20.0.linux-amd64.tar.gz
3 mysql監控客戶端下載地址 https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz
4 Linux服務器客戶端下載地址 https://github.com/prometheus/node_exporter/releases/download/v1.0.0-rc.0/node_exporter-1.0.0-rc.0.linux-amd64.tar.gz
5 模板下載地址 https://grafana.com/grafana/dashboards?dataSource=influxdb&orderBy=name&direction=asc

 

prometheus部署:

下載解壓:git

1 wget https://github.com/prometheus/prometheus/releases/download/v2.17.1/prometheus-2.17.1.linux-amd64.tar.gz
2 wget
https://github.com/prometheus/node_exporter/releases/download/v1.0.0-rc.0/node_exporter-1.0.0-rc.0.linux-amd64.tar.gz
3 tar -xvzf prometheus-2.17.1.linux-amd64.tar.gz
4 tar -xvzf node_exporter-1.0.0-rc.0.linux-amd64.tar.gz
5 cd prometheus-2.17.1.linux-amd64
6 mkdir Linux Redis Mysql Mongodb

添加修改prometheus配置文件:github

static_configs:
- targets: ['本機IP:9090']redis

- job_name: 'Linux' file_sd_configs: - files: ['/usr/local/src/prometheus-2.17.0.linux-amd64/Linux/Linux.yml'] refresh_interval: 5s - job_name: 'MysqlLinux' file_sd_configs: - files: ['/usr/local/src/prometheus-2.17.0.linux-amd64/Linux/MysqlLinux.yml'] refresh_interval: 5s - job_name: 'RedislLinux' file_sd_configs: - files: ['/usr/local/src/prometheus-2.17.0.linux-amd64/Linux/RedisLinux.yml'] refresh_interval: 5s - job_name: 'MongodbLinux' file_sd_configs: - files: ['/usr/local/src/prometheus-2.17.0.linux-amd64/Linux/MongodbLinux.yml'] refresh_interval: 5s - job_name: 'Mysql' file_sd_configs: - files: ['/usr/local/src/prometheus-2.17.0.linux-amd64/Mysql/Mysql.yml'] refresh_interval: 5s - job_name: 'Redis' file_sd_configs: - files: ['/usr/local/src/prometheus-2.17.0.linux-amd64/Redis/Redis.yml'] refresh_interval: 5s

編寫子配置文件,每一個監控客戶端的端口都不一樣:sql

vim Linux/Linux.yml - targets: ['監控主機IP:9100'] labels: name: Linux

啓動prometheusmongodb

nohup ./prometheus --config.file=prometheus.yml &

啓動node_exportervim

nohup ./node_exporter >>/dev/null &

登陸 http://prometheus:9090/targets 能夠查看到監控主機是否正常

說明:

     node_exporter 爲prometheus 數據採集器,須要部署到要監控的服務器上面,部署好後,在prometheus 對應的子配置文件裏添加服務對應的地址和端口服務器

- targets: ['監控主機IP:9100'] labels: name: Linux

 

 

grafana部署

               官網下載地址 http://docs.grafana.org/installation/rpm/

#下載軟件
wget https://dl.grafana.com/oss/release/grafana-6.7.1-1.x86_64.rpm #如今軟件依賴包 yum install initscripts fontconfig urw-fonts -y #安裝grafana軟件 yum install grafana-6.7.1-1.x86_64.rpm -y
#啓動服務
systemctl start grafana-server.service

      grafana 默認啓動3000端口 ,訪問 http://IP:3000  默認帳號、密碼admin/admin

1.登陸grafang系統

 

 2.配置Prometheus 和 Grafana 鏈接 添加數據源

 

 選擇prometheus

 

 

 填寫prometheus對應IP地址和端口保存 

 導入Linux監控模板

 

 

 選擇下載好的模板

 

 

 導入模板:

 

 

 查看Linux監控:

 

 

 

 

 

 mysql監控部署:

           在須要監控的mysql上安裝 node_exporter和 mysqld_exporter

tar -xvf node_exporter-0.14.0.linux-amd64.tar.gz cd node_exporter-0.14.0.linux-amd64 nohup ./node_exporter & tar -xvf mysqld_exporter-0.10.0.linux-amd64.tar.gz cd mysqld_exporter-0.10.0.linux-amd64 vi .my.cnf [client] user=root password=root
nohup./mysqld_exporter -config.my-cnf=".my.cnf" &

添加服務器配置:

1 vim Linux/MysqlLinux.yml 2 - targets: ['監控主機IP:9100'] 3  labels: 4     name: Linux
1 vim Mysql/Mysql.yml 2 - targets: ['mysqIP:9104'] 3   labels: 4     name: Mysql

導入對應的mysql模板

 

 redis監控部署:

         在須要監控的mysql上安裝 node_exporter和 redis_exporter

1 tar -xvf redis_exporter-v0.11.linux-amd64.tar.gz 2 nohup /opt/redis_exporter -redis.addr  redis://IP地址:16379 -redis.password 密碼 &

添加服務器配置:

vim Linux/RedisLinux.yml - targets: ['監控主機IP:9100'] labels: name: Linux
vim Redis/Redis.yml - targets: ['RedisIP:端口'] labels: name: Redis

 mongodb監控部署:

   更新中.....................

相關文章
相關標籤/搜索