1、先安装docker-io
yum install docker-io -y
2、配置加速
vim /etc/docker/daemon.json
{
“registry-mirrors”: [
“https://hub-mirror.c.163.com”,
“https://mirror.baidubce.com”
]
}
3、拉取prometheus、node-exporter、granfana镜像
docker pull granfana/granfana
docker pull prom/prometheus
docker pull prom/node-exporter
4、编辑prometheus.yml
vim /opt/prometheus/prometheus.yml
global:
scrape_interval: 60s
evaluation_interval: 60s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['192.168.100.17:9090']
labels:
instance: prometheus
- job_name: linux
static_configs:
- targets: ['192.168.100.17:9100']
labels:
instance: 192.168.100.17
5、运行node-exporter实例、prometheus实例、granfana实例
docker run -d -p 9100:9100 -v "/proc:/host/proc:ro" -v "/sys:/host/sys:ro" -v "/:/rootfs:ro" --net="host" prom/node-exporter
docker run -d \
> -p 9090:9090 \
> -v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
> prom/prometheus
创建granfana存储目录
mkdir /opt/grafana-storage
加权限
chmod 777 /opt/grafana-storage
docker run -d -p 3000:3000 -v /opt/grafana-storage/:/var/lib/grafana grafana/grafana
查看一下端口
ss -alntp
6、在本地浏览器访问prometheus、granfana
http://host_ip:9090/targets
可以看到所以node节点的状态
访问host_ip:3000可以访问granfana的web界面
docker搭建prometheus成功!