docker 部署prometheus+grafana

news/2024/5/18 21:51:27 标签: docker, prometheus, grafana

docker_0">首先进行部署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_18">开始进行安装docker

yum install docker-ce-19.03.* docker-ce-cli-19.03.* -y
# 由于新版kubelet建议使用systemd,所以可以把docker的CgroupDriver改成systemd
# "live-restore": true这个此参数相当于是进行加载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
# 所有节点设置开机自启动Docker:
systemctl daemon-reload && systemctl enable --now docker

安装普罗米修斯

下载镜像:

docker pull docker.mirrors.sjtug.sjtu.edu.cn/prom/prometheus

创建普罗米的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"]

创建普罗米使用的目录:

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启动的话可能出现没有权限的报错

进行验证是否启动成功:

在这里插入图片描述

grafana_92">grafana大屏展示

grafanadocker_93">进行下载grafanadocker镜像

docker pull docker.mirrors.sjtug.sjtu.edu.cn/grafana/grafana:latest

进行创建所有使用的目录

mkdir -p /root/grafana/data /root/grafana/plugins /root/grafana/config

cp文件到config下

cp grafana.ini  /root/grafana/config/grafana.ini

grafana_106">启动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

进行验证:

在这里插入图片描述

进行关联普罗米的数据源:

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述


http://www.niftyadmin.cn/n/5421634.html

相关文章

HTTP/2、HTTP/3对HTTP/1.1的性能改进和优化

HTTP/1.1 相比 HTTP/1.0 提高了什么性能&#xff1f; 性能上的改进&#xff1a; 使用长连接的方式改善了 HTTP/1.0 短连接造成的性能开销。 支持管道&#xff08;pipeline&#xff09;网络传输&#xff0c;只要第一个请求发出去了&#xff0c;不必等其回来&#xff0c;就可以…

1688平台官方开发平台API接口接入|发布商品|订单查询|跨境API接口

《财经十一人》获悉&#xff0c;阿里巴巴&#xff08;BABA.N&#xff09;旗下中国B2B平台1688正布局跨境业务。 举措主要有二&#xff1a;一是提供跨境版API接口&#xff0c;可将1688的货盘导入各类有流量的平台&#xff0c;比如各国代采网站、服务商SaaS&#xff08;软件服务…

前端开发的发展史:框架与技术栈的演变

&#x1f31f; 前言 欢迎来到我的技术小宇宙&#xff01;&#x1f30c; 这里不仅是我记录技术点滴的后花园&#xff0c;也是我分享学习心得和项目经验的乐园。&#x1f4da; 无论你是技术小白还是资深大牛&#xff0c;这里总有一些内容能触动你的好奇心。&#x1f50d; &#x…

【Spring】yaml自定义参数添加提示功能

文章目录 1. 说明2. 依赖3. 处理流程&#xff08;以自定义swagger配置为例&#xff09;3.1 定义自定义参数SwaggerProperties3.2 通过Configuration启用并使用自定义参数 4. 使用 返回首页 1. 说明 编写SpringBoot项目时是不是羡慕spring以及第三方插件的自动提示功能。其实实…

IP形象设计是什么设计?如何做?

随着市场竞争的激烈&#xff0c;越来越多的企业开始关注品牌形象的塑造和推广。在品牌形象中&#xff0c;知识产权形象设计是一个非常重要的方面。在智能和互联网的趋势下&#xff0c;未来的知识产权形象设计可能更加关注数字和社交网络。通过数字技术和社交媒体平台&#xff0…

sql面试题21:营销带货销量分析

题目大概意思&#xff1a; 找出网红带来的订单号和销售额&#xff08;销售额是该订单的&#xff0c;比如凑单&#xff09;&#xff0c;满足是优惠码是1的&#xff0c;B类商品 数据表两个&#xff0c;分别是订单和品类 CREATE TABLE 订单 (订单号 VARCHAR(512),商品号 VARCH…

链表——单链表的C实现(保姆级代码、注释教学)

首先需要借助三个文件 SList.h SList.c test.c 目录 SList.h &#xff1a;用来建立结构体、头文件、函数声明、全局变量建立 SList.c&#xff1a;对头文件中声明的函数的实现 void SLTPrint(SLTNode* phead) SLTNode* BuyLTNode(SLTDataType x) voi…

5天获限定访问学者Offer|新加坡南洋理工大学申请公派成功

L老师拟申报某公派访问学者项目&#xff0c;要求半个月内获得新加坡国立大学或者南洋理工大学的邀请函。我们利用广泛的资源和丰富的申请经验&#xff0c;高效运作&#xff0c;仅仅5天就获得了新加坡南洋理工大学的邀请函&#xff0c;提前完成申请人的委托。 L老师背景&#xf…