在docker中连接mysqld-exporter-mysql_up 0

时间:2018-09-11 21:16:23

标签: mysql docker

我做了什么:

1. docker run --net minha-rede --name mysql01 -e MYSQL_ROOT_PASSWORD=Password1234 -d mysql

2. docker run --net minha-rede --name wordpress01 --link mysql01 -p 8080:80 -e WORDPRESS_DB_HOST=mysql01:3306 -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=Password1234 -e WORDPRESS_DB_NAME=wordpress -e WORDPRESS_TABLE_PREFIX=wp_ -d wordpress

3. docker exec -it mysql01 bash

4. mysql -u root -p

5. CREATE USER 'luckerman'@'localhost' IDENTIFIED BY 'onboard' WITH MAX_USER_CONNECTIONS 3;

6. GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'luckerman'@'localhost';

7. exit

8. exit

9. docker run -d \
  -p 9104:9104 --name mysqlexp01\
  --network minha-rede  \
  -e DATA_SOURCE_NAME="luckerman:onboard@(minha-rede:3306)/" \
  prom/mysqld-exporter

但是当我运行http://localhost:9104/metrics时,我收到消息# TYPE mysql_exporter_last_scrape_error gauge mysql_exporter_last_scrape_error 1 当我运行docker logs mysqlexp01时,会显示以下内容:

  

time =“ 2018-09-11T20:57:40Z” level = info msg =“正在启动mysqld_exporter(版本= 0.11.0,branch = HEAD,版本= 5d7179615695a61ecc3b5bf90a2a7c76a9592cdd)” source =“ mysqld_exporter.go:206” < / p>      

time =“ 2018-09-11T20:57:40Z” level = info msg =“构建上下文(go = go1.10.3,user = root @ 3d3ff666b0e4,date = 20180629-15:00:35)” source = “ mysqld_exporter.go:207”

     

time =“ 2018-09-11T20:57:40Z” level = info msg =“已启用刮板:” source =“ mysqld_exporter.go:218”

     

time =“ 2018-09-11T20:57:40Z” level = info msg =“ --collect.info_schema.tables” source =“ mysqld_exporter.go:222”

     

time =“ 2018-09-11T20:57:40Z” level = info msg =“ --collect.global_status” source =“ mysqld_exporter.go:222”

     

time =“ 2018-09-11T20:57:40Z” level = info msg =“ --collect.global_variables” source =“ mysqld_exporter.go:222”

     

time =“ 2018-09-11T20:57:40Z” level = info msg =“ --collect.slave_status” source =“ mysqld_exporter.go:222”

     

time =“ 2018-09-11T20:57:40Z” level = info msg =“在:9104上收听” source =“ mysqld_exporter.go:232”

     

time =“ 2018-09-11T20:57:44Z” level = error msg =“错误ping mysqld:拨打tcp 127.0.0.1:3306:连接:连接被拒绝” source =“ exporter.go:119”

我做错了什么?我尝试了很多论坛,站点等...

1 个答案:

答案 0 :(得分:0)

成功了!我是这样做的:

docker网络检查minha-rede

然后我找到了my-sql的IP(在我的情况下为172.23.0.2) 然后我输入了my-sql并执行了以下命令: 通过MAX_USER_CONNECTIONS 3的“ onboard”创建用户'luckerman'@'172.23.0.2'

GRANT过程,复制客户端,选择到'luckerman'@'172.23.0.2';

谢谢@ alex-karshin!