目錄node
1、普羅米修斯概述linux
2、時間序列數據golang
一、什麼是序列數據web
三、Prometheus的主要特徵docker
四、普羅米修斯原理架構圖數據庫
3、實驗環境準備vim
一、安裝prometheuswindows
Prometheus(由go語言(golang)開發)是一套開源的監控&報警&時間序列數 據庫的組合。適合監控docker容器。由於kubernetes(俗稱k8s)的流行帶動 了prometheus的發展。
https://prometheus.io/docs/introduction/overview/
時間序列數據(TimeSeries Data) : 按照時間順序記錄系統、設備狀態變化 的數據被稱爲時序數據。
應用的場景不少, 如:
關係型數據庫對於大規模數據的處理性能糟糕。NOSQL能夠比較好的處理 大規模數據,讓依然比不上時間序列數據庫。
高效的壓縮算法,節省存儲空間,有效下降IO
Prometheus有着很是高效的時間序列數據存儲方法,每一個採樣數據僅僅佔 用3.5byte左右空間,上百萬條時間序列,30秒間隔,保留60天,大概花了 200多G(來自官方數據)
多維度數據模型 靈活的查詢語言 不依賴分佈式存儲,單個服務器節點是自主的 以HTTP方式,經過pull模型拉去時間序列數據 也能夠經過中間網關支持push模型 經過服務發現或者靜態配置,來發現目標服務對象 支持多種多樣的圖表和界面展現
服務器 | IP地址 |
Prometneus服務器 | 192.168.116.129 |
被監控服務器 | 192.168.116.130 |
grafana服務器 | 192.168.116.131 |
教程使用的軟件:連接: https://pan.baidu.com/s/1QV4KYZksyIp65UsScioq4Q 提取碼: vcej
失效可聯繫我
1. 靜態ip(要求能上外網)
2. 主機名
各自配置好主機名 # hostnamectl set-hostname --static server.cluster.com 三臺都互相綁定IP與主機名 # vim /etc/hosts 192.168.116.129 master 192.168.116.130 node1 192.168.116.131 node2
echo "192.168.116.129 master 192.168.116.130 node1 192.168.116.131 node2">>/etc/hosts
3. 時間同步(時間同步必定要確認一下)
yum install -y ntpdate && ntpdate time.windows.com
4. 關閉防火牆,selinux
# systemctl stop firewalld # systemctl disable firewalld # iptables -F
從 https://prometheus.io/download/ 下載相應版本,安裝到服務器上
官網提供的是二進制版,解壓就能用,不須要編譯
上傳prometheus-2.5.0.linux-amd64.tar.gz
tar -zxvf prometheus-2.5.0.linux-amd64.tar.gz -C /usr/local/ mv /usr/local/prometheus-2.5.0.linux-amd64/ /usr/local/prometheus
直接使用默認配置文件啓動
/usr/local/prometheus/prometheus --config.file="/usr/local/prometheus/prometheus.yml" &
確認端口(9090)
ss -anltp | grep 9090
經過瀏覽器訪問http://服務器IP:9090就能夠訪問到prometheus的主界面
默認只監控了本機一臺,點Status --》點Targets --》能夠看到只監控了本 機
經過http://服務器IP:9090/metrics能夠查看到監控的數據
在web主界面能夠經過關鍵字查詢監控項
① 在遠程linux主機(被監控端agent1)上安裝node_exporter組件
下載地址: https://prometheus.io/download/
上傳node_exporter-0.16.0.linux-amd64.tar.gz
tar -zxvf node_exporter-0.16.0.linux-amd64.tar.gz -C /usr/local/ mv /usr/local/node_exporter-0.16.0.linux-amd64/ /usr/local/node_exporter
裏面就一個啓動命令node_exporter,能夠直接使用此命令啓動
nohup /usr/local/node_exporter/node_exporter &
確認端口(9100)
擴展: nohup命令: 若是把啓動node_exporter的終端給關閉,那麼進程也會 隨之關閉。nohup命令會幫你解決這個問題。
② 經過瀏覽器訪問http://被監控端IP:9100/metrics就能夠查看到 node_exporter在被監控端收集的監控信息
③ 回到prometheus服務器的配置文件裏添加被監控機器的配置段
在主配置文件最後加上下面三行
vim /usr/local/prometheus/prometheus.yml
- job_name: 'node1' static_configs: - targets: ['192.168.116.130:9100']
- job_name: 'agent1' # 取一個job名稱來代 表被監控的機器 static_configs: - targets: ['10.1.1.14:9100'] # 這裏改爲被監控機器 的IP,後面端口接9100
改完配置文件後,重啓服務
pkill prometheus
確認端口沒有進程佔用
/usr/local/prometheus/prometheus --config.file="/usr/local/prometheus/prometheus.yml" &
確認端口被佔用,說 明重啓成功
④ 回到web管理界面 --》點Status --》點Targets --》能夠看到多了一臺監 控目標
練習: 加上本機prometheus的監控 答: 在本機安裝node_exporter,也使用上面的方式監控起來。