docker 部署prometheus+grafana的過程詳解
更新時間:2024年03月08日 14:56:33 作者:清風笑煙語
這篇文章主要介紹了docker 部署prometheus+grafana的過程,本文通過示例圖文相結(jié)合給大家介紹的非常詳細,需要的朋友可以參考下
首先進行部署docker
配置阿里云依賴:
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo # 配置centos 7的鏡像源 yum install -y yum-utils device-mapper-persistent-data lvm2 # 安裝一些后期或需要的的一下依賴 yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo sed -i 's/http/https/g' /etc/yum.repos.d/CentOS-Base.repo cat <<EOF > /etc/yum.repos.d/kubernetes.repo # 配置阿里云的k8s源 [kubernetes] name=Kubernetes baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg EOF sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
開始進行安裝docker
yum install docker-ce-19.03.* docker-ce-cli-19.03.* -y # 由于新版kubelet建議使用systemd,所以可以把docker的CgroupDriver改成systemd # "live-restore": true這個此參數(shù)相當于是進行加載docker不進行重啟里面的鏡像 mkdir /etc/docker cat > /etc/docker/daemon.json <<EOF { "registry-mirrors": [ "https://registry.docker-cn.com", "http://hub-mirror.c.163.com", "https://docker.mirrors.ustc.edu.cn" ], "exec-opts": ["native.cgroupdriver=systemd"], "max-concurrent-downloads": 10, "max-concurrent-uploads": 5, "log-opts": { "max-size": "300m", "max-file": "2" }, "live-restore": true } EOF # 所有節(jié)點設(shè)置開機自啟動Docker: systemctl daemon-reload && systemctl enable --now docker
安裝普羅米修斯
下載鏡像:
docker pull docker.mirrors.sjtug.sjtu.edu.cn/prom/prometheus
創(chuàng)建普羅米的yaml
# 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"]
創(chuàng)建普羅米使用的目錄:
mkdir /root/data/ cp prometheus.yml /root/.
啟動普羅米
docker run --name xixi -itd -u root -p 9091:9090 \ -v /root/prometheus.yml:/etc/prometheus/prometheus.yml \ -v /root/data: -v /root/data:/prometheus \ docker.mirrors.sjtug.sjtu.edu.cn/prom/prometheus:latest # 如果不寫-u root啟動的話可能出現(xiàn)沒有權(quán)限的報錯
進行驗證是否啟動成功:
grafana大屏展示
進行下載grafana的docker鏡像
docker pull docker.mirrors.sjtug.sjtu.edu.cn/grafana/grafana:latest
進行創(chuàng)建所有使用的目錄
mkdir -p /root/grafana/data /root/grafana/plugins /root/grafana/config
cp文件到config下
cp grafana.ini /root/grafana/config/grafana.ini
啟動grafana
docker run -dit \ -p 3000:3000 \ --name=grafana \ -u root \ -v /etc/localtime:/etc/localtime:ro \ -v /root/grafana/data:/var/lib/grafana \ -v /root/grafana/plugins/:/var/lib/grafana/plugins \ -v /root/grafana/config/grafana.ini:/etc/grafana/grafana.ini \ -e "GF_SECURITY_ADMIN_PASSWORD=admin" \ -e "GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource,grafana-piechart-panel" \ docker.mirrors.sjtug.sjtu.edu.cn/grafana/grafana:latest
進行驗證:
進行關(guān)聯(lián)普羅米的數(shù)據(jù)源:
到此這篇關(guān)于docker 部署prometheus+grafana的文章就介紹到這了,更多相關(guān)docker 部署prometheus+grafana內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
docker內(nèi)網(wǎng)搭建dns使用域名訪問替代ip:port的操作
這篇文章主要介紹了docker內(nèi)網(wǎng)搭建dns使用域名訪問替代ip:port的操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-11-11docker容器狀態(tài)出現(xiàn)Exit(1)的問題及解決
這篇文章主要介紹了docker容器狀態(tài)出現(xiàn)Exit(1)的問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-06-06docker-swarm之使用Docker secret管理敏感數(shù)據(jù)
就Docker Swarm集群服務(wù)而言,secret 是塊狀數(shù)據(jù),例如密碼、SSH私鑰、SSL證書或其他不應(yīng)通過網(wǎng)絡(luò)傳輸或未加密存儲在Dockerfile或應(yīng)用程序源代碼中的數(shù)據(jù),我們可以使用Docker secret 集中管理這些數(shù)據(jù),所以接下來就帶大家了解一下如何使用Docker secret 管理敏感數(shù)據(jù)2023-08-08.NET?6?從0到1使用Docker部署至Linux環(huán)境超詳細教程
這篇文章主要介紹了.NET?6?從0到1使用Docker部署至Linux環(huán)境,本文通過圖文并茂的形式給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-05-05Docker安裝ElasticSearch和Kibana的問題及處理方法
這篇文章主要介紹了Docker安裝ElasticSearch和Kibana的問題及遇到問題解決方法,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-02-02