一、实验步骤
1、安装docker、docker-compose
(1条消息) Docker离线环境部署服务_小布丁cc的博客-CSDN博客
(1条消息) Docker-compose离线安装_小布丁cc的博客-CSDN博客
2、下载镜像包
docker pull prom/node-exporter
docker pull prom/prometheus
docker pull grafana/grafana
3、启动node-exporter
docker run -d -p 9100:9100 \
-v "/proc:/host/proc:ro" \
-v "/sys:/host/sys:ro" \
-v "/:/rootfs:ro" \
--net="host" \
prom/node-exporter
4、访问url
地址:http://ip:9100/metrics 效果如下
5、新建目录prometheus,编辑配置文件prometheus.yml
[root@localhost /]# mkdir /opt/prometheus
[root@localhost /]# cd opt/prometheus/
[root@localhost prometheus]# vim prometheus.yml
global:
scrape_interval: 60s
evaluation_interval: 60s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
labels:
instance: prometheus
- job_name: linux
static_configs:
- targets: ['ip:9100']
labels:
instance: localhost
ps:修改IP地址,这里的IP就是本地地址
6、启动Prometheus
docker run -d \
-p 10050:9090 \
-v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
prom/prometheus
7、等待几秒查询端口状态
8、访问网站
http://ip:10050/graph
http://ip:10050/targets
9、启动grafana
docker run -d \
-p 10051:3000 \
--name=grafana \
-e "GF_SERVER_ROOT_URL=http://grafana.server.name" \
-e "GF_SECURITY_ADMIN_PASSWORD=admin" \
grafana/grafana
启动报错:提示我们容器冲突需要删除在重新启动
docker: Error response from daemon: Conflict. The container name "/grafana" is already in use by container "40cd8282b83c0807a3b4c89cea4973a8562a12d0caf214f1510da7cae11ac3dd". You have to remove (or rename) that container to be able to reuse that name.
10、访问首页
地址:http://ip:10051/ 账户密码:admin/admin
11、添加数据源
12、回到首页,导入granfana的监控模板,输入主机监控模板id:8919
更多监控模板:
https://grafana.com/grafana/dashboards/