首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用Prometheus、Docker和prom/mysqld图像监视MySQL

无法使用Prometheus、Docker和prom/mysqld图像监视MySQL
EN

Stack Overflow用户
提问于 2019-08-04 14:30:42
回答 1查看 2.1K关注 0票数 0

我正在使用Prometheus,Docker和prom/mysqld来监控MySQL。我已经搜索了很多网站,并一步一步地跟踪它们,但不幸的是,我没有得到我想要的结果。

有两个主要问题:

  1. 我甚至不能用我在docker-compose.yml文件中定义的用户和密码连接到mysql。

错误是:

错误1045 (28000):拒绝访问用户'root'@'localhost‘(使用密码: YES)

我还检查了堆栈溢出(如this one )中常见的问题,并尝试了所有这些问题,但仍然不能正常工作。我还添加了command: mysqld --default-authentication-plugin=mysql_native_password到mysql的配置中,在docker-复合文件中。

  1. 每当我设置DATA_SOURCE_NAME环境变量时,我都会遇到localhost:9104/metrics上度量指标的http超时,而我可以在没有任何问题的情况下获得localhost:9104,虽然我添加了一些标志,但它不起作用!

这是我的档案:

docker-compose.yml:

代码语言:javascript
复制
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:

代码语言:javascript
复制
[client]
user=mostafa
password=ghadimi

和prometheus.yml:

代码语言:javascript
复制
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命令时,我没有遇到任何错误。

EN

回答 1

Stack Overflow用户

发布于 2019-08-07 13:32:33

将mysql出口商的环境中的"localhost“转换为

mostafa:ghadimi@(mysql:3306)/db

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57347415

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档