標籤(空格分隔): greenplum系列node
[toc]linux
Greenplum是面向數據倉庫應用的分佈式關係型MPP數據庫,基於PostgreSQL開發,跟PostgreSQL的兼容性很是好,大部分PostgreSQL客戶端工具及PostgreSQL應用都能運行在Greenplum平臺上。GPCC是Greenplum數據庫官方商業版的數據庫監控軟件,對於只能用得起開源的用戶來講,只能考慮其餘的監控方案了。本文裏介紹一種基於Promethues與Grafana的Greenplum分佈式數據庫監控的實現方案。
Prometheus是由SoundCloud開發的開源監控報警系統和時序列數據庫(TSDB),使用Go語言開發。Prometheus目前在開源社區至關活躍。Prometheus性能也足夠支撐上萬臺規模的集羣。其架構圖以下:
Prometheus Server, 負責從 Exporter 拉取和存儲監控數據,並提供一套靈活的查詢語言(PromQL)供用戶使用。 Exporter, 負責收集目標對象(host, container…)的性能數據,並經過 HTTP 接口供 Prometheus Server 獲取。 可視化組件,監控數據的可視化展示對於監控方案相當重要。之前 Prometheus 本身開發了一套工具,不事後來廢棄了,由於開源社區出現了更爲優秀的產品 Grafana。 Grafana 可以與 Prometheus 無縫集成,提供完美的數據展現能力。 Alertmanager,用戶能夠定義基於監控數據的告警規則,規則會觸發告警。一旦 Alermanager 收到告警,會經過預約義的方式發出告警通知。支持的方式包括 Email、PagerDuty、Webhook 等.
Grafana是一個跨平臺的開源的度量分析和可視化工具,能夠經過將採集的數據查詢而後可視化的展現,並及時通知。它主要有如下六大特色: 一、展現方式:快速靈活的客戶端圖表,面板插件有許多不一樣方式的可視化指標和日誌,官方庫中具備豐富的儀表盤插件,好比熱圖、折線圖、圖表等多種展現方式; 二、數據源:Graphite,InfluxDB,OpenTSDB,Prometheus,Elasticsearch,CloudWatch和KairosDB等; 三、通知提醒:以可視方式定義最重要指標的警報規則,Grafana將不斷計算併發送通知,在數據達到閾值時經過Slack、PagerDuty等得到通知; 四、混合展現:在同一圖表中混合使用不一樣的數據源,能夠基於每一個查詢指定數據源,甚至自定義數據源; 五、註釋:使用來自不一樣數據源的豐富事件註釋圖表,將鼠標懸停在事件上會顯示完整的事件元數據和標記; 六、過濾器:Ad-hoc過濾器容許動態建立新的鍵/值過濾器,這些過濾器會自動應用於使用該數據源的全部查詢。
Greenplum的監控可相似於PostgreSQL來實現,但又存在差別,不一樣點在於: 要實現一個Greenplum的Exporter指標採集器; 使用Grafana繪製一個可視化狀態圖; 基於Prometheus配置報警規則(本文此部分略);
這裏類比PostgreSQL數據庫的Exporter實現方法,實現了一個Greenplum的Exporter,項目地址爲: https://github.com/tangyibo/greenplum_exporter 在greenplum_expoter裏主要擴展了實現了客戶鏈接信息、帳號鏈接信息、Segment存儲信息、集羣節點同步狀態、數據庫鎖監控等相關指標,具體指標以下:
Prometheus自己也是一個導出器(exporter),提供了關於內存使用、垃圾收集以及自身性能 與健康狀態等各類主機級指標。 prometheus官網下載址: https://prometheus.io/download/ wget https://github.com/prometheus/prometheus/releases/download/v2.21.0/prometheus-2.21.0.linux-amd64.tar.gz # tar xf prometheus-2.21.0.linux-amd64.tar.gz # mv prometheus-2.21.0.linux-amd64 /usr/local/prometheus # chmod +x /usr/local/prometheus/prom* # cp -rp /usr/local/prometheus/promtool /usr/bin/
cd /usr/local/prometheus/ vim prometheus.yml ----- # my global config global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s). # Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: # - alertmanager:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: # - "first_rules.yml" # - "second_rules.yml" # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['localhost:9090'] - job_name: 'greenplum' static_configs: - targets: ['192.168.100.11:9297'] labels: app: master01 nodename: node01.flyfish.cn role: master - targets: ['192.168.100.12:9297'] labels: app: node02 nodename: node02.flyfish.cn role: standby - targets: ['192.168.100.13:9297'] labels: app: node03 nodename: node03.flyfish.cn role: node - targets: ['192.168.100.14:9297'] labels: app: node04 nodename: node04.flyfish.cn role: node - targets: ['192.168.100.15:9297'] labels: app: node05 nodename: node05.flyfish.cn role: node -----
啓動: cd /usr/local/prometheus/ ./prometheus --config.file=prometheus.yml &
一、下載安裝包 wget https://github.com.cnpmjs.org/tangyibo/greenplum_exporter/releases/download/1.0/greenplum_exporter-1.0-1.x86_64.rpm rpm -ivh greenplum_exporter-1.0-1.x86_64.rpm
二、配置數據庫鏈接 修改vim /etc/systemd/system/greenplum_exporter.service文件中配置的greenplum數據庫服務器的地址和gpadmin帳號的密碼。 ---- [Unit] Description=greenplum exporter After=network.target [Service] Type=simple User=prometheus Environment=GPDB_DATA_SOURCE_URL=postgres://gpadmin:gpadmin@192.168.100.11:5432/postgres?sslmode=disable ExecStart=/usr/local/greenplum_exporter/bin/greenplum_exporter --log.level=error Restart=on-failure [Install] WantedBy=multi-user.target ----
啓動Expoter程序 ---- systemctl daemon-reload systemctl start greenplum_exporter systemctl status greenplum_exporter ----
重啓:promethues ps -ef |grep promethus kill -9 3121 ./prometheus --config.file=prometheus.yml
一、下載: wget https://dl.grafana.com/oss/release/grafana-7.1.5-1.x86_64.rpm rpm -ivh grafana-7.1.5-1.x86_64.rpm systemctl start grafana-server
五、訪問 訪問地址:http://192.168.100.16:3000 用戶名:admin 密碼:admin
使用Grafana繪製一個可視化狀態圖 根據以上監測指標,便可使用Grafana配置圖像了,具體內容請見: 將下面中的數據 https://github.com/tangyibo/greenplum_exporter/blob/master/grafana/greenplum_dashboard.json 中配置的內容粘貼到上圖紅色框框內,點擊load按鈕加載。