<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] ## 概述 作為應用與Kubernetes的監控體系,Prometheus具備諸多的優勢,如: * Kubernetes默認支持,非常適合容器和微服務 * 無依賴,安裝方便,上手容易 * 社區活躍,它不僅僅是個工具,而是生態 * 已有很多插件或者exporter,可以適應多種應用場景的數據收集需要 * Grafana默認支持,提供良好的可視化 * 高效,單一Prometheus可以處理百萬級的監控指標,每秒處理數十萬的數據點 在部署之前,先來了解一下Prometheus各個組件的作用吧! * MertricServer:是k8s集群資源使用情況的聚合器,收集數據給K8s集群內使用,如:kubectl,hpa,scheduler * PrometheusOperator:是一個系統檢測和警報工具箱,用來存儲監控數據; * NodeExporter:用于各node的關鍵度量指標狀態數據; * kubeStateMetrics:收集k8s集群內資源對象數據,指定告警規則; * Prometheus:采用pull方式收集apiserver,scheduler,controller-manager,kubelet組件數據,通過http協議傳輸; * Grafana:是可視化數據統計和監控平臺。 web管理部署一個就可以。如果安裝了其他web管理可以刪除 [https://github.com/prometheus/prometheus](https://github.com/prometheus/prometheus) ## 下載 **下載prometheus所需文件:** ``` 鏈接: https://pan.baidu.com/s/12W5DGlVZqWYtMKVxgfR6GA 提取碼: 8uw8 或者 git clone https://github.com.cnpmjs.org/diycat1024/Prometheus-Grafana ``` ### 在kubernetest集群中創建namespace ``` apiVersion: v1 kind: Namespace metadata: name: ns-monitor labels: name: ns-monitor kubectl apply -f namespace.yaml ``` ### 安裝node-exporter 在kubernetest集群中部署node-exporter,Node-exporter用于采集kubernetes集群中各個節點的物理指標,比如:Memory、CPU等。可以直接在每個物理節點是直接安裝,這里我們使用DaemonSet部署到每個節點上,使用 hostNetwork: true 和 hostPID: true 使其獲得Node的物理指標信息,配置tolerations使其在master節點也啟動一個pod。 ``` kubectl apply -f node-exporter.yaml ``` 檢驗node-exporter是否成功運行 ``` [root@master1 ~]# kubectl get pod -n ns-monitor NAME READY STATUS grafana-677d945674-56m5n 1/1 Running node-exporter-vkpt2 1/1 Running node-exporter-zkh9s 1/1 Running prometheus-6c9574d5ff-292bq 1/1 Running [root@master1 ~]# kubectl get svc -n ns-monitor NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) grafana-service NodePort 10.96.101.190 <none> 3000:32405/TCP node-exporter-service NodePort 10.107.147.241 <none> 9100:31672/TCP prometheus-service NodePort 10.97.249.230 <none> 9090:30437/TCP 瀏覽器訪問: http://主機ip:31672/metrics ``` [http://192.168.84.241:31672/metrics](http://192.168.84.241:31672/metrics) ## 安裝nsf server 參考最下面的解決辦法 搭建服務一條龍 ``` sudo apt install nfs-kernel-server ``` ``` sudo vim /etc/exports /nfs/prometheus/data/ 192.168.84.75/24(rw,no_root_squash,no_all_squash,sync) /nfs/grafana/data/ 192.168.84.75/24(rw,no_root_squash,no_all_squash,sync) ``` ``` sudo mkdir -p /nfs/prometheus/data sudo chmod -R 777 /nfs/prometheus/data/ sudo mkdir -p /nfs/grafana/data sudo chmod -R 777 /nfs/grafana/data/ sudo exportfs -r sudo systemctl start rpcbind sudo systemctl status rpcbind ``` ## 部署 Prometheus pod prometheus.yaml 中包含rbac認證、ConfigMap等。 需要修改 PersistentVolume.server ``` apiVersion: v1 kind: PersistentVolume metadata: name: "prometheus-data-pv" labels: name: prometheus-data-pv release: stable spec: capacity: storage: 5Gi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Recycle nfs: path: /nfs/prometheus/data server: 192.168.84.75 # nsf server的ip ``` ``` sudo kubectl apply -f prometheus.yaml ``` 檢驗是否正常運行 ``` [root@master1 ~]# sudo kubectl get pod -n ns-monitor NAME READY STATUS grafana-677d945674-56m5n 1/1 Running node-exporter-vkpt2 1/1 Running node-exporter-zkh9s 1/1 Running prometheus-6c9574d5ff-292bq 1/1 Running [root@master1 ~]# sudo kubectl get svc -n ns-monitor NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) grafana-service NodePort 10.96.101.190 <none> 3000:32405/TCP node-exporter-service NodePort 10.107.147.241 <none> 9100:31672/TCP prometheus-service NodePort 10.97.249.230 <none> 9090:30437/TCP ``` 如果是宿主機則可以訪問:http://10.97.249.230:9090 瀏覽器訪問: http://主機ip:30437/graph ## 在kubernetest中部署grafana ``` sudo kubectl apply -f grafana.yaml ``` 檢驗是否正常運行 ``` sudo kubectl get pod -n ns-monitor NAME READY STATUS grafana-677d945674-56m5n 1/1 Running node-exporter-vkpt2 1/1 Running node-exporter-zkh9s 1/1 Running prometheus-6c9574d5ff-292bq 1/1 Running sudo kubectl get svc -n ns-monitor NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) grafana-service NodePort 10.96.101.190 <none> 3000:32405/TCP node-exporter-service NodePort 10.107.147.241 <none> 9100:31672/TCP prometheus-service NodePort 10.97.249.230 <none> 9090:30437/TCP ``` 瀏覽器訪問: http://主機ip:32405/graph/login 默認用戶名和密碼:admin/admin ## grafana的配置 ### 配置數據源 Grafana需要拉取prometheus的接口獲取數據,才能畫圖。 ![](http://yuerblog.cc/wp-content/uploads/2019/01/word-image.png) 然后添加datasource: ![](https://yuerblog.cc/wp-content/uploads/2019/01/word-image-1.png) 選擇prometheus: ![](https://yuerblog.cc/wp-content/uploads/2019/01/word-image-2.png) 配置服務端地址,地址寫上面的 http://prometheus-service:9090(域名:9090), k8s的coreDNS會解析域名prometheus-service為對應的10.97.249.230地址 : ![](https://yuerblog.cc/wp-content/uploads/2019/01/word-image-3.png) ### 導入Dashboard模板 ![](https://www.itnotebooks.com/wp-content/uploads/2018/08/QQ%E6%B5%8F%E8%A7%88%E5%99%A8%E6%88%AA%E5%9B%BE20180823232633.png) **這里使用的是kubernetes集群模板,模板編號315,在線導入地址https://grafana.com/dashboards/315** ![](https://www.itnotebooks.com/wp-content/uploads/2018/08/QQ%E6%B5%8F%E8%A7%88%E5%99%A8%E6%88%AA%E5%9B%BE20180823232658.png) ![](https://www.itnotebooks.com/wp-content/uploads/2018/08/QQ%E6%B5%8F%E8%A7%88%E5%99%A8%E6%88%AA%E5%9B%BE20180823232717.png) ### **效果展示:** ![](https://www.itnotebooks.com/wp-content/uploads/2018/08/QQ%E6%B5%8F%E8%A7%88%E5%99%A8%E6%88%AA%E5%9B%BE20180823232815.png) ![](https://www.itnotebooks.com/wp-content/uploads/2018/08/QQ%E6%B5%8F%E8%A7%88%E5%99%A8%E6%88%AA%E5%9B%BE20180823232815.png) ![](https://www.itnotebooks.com/wp-content/uploads/2018/08/QQ%E6%B5%8F%E8%A7%88%E5%99%A8%E6%88%AA%E5%9B%BE20180823232838.png) ## Kubernetes創建pod一直處于ContainerCreating排查和解決 通過 `sudo kubectl get pod -n ns-monitor`查看pod名字和狀態 查看 prometheus pod信息 ``` sudo kubectl describe pod prometheus -n ns-monitor mount: /var/lib/kubelet/pods/9b618933-87b6-496a-90da-25a4e9e782c3/volumes/kubernetes.io~nfs/prometheus-data-pv: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program. Warning FailedMount 18s kubelet, catrefine-virtual-machine MountVolume.SetUp failed for volume "prometheus-data-pv" : mount failed: exit status 32 ``` ## 解決辦法 搭建nsf服務 ``` sudo apt install nfs-kernel-server ``` 默認情況下,在Ubuntu 18.04上,NFS版本2是禁用的。版本3和版本4已啟用。您可以通過運行以下[`cat`](https://www.myfreax.com/linux-cat-command/)命令來驗證: ``` sudo cat /proc/fs/nfsd/versions ``` 寫入 exports ``` cat /etc/exports sudo echo /nfs/prometheus/data/ 192.168.84.75/24(rw,no_root_squash,no_all_squash,sync) >> /etc/exports sudo echo /nfs/prometheus/data/ 192.168.84.75/24(rw,no_root_squash,no_all_squash,sync) >> /etc/exports ``` ``` 可以設定的參數主要有以下這些: rw:可讀寫的權限; ro:只讀的權限; no_root_squash:登入到NFS主機的用戶如果是root,該用戶即擁有root權限; root_squash:登入NFS主機的用戶如果是root,該用戶權限將被限定為匿名使用者nobody; all_squash:不管登陸NFS主機的用戶是何權限都會被重新設定為匿名使用者nobody。 anonuid:將登入NFS主機的用戶都設定成指定的user id,此ID必須存在于/etc/passwd中。 anongid:同anonuid,但是變成group ID就是了! sync:資料同步寫入存儲器中。 async:資料會先暫時存放在內存中,不會直接寫入硬盤。 insecure:允許從這臺機器過來的非授權訪問。 ``` 驗證配置的/nfs/prometheus/data/是否正確 ``` sudo mkdir -p /nfs/prometheus/data sudo chmod -R 777 /nfs/grafana/data/ sudo exportfs -r ``` 啟動服務 ``` sudo systemctl start rpcbind sudo systemctl status rpcbind ``` 主節點,子節點檢驗: ``` [root@szy-k8s-master /]# showmount -e 192.168.84.75 Export list for 192.168.84.75: /nfs/prometheus/data 192.168.84.75/24 [root@szy-k8s-salve/]# showmount -e 192.168.84.75 Export list for 192.168.84.75: /nfs/prometheus/data 192.168.84.75/24 ``` ``` NFS客戶端的操作: 1、showmout命令對于NFS的操作和查錯有很大的幫助,所以我們先來看一下showmount的用法 showmout -a :這個參數是一般在NFS SERVER上使用,是用來顯示已經mount上本機nfs目錄的cline機器。 -e :顯示指定的NFS SERVER上export出來的目錄。 2、mount nfs目錄的方法: mount -t nfs hostname(orIP):/directory /mount/point ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看