我正在使用Prometheus,Docker和prom/mysqld来监控MySQL。我已经搜索了很多网站,并一步一步地跟踪它们,但不幸的是,我没有得到我想要的结果。
有两个主要问题:
错误是:
错误1045 (28000):拒绝访问用户'root'@'localhost‘(使用密码: YES)
我还检查了堆栈溢出(如this one )中常见的问题,并尝试了所有这些问题,但仍然不能正常工作。我还添加了command: mysqld --default-authentication-plugin=mysql_native_password到mysql的配置中,在docker-复合文件中。
DATA_SOURCE_NAME环境变量时,我都会遇到localhost:9104/metrics上度量指标的http超时,而我可以在没有任何问题的情况下获得localhost:9104,虽然我添加了一些标志,但它不起作用!这是我的档案:
docker-compose.yml:
version: '3'
services:
mysql:
image: mysql
container_name: mysql
restart: always
volumes:
- mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD= password
- MYSQL_DATABASE= db
- MYSQL_USER= mostafa
- MYSQL_PASSWORD= ghadimi
command: --default-authentication-plugin=mysql_native_password
ports:
- 3306:3306
- 33060:33060
adminer:
image: adminer
restart: always
ports:
- 8080:8080
prometheus:
image: prom/prometheus
container_name: prometheus
ports:
- 9090:9090
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
command:
- --config.file=/etc/prometheus/prometheus.yml
mysql-exporter:
image: prom/mysqld-exporter
container_name: mysql-exporter
ports:
- 9104:9104
volumes:
- ./mysql-exporter/.my.cnf:/root/.my.cnf
environment:
- DATA_SOURCE_NAME='mostafa:ghadimi@(localhost:9104)/db'
- collect.info_schema.tablestats=true
- collect.info_schema.userstats=true
- collect.info_schema.query_response_time=true
- collect.auto_increment.columns=true
- collect.binlog_size=true
- collect.perf_schema.eventsstatements=true
- collect.perf_schema.eventswaits=true
- collect.perf_schema.file_events=true
- collect.perf_schema.indexiowaits=true
- collect.perf_schema.tableiowaits=true
- collect.perf_schema.tablelocks=true
depends_on:
- mysql
volumes:
mysql:.my.cnf:
[client]
user=mostafa
password=ghadimi和prometheus.yml:
global:
scrape_interval: 15s
external_labels:
monitor: 'my-monitor'
scrape_configs:
# - job_name: 'prometheus'
# static_configs:
# - targets: ['localhost:9090']
- job_name: 'mysql-exporter'
static_configs:
- targets: ['mysql-exporter:9104']PS:每当我执行docker-compose up命令时,我没有遇到任何错误。
发布于 2019-08-07 13:32:33
将mysql出口商的环境中的"localhost“转换为
mostafa:ghadimi@(mysql:3306)/db
https://stackoverflow.com/questions/57347415
复制相似问题