• 使用 cAdvisor 主机上的容器


    前言

    官方地址:https://github.com/google/cadvisor

    CAdvisor 是谷歌开发的用于分析运行中容器的资源占用和性能指标的开源工具。
    CAdvisor 是一个运行时的守护进程,负责收集、聚合、处理和输出运行中容器的信息。

    基于 Prometheus 安装文章进行的试验。

    安装测试

    安装 docker

    配置docker的yum源

    [root@es01 ~]# cat /etc/yum.repos.d/docker-ce.repo 
    [docker-ce-stable]
    name=Docker CE Stable - $basearch
    baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/stable
    enabled=1
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
    
    [docker-ce-stable-debuginfo]
    name=Docker CE Stable - Debuginfo $basearch
    baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/debug-$basearch/stable
    enabled=0
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
    
    [docker-ce-stable-source]
    name=Docker CE Stable - Sources
    baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/source/stable
    enabled=0
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
    
    [docker-ce-edge]
    name=Docker CE Edge - $basearch
    baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/edge
    enabled=0
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
    
    [docker-ce-edge-debuginfo]
    name=Docker CE Edge - Debuginfo $basearch
    baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/debug-$basearch/edge
    enabled=0
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
    
    [docker-ce-edge-source]
    name=Docker CE Edge - Sources
    baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/source/edge
    enabled=0
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
    
    [docker-ce-test]
    name=Docker CE Test - $basearch
    baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/test
    enabled=0
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
    
    [docker-ce-test-debuginfo]
    name=Docker CE Test - Debuginfo $basearch
    baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/debug-$basearch/test
    enabled=0
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
    
    [docker-ce-test-source]
    name=Docker CE Test - Sources
    baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/source/test
    enabled=0
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
    
    [docker-ce-nightly]
    name=Docker CE Nightly - $basearch
    baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/nightly
    enabled=0
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
    
    [docker-ce-nightly-debuginfo]
    name=Docker CE Nightly - Debuginfo $basearch
    baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/debug-$basearch/nightly
    enabled=0
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
    
    [docker-ce-nightly-source]
    name=Docker CE Nightly - Sources
    baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/source/nightly
    enabled=0
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
    

    安装docker-ce

    yum install docker-ce -y
    

    启动

    systemctl start docker
    

    启动 cAdvisor 容器

    docker run 
      --volume=/:/rootfs:ro 
      --volume=/var/run:/var/run:ro 
      --volume=/sys:/sys:ro 
      --volume=/var/lib/docker/:/var/lib/docker:ro 
      --volume=/dev/disk/:/dev/disk:ro 
      --publish=8090:8080 
      --detach=true 
      --name=cadvisor 
      google/cadvisor:latest
    

    查看容器状态

    [root@es01 ~]# docker ps -a
    CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                    NAMES
    70f072038935        google/cadvisor:latest   "/usr/bin/cadvisor -…"   3 days ago          Up 3 days           0.0.0.0:8080->8080/tcp   cadvisor
    
    [root@es01 ~]# netstat -lntup | grep 8080
    tcp6       0      0 :::8080                 :::*                    LISTEN      9758/docker-proxy
    

    访问测试

    通过 http://ip:port 进行访问:

    prometheus 服务端配置

    编辑 prometheus.yml 配置文件,在 scripe_configs 下添加下面内容:

      - job_name: 'cadvisor'
        metrics_path: '/metrics'
        static_configs:
        - targets: ['10.0.20.11:8080']
    

    使用 promtool 检查配置文件

    [root@es01 config]# /opt/prometheus-2.14/bin/promtool check config /opt/prometheus-2.14/config/prometheus.yml
    Checking /opt/prometheus-2.14/config/prometheus.yml
      SUCCESS: 0 rule files found
    

    重新加载配置文件

    curl -X POST http://10.0.20.11:9090/-/reload
    

    访问测试:

  • 相关阅读:
    Building a flexiable renderer
    Indirect Illumination in mental ray
    我的心情
    Cellular Automata
    Subsurface Scattering in mental ray
    Shader Types in mental ray
    BSP Traversal
    我的渲染器终于达到了MR的速度
    How to handle displacement and motion blur
    说明
  • 原文地址:https://www.cnblogs.com/winstom/p/11928839.html
Copyright © 2020-2023  润新知