赞
踩
一、安装mysqld-exporter
1、下载mysqld-exporter:docker pull prom/mysqld-exporter
2、根据自己配置的数据库用户名和密码进行启动
docker run -d --name mysqld_exporter -p 9104:9104 -e DATA_SOURCE_NAME="root:Newmysql55..(127.0.0.1:3306)/" prom/mysqld-exporter
3、查看启动过的容器实例:docker ps -a
4、自动启动:docker update --restart=always b3cfe4658581
5、切换root用户操作,修改prometheus配置文件
cd /usr/local/prometheus/data
编辑prometheus.yml文件:vim prometheus.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'
- static_configs:
- - targets: ['192.168.184.130:9090']
-
- - job_name: 'mysql'
- static_configs:
- - targets: ['192.168.184.130:9104']
6、查看启动过的容器实例:docker ps -a
7、重启prometheus:docker restart e21b260d923d
8、重启mysqld-exporter:docker restart b3cfe4658581
9、登录prometheus进行查看:http://192.168.184.130:9090/
二、安装redis_exporter
1、下载:docker pull oliver006/redis_exporter
2、运行:docker run -d --name redis_exporter -p 9121:9121 oliver006/redis_exporter
3、自动启动:docker update --restart=always 448f012f6c68
4、切换root用户操作,修改prometheus配置文件
cd /usr/local/prometheus/data
编辑prometheus.yml文件:vim prometheus.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'
- static_configs:
- - targets: ['192.168.184.130:9090']
-
- - job_name: 'mysql'
- static_configs:
- - targets: ['192.168.184.130:9104']
-
- - job_name: 'redis'
- static_configs:
- - targets: ['192.168.184.130:9121']
5、查看启动过的容器实例:docker ps -a
6、重启prometheus:docker restart e21b260d923d
三、安装mongo-exporter
mongo-exporter安装方法1:
下载:docker pull noenv/mongo-exporter:latest
创建账号密码是在navicat链接mongodb之后进行查询创建
use admin
db.createUser({user:"root",pwd:"Newmongodb55..",roles:[{role:'root',db:'admin'}]})
运行:
mkdir -p /root/docker_volume/mongodb/data
docker run -d --name mongo-explorer -p 30056:9104 noenv/mongo-exporter --mongodb.uri mongodb://root:Newmongodb55..@192.168.59.130:27017
注意:上面的9104端口是必须的,而且它与mysql-exporter的端口都是9104
查看启动过的容器实例:docker ps -a
自动启动:docker update --restart=always 436ac6f83c60
切换root用户操作,修改prometheus配置文件
cd /usr/local/prometheus/data
编辑prometheus.yml文件:vim prometheus.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'
- static_configs:
- - targets: ['192.168.184.130:9090']
-
- - job_name: 'mysql'
- static_configs:
- - targets: ['192.168.184.130:9104']
-
- - job_name: 'redis'
- static_configs:
- - targets: ['192.168.184.130:9121']
-
- - job_name: 'mongo'
- static_configs:
- - targets: ['192.168.184.130:9104']
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。