Prometheus+Grafana部署配置
Prometheus安裝
下載Prometheus服務端
Download | PrometheusAn open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.https://prometheus.io/download/
上傳至服務器,解壓
tar -zxvf prometheus-3.0.1.linux-amd64.tar.gz
cd prometheus-3.0.1.linux-amd64
運行
./prometheus --config.file="prometheus.yml"
后臺運行
nohup?./prometheus --config.file=prometheus.yml &
當首次訪問9090端口時,時間序列數據的洪流如同宇宙背景輻射般撲面而來。
Grafana安裝
Grafana是一個可視化面板(Dashboard),有著非常漂亮的圖表和布局展示,功能齊全的度量儀表盤和圖形編輯器,支持Graphite、zabbix、InfluxDB、Prometheus
下載地址:Download Grafana | Grafana LabsOverview of how to download and install different versions of Grafana on different operating systems.https://grafana.com/grafana/download
yum localinstall -y grafana-6.5.0-1.x86_64.rpm
systemctl start grafana-server
訪問頁面http://服務器IP:3000 ,默認賬號、密碼admin/admin
Prometheus被監控端安裝插件
下載插件(此處下載一個node 和 mysql插件)
Download | PrometheusAn open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.https://prometheus.io/download/
在被監控端主機解壓這兩個文件
tar -zxvf node_exporter-1.8.2.linux-amd64.tar.gz?
???????????
node_exporter插件可直接運行cd node_exporter-1.8.2.linux-amd64
node_exporter插件可直接運行
cd node_exporter-1.8.2.linux-amd64
nohup ./node_exporter &
mysqld_exporter需要連接到MySQL,需要授權
mysqld_exporter插件需要創建一個用戶+密碼的文件
tar -zxvf mysqld_exporter-0.16.0.linux-amd64.tar.gz
cd mysqld_exporter-0.16.0.linux-amd64
mysql> use mysql;mysql> create user dbuser;
mysql> GRANT REPLICATION CLIENT, PROCESS ON *.* TO 'dbuser'@'localhost' identified by '123456';
mysql> GRANT SELECT ON performance_schema.* TO 'dbuser'@'localhost';
創建 .my.cnf 加入以下內容
[client]user=dbuserpassword=123456
啟動mysqld_exporter
nohup ./mysqld_exporter --config.my-cnf=.my.cnf &
Prometheus服務端添加被監控端
cd prometheus-3.0.1.linux-amd64
vi prometheus.yml? 加入- job_name: system-statusstatic_configs:- targets: ['192.168.126.50:9100']labels:instance: 7-7- job_name: mysql-statusstatic_configs:- targets: ['192.168.126.40:9104']labels:instance: 7-7-mysql
?訪問Prometheus?? http://192.168.126.30:9090/targets
Grafana對接Prometheus
添加源數據
添加成功
Grafana添加圖表
自帶dashboard
下載地址
Grafana dashboards | Grafana LabsBrowse a library of official and community-built dashboards.https://grafana.com/grafana/dashboards
導入