赞
踩
vim prometheus-config.yml
# 全局配置
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
# 监控prometheus本身
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
# 通过node_exporter将监控数据传给prometheus,如果要监控多台服务器,只要在每个服务器上安装node_exporter,指定不同多ip地址就好了
- job_name: 'node_qq'
static_configs:
- targets: ['10.10.220.xx:9100']
# 监控mysql
- job_name: 'mysql-qq'
static_configs:
- targets: ['10.10.220.xx:9104']
# 通过node_exporter将监控数据传给prometheus,如果要监控多台服务器,只要在每个服务器上安装node_exporter,指定不同多ip地址就好了
- job_name: 'node_mom_mysql'
static_configs:
- targets: ['10.10.220.xx:9100']
# 监控mysql
- job_name: 'mysql-mom'
static_configs:
- targets: ['10.10.220.xx:9104']
# 监控mysql
- job_name: 'mysql-mom-test'
static_configs:
- targets: ['10.10.10.130:9104']
docker pull prom/prometheus
docker run --name prometheus -d -p 9090:9090 -v /root/prometheus/prometheus-config.yml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml
docker pull grafana/grafana
docker run --name grafana -d -p 3000:3000 grafana/grafana
docker pull portainer/portainer
docker run -d -p 9000:9000 --restart=always -v /var/run/docker.sock:/var/run/docker.sock --name portainer portainer/portainer
tar -zxvf node_exporter-1.4.0.linux-amd64.tar.gz -C /opt/
ln -s /opt/node_exporter-1.4.0.linux-amd64/ /opt/node_exporter
nohup /opt/node_exporter/node_exporter &
配置prometheus
- job_name: 'node_mom_mysql'
static_configs:
- targets: ['10.10.220.xx:9100']
登录MySQL为exporter创建一个用户并进行授权(我直接使用root进行操作了,有风险,尽量不要使用)
CREATE USER 'exporter'@'127.0.0.1' IDENTIFIED BY 'xxxxxx' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'127.0.0.1';
flush privileges;
配置mysql_exporter
vim /opt/mysqld_exporter/mysqld_exporter.cnf
[client]
host=127.0.0.1
user=exporter
password=xxxxxx
tar -zxvf mysqld_exporter-0.14.0.linux-amd64.tar.gz -C /opt/
ln -s /opt/mysqld_exporter-0.12.1.linux-amd64/ /opt/mysqld_exporter
nohup /opt/mysqld_exporter/mysqld_exporter --config.my-cnf=/opt/mysqld_exporter/mysqld_exporter.cnf &
配置prometheus
# 监控mysql
- job_name: 'mysql-mom-test'
static_configs:
- targets: ['10.10.10.xxx:9104']
以docker 方式启动
docker run -d --restart=always --name mysqld-exporter -p 9104:9104 -e DATA_SOURCE_NAME="exporter:xxxxxx@(10.10.10.xx:3308)/" prom/mysqld-exporter
解决方法
在公司网络不行,但在家里的网络可以,说明是网络的问题,我把笔记本的无线切成手机热点就可以了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。