目錄
Cadvisor +Prometheus+Grafana的安裝部署
一、安裝docker:
1、安裝docker-ce
2、阿里云鏡像加速器
3、下載組件鏡像
4、創(chuàng)建自定義網(wǎng)絡
二、部署Cadvisor
1、被監(jiān)控主機上部署Cadvisor容器
2、訪問cAdvisor頁面
三、安裝prometheus
1、部署Prometheus?
2、先準備配置
3、訪問prometheus頁面
四、部署Granfana
1、下載grafana并運行
2、配置Granfana
3、配置數(shù)據(jù)源
4、導入模板
5、選擇對應的數(shù)據(jù)源,點擊導入,
6、準備測試容器
7、WEB操作,如下:(新建+編+保存)
8、結(jié)果如下:
Cadvisor +Prometheus+Grafana的安裝部署
一、安裝docker:
1、安裝docker-ce
[root@huyang3 ~]# iptables -F
[root@huyang3 ~]# setenforce 0
[root@huyang3 ~]# systemctl stop firewalld
[root@huyang3 ~]# cd /etc/yum.repos.d/
[root@lhuyang3 ~]# wget
http://mirrors.aliyun.com/repo/Centos-7.repo
[root@huyang3 ~]# yum -y install yum-utils device-mapper-persistent-data lvm2
[root@huyang3 ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@huyang3 ~]# yum -y install docker-ce
[root@huyang3 ~]# systemctl start docker
[root@huyang3 ~]# systemctl enable docker
[root@huyang3 ~]# docker version
2、阿里云鏡像加速器
阿里云登錄 - 歡迎登錄阿里云,安全穩(wěn)定的云計算服務平臺
[root@huyang3 ~]# cat << END > /etc/docker/daemon.json
{
????"registry-mirrors":[ "https://nyakyfun.mirror.aliyuncs.com" ]
}
END
[root@huyang3 ~]# systemctl daemon-reload
[root@huyang3 ~]# systemctl restart docker
3、下載組件鏡像
[root@huyang3 ~]# docker pull prom/prometheus
[root@huyang3 ~]# docker pull google/cadvisor
[root@huyang3 ~]# docker pull grafana/grafana
[root@huyang3 ~]# docker images
4、創(chuàng)建自定義網(wǎng)絡
????????為了把后期創(chuàng)建的Cadvisor+InfluxDB+Grafana這三個容器都加入自己定義的網(wǎng)絡便于理解和管理,所以才新建一個自定義網(wǎng)絡。
[root@huyang3 ~]# docker network create monitor
[root@huyang3 ~]# docker network ls
????????Ps備注:假如出現(xiàn)上述網(wǎng)絡創(chuàng)建不成功的話,則重啟docker,然后再創(chuàng)建網(wǎng)絡,這樣就可以創(chuàng)建成功了!
[root@huyang3 ~]# docker network inspect monitor
二、部署Cadvisor
1、被監(jiān)控主機上部署Cadvisor容器
[root@huyang3 ~]# docker pull google/cadvisor
[root@huyang3 ~]# docker run -d \
--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=8080:8080 \
--detach=true \
--name=cadvisor \
google/cadvisor:latest
2、訪問cAdvisor頁面
訪問http://192.168.100.133:8080?cAdvisor頁面可以看到收集到的數(shù)據(jù)
三、安裝prometheus
1、部署Prometheus?
[root@huyang3 ~]# docker pull prom/prometheus
2、先準備配置
[root@huyang3 ~]# vim /tmp/prometheus.yml
# 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']
- job_name: 'docker' ##定義一個叫docker的組
static_configs:
- targets: ['192.168.100.133:8080'] ##填寫一個或多個cadvisor的主機地址用逗號隔開運行容器
[root@huyang3 ~]# docker run -d \
--name=prometheus ?-p 9090:9090 ?\
-v /tmp/prometheus.yml:/etc/prometheus/prometheus.yml \
-v /etc/localtime:/etc/localtime \
prom/prometheus
3、訪問prometheus頁面
http://192.168.100.133:9090
看到docker組狀態(tài)up為正常
查詢項是可以查到數(shù)據(jù)的
四、部署Granfana
1、下載grafana并運行
[root@huyang3 ~]# docker pull grafana/grafana
[root@huyang3 ~]# docker run -d \
--name=grafana \
?-p 3000:3000 \
grafana/grafana
2、配置Granfana
訪問http://192.168.100.133:3000默認賬戶admin 密碼 admin首次登陸需要修改密碼!
?
3、配置數(shù)據(jù)源
4、導入模板
5、選擇對應的數(shù)據(jù)源,點擊導入,
就可以看到被監(jiān)控主機的數(shù)據(jù)
6、準備測試容器
[root@huyang3 ~]# docker run -d --name=nginx -p 80:80 nginx
7、WEB操作,如下:(新建+編+保存)
?
8、結(jié)果如下:
?文章來源:http://www.zghlxwxcb.cn/news/detail-634116.html
到此Cadvisor +Prometheus+Grafana基本架構(gòu)部署完畢文章來源地址http://www.zghlxwxcb.cn/news/detail-634116.html
到了這里,關于docker容器監(jiān)控:Cadvisor +Prometheus+Grafana的安裝部署的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!