标签:comm art doc 增加 pen monitor net 系统 主页
系统:CentOS Linux release 8.1.1911 (Core)docker: Docker version 19.03.8, build afacb8b
docker-compose: 1.23
安装以下依赖包
yum install -y yum-utils device-mapper-persistent-data lvm2
添加docker的yum源
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
配置镜像加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-‘EOF‘
{
"registry-mirrors": ["https://zggyaen3.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
更新yum源缓存, 安装docker-ce
$ sudo yum makecache fast
$ sudo yum install docker-ce
普通用户需要加入docker组
$ sudo usermod -a -G docker ${USER}
修改docker存储位置(可以不改)
$ sudo systemctl stop docker
$ sudo mv /var/lib/docker /home/lan/docker
$ sudo ln -s /home/lan/docker /var/lib/docker
$ sudo systemctl start docker
$ sudo systemctl enable docker
$ sudo curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
如果下载很慢可手动下载,再上传至系统
下载路径: https://github.com/docker/compose/releases/ 可以选择对应的版本下载
编写docker-compose文件
version: "3"
services:
prom:
image: quay.io/prometheus/prometheus:latest
volumes:
- ./monitor/prometheus.yml:/etc/prometheus/prometheus.yml
command: "--config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/prometheus"
ports:
- 23333:9090 # prometheus的访问地址被我改成了23333
depends_on:
- exporter
exporter:
image: prom/node-exporter:latest
ports:
- "9100:9100"
# network_mode: host
grafana:
image: grafana/grafana
ports:
- "3000:3000"
environment:
- “GF_SECURITY_ADMIN_PASSWORD=Gz2020@”
- “GF_INSTALL_PLUGINS=alexanderzobnin-zabbix-app”
restart: "always"
volumes:
- “grafana-etc:/etc/grafana/”
- $GRAFANA_DIR/data:/var/lib/grafana:rw
- $GRAFANA_DIR$GRAFANA_plugins:/var/lib/grafana/plugins:rw
- /etc/localtime:/etc/localtime
depends_on:
- prom
修改Prometheus配置文件,增加node-exporter监控
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: ‘prometheus‘
static_configs:
- targets: [‘localhost:9090‘]
- job_name: ‘server‘
static_configs:
- targets: [‘ip:9100‘]
验证Prometheus是否收到数据
ip:9100/metrics
访问 http://ip:3000 初始账号:admin 初始密码: admin
1. 点击设置 --> Data Sources --> Add data source --> Prometheus --> URL(填写 http://ip:23333)
2. 添加图形插件:
访问地址https://grafana.com/grafana/dashboards/8919 --> Download JSON --> 回到自己的grafana主页面 --> 左上角的home --> Import dashboard --> Upload.json file --> 该填的都填了,可以点Import就行
基于docker-compose部署Prometheus + Grafana监控系统
标签:comm art doc 增加 pen monitor net 系统 主页
原文地址:https://blog.51cto.com/liuxiaolan/2495250