1.cAdvisor是什么
cAdvisor是专门用来采集数据的工具。
2.Docker下cadvisor环境安装
1.拉取官方镜像google/cadvisor
[root@ecs-429b ~]$>docker pull google/cadvisor
2.创建容器google/cadvisor
[root@ecs-429b ~]$>docker run -itd --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=8081:8080 --detach=true --name=cadvisor google/cadvisor
3.Docker下prometheus环境安装
更多prometheus的详细内容,参考网址://www.greatytc.com/writer#/notebooks/50037693/notes/87166367
1.拉取prom/prometheus镜像
[root@ecs-429b ~]$>docker pull prom/prometheus
2.创建prometheus目录,新增prometheus.yml文件,用于指定设置docker地址:mkdir -p /opt/prometheus、vi /opt/prometheus/prometheus.yml
3.创建prometheus容器,指定端口、名称、挂载目录、设置时区:
docker run -itd --name prometheus -p 9090:9090
-v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
-v /etc/localtime:/etc/localtime:ro
prom/prometheus
>4.修改配置文件后,重启prometheus,即重启服务就是重启容器:docker restart prometheus
>对应第二步,新建yaml文件并修改:vi /opt/prometheus/prometheus.yml
global:
scrape_interval: 60s
evaluation_interval: 60s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['172.17.0.1:9090'] #dokcer安装的宿主机对应的ip,比如10.100.10.15
labels:
instance: prometheus
- job_name: linux
static_configs:
- targets: ['172.17.0.1:9100'] #dokcer安装的宿主机对应的ip,比如10.100.10.15
- job_name: mysql
static_configs:
- targets: ['172.17.0.1:9104'] #dokcer安装的宿主机对应的ip,比如10.100.10.15
- job_name: 'cadvisor'
static_configs:
- targets: ['172.17.0.1:8081'] #dokcer安装的宿主机对应的ip,比如10.100.10.15
>对应第三步,创建prometheus并创建容器
docker run -itd --name prometheus -p 9090:9090 \
-v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
-v /etc/localtime:/etc/localtime:ro \
prom/prometheus
4.Docker下grafana环境安装
grafana容器搭建操作步骤
1.创建grafana目录:
mkdir -p /opt/grafana/data
chmod 777 /opt/grafana/data
2.拉取官方的grafana镜像:docker pull grafana/grafana
3.运行容器,端口映射,用于外网访问:
docker run -itd --name=grafana -p 3000:3000 \
-v /opt/grafana/data:/var/lib/grafana \
-v /etc/localtime:/etc/localtime:ro \
grafana/grafana
4.进入容器:docker exec -it e7eeb8be6171 /bin/bash
5.输入对应的网址+端口,访问容器,用户名/密码的默认值为admin/admin:http://10.100.10.16:3000/login