1.cAdvisor是什么
cAdvisor是專門用來采集數(shù)據(jù)的工具。
2.Docker下cadvisor環(huán)境安裝
1.拉取官方鏡像google/cadvisor
[root@ecs-429b ~]$>docker pull google/cadvisor
2.創(chuàng)建容器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環(huán)境安裝
更多prometheus的詳細(xì)內(nèi)容,參考網(wǎng)址:http://www.reibang.com/writer#/notebooks/50037693/notes/87166367
1.拉取prom/prometheus鏡像
[root@ecs-429b ~]$>docker pull prom/prometheus
2.創(chuàng)建prometheus目錄冷溃,新增prometheus.yml文件沙庐,用于指定設(shè)置docker地址:mkdir -p /opt/prometheus镀梭、vi /opt/prometheus/prometheus.yml
3.創(chuàng)建prometheus容器屋确,指定端口瘤睹、名稱舌胶、掛載目錄捆蜀、設(shè)置時區(qū):
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幔嫂,即重啟服務(wù)就是重啟容器:docker restart prometheus
>對應(yīng)第二步辆它,新建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安裝的宿主機(jī)對應(yīng)的ip,比如10.100.10.15
labels:
instance: prometheus
- job_name: linux
static_configs:
- targets: ['172.17.0.1:9100'] #dokcer安裝的宿主機(jī)對應(yīng)的ip履恩,比如10.100.10.15
- job_name: mysql
static_configs:
- targets: ['172.17.0.1:9104'] #dokcer安裝的宿主機(jī)對應(yīng)的ip锰茉,比如10.100.10.15
- job_name: 'cadvisor'
static_configs:
- targets: ['172.17.0.1:8081'] #dokcer安裝的宿主機(jī)對應(yīng)的ip,比如10.100.10.15
>對應(yīng)第三步切心,創(chuàng)建prometheus并創(chuàng)建容器
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環(huán)境安裝
grafana容器搭建操作步驟
1.創(chuàng)建grafana目錄:
mkdir -p /opt/grafana/data
chmod 777 /opt/grafana/data
2.拉取官方的grafana鏡像:docker pull grafana/grafana
3.運(yùn)行容器飒筑,端口映射,用于外網(wǎng)訪問:
docker run -itd --name=grafana -p 3000:3000 \
-v /opt/grafana/data:/var/lib/grafana \
-v /etc/localtime:/etc/localtime:ro \
grafana/grafana
4.進(jìn)入容器:docker exec -it e7eeb8be6171 /bin/bash
5.輸入對應(yīng)的網(wǎng)址+端口绽昏,訪問容器协屡,用戶名/密碼的默認(rèn)值為admin/admin:http://10.100.10.16:3000/login