背景:

线上一些任务大部分使用Spark Sql来处理Hive的数据;今天任务由于数据量增大,任务耗时也增加,因此导致多个任务同时运行。但是后来任务迟迟运行不完,因此去查看任务日志;

16-08-2018 10:16:47 CST java.sql.SQLException: null,  message from server: "Host 'datanode03' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"
16-08-2018 10:16:47 CST     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:963)
16-08-2018 10:16:47 CST     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896)
16-08-2018 10:16:47 CST     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885)
16-08-2018 10:16:47 CST     at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1042)
16-08-2018 10:16:47 CST     at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2253)
16-08-2018 10:16:47 CST     at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2284)
16-08-2018 10:16:47 CST     at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2083)
16-08-2018 10:16:47 CST     at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:806)
16-08-2018 10:16:47 CST     at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)
16-08-2018 10:16:47 CST     at sun.reflect.GeneratedConstructorAccessor54.newInstance(Unknown Source)
16-08-2018 10:16:47 CST     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
16-08-2018 10:16:47 CST     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
16-08-2018 10:16:47 CST     at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
16-08-2018 10:16:47 CST     at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:410)
16-08-2018 10:16:47 CST     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:328)
16-08-2018 10:16:47 CST     at java.sql.DriverManager.getConnection(DriverManager.java:664)
16-08-2018 10:16:47 CST     at java.sql.DriverManager.getConnection(DriverManager.java:208)
16-08-2018 10:16:47 CST     at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:361)
16-08-2018 10:16:47 CST     at com.jolbox.bonecp.BoneCP.obtainInternalConnection(BoneCP.java:269)
16-08-2018 10:16:47 CST     at com.jolbox.bonecp.ConnectionHandle.(ConnectionHandle.java:242)
16-08-2018 10:16:47 CST     at com.jolbox.bonecp.PoolWatchThread.fillConnections(PoolWatchThread.java:115)
16-08-2018 10:16:47 CST     at com.jolbox.bonecp.PoolWatchThread.run(PoolWatchThread.java:82)
16-08-2018 10:16:47 CST     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
16-08-2018 10:16:47 CST     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
16-08-2018 10:16:47 CST     at java.lang.Thread.run(Thread.java:745)
16-08-2018 10:16:48 CST 18/08/16 10:16:48 ERROR BoneCP: Failed to acquire connection to jdbc:mysql://datanode15:3306/hive?characterEncoding=UTF-8. Sleeping for 7000 ms. Attempts left: 0
16-08-2018 10:16:48 CST java.sql.SQLException: null,  message from server: "Host 'fg03' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"
16-08-2018 10:16:48 CST     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:963)
16-08-2018 10:16:48 CST     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896)
16-08-2018 10:16:48 CST     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885)
16-08-2018 10:16:48 CST     at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1042)
16-08-2018 10:16:48 CST     at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2253)
16-08-2018 10:16:48 CST     at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2284)
16-08-2018 10:16:48 CST     at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2083)
16-08-2018 10:16:48 CST     at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:806)
16-08-2018 10:16:48 CST     at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)
16-08-2018 10:16:48 CST     at sun.reflect.GeneratedConstructorAccessor54.newInstance(Unknown Source)
16-08-2018 10:16:48 CST     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
16-08-2018 10:16:48 CST     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
16-08-2018 10:16:48 CST     at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
16-08-2018 10:16:48 CST     at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:410)
16-08-2018 10:16:48 CST     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:328)
16-08-2018 10:16:48 CST     at java.sql.DriverManager.getConnection(DriverManager.java:664)
16-08-2018 10:16:48 CST     at java.sql.DriverManager.getConnection(DriverManager.java:208)
16-08-2018 10:16:48 CST     at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:361)
16-08-2018 10:16:48 CST     at com.jolbox.bonecp.BoneCP.obtainInternalConnection(BoneCP.java:269)
16-08-2018 10:16:48 CST     at com.jolbox.bonecp.ConnectionHandle.(ConnectionHandle.java:242)
16-08-2018 10:16:48 CST     at com.jolbox.bonecp.PoolWatchThread.fillConnections(PoolWatchThread.java:115)
16-08-2018 10:16:48 CST     at com.jolbox.bonecp.PoolWatchThread.run(PoolWatchThread.java:82)
16-08-2018 10:16:48 CST     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
16-08-2018 10:16:48 CST     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
16-08-2018 10:16:48 CST     at java.lang.Thread.run(Thread.java:745)
16-08-2018 10:16:48 CST 18/08/16 10:16:48 ERROR PoolWatchThread: Error in trying to obtain a connection. Retrying in 7000ms

关键的一段:java.sql.SQLException: null,  message from server: "Host 'datanode03' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"

怀疑是Mysql的问题

百度查询Mysql问题

原因: 同一个ip在短时间内产生太多(超过mysql数据库max_connect_errors的最大值)中断的数据库连接而导致的阻塞;

解决方法:
   1、提高允许的max_connection_errors数量:
  ① 进入Mysql数据库查看max_connection_errors: show variables like '%max_connect_errors%'; 
    ② 修改max_connection_errors的数量为1000: set global max_connect_errors = 1000; 
  ③ 查看是否修改成功:show variables like '%max_connect_errors%';

2、使用mysqladmin flush-hosts 命令清理一下hosts文件(不知道mysqladmin在哪个目录下可以使用命令查找:whereis mysqladmin);
  ① 在查找到的目录下使用命令修改:mysqladmin --socket=/tmp/kkimdb.sock --port=3306 -uhyman -p flush-hosts
  备注: 配置有master/slave主从数据库的要把主库和从库都修改一遍的(我就吃了这个亏明明很容易的几条命令结果折腾了大半天); 
      mysql> flush hosts; 也可以
      max_connect_errors是一个MySQL中与安全有关的计数器值,它负责阻止过多尝试失败的客户端以防止暴力破解密码的情况。max_connect_errors的值与性能并无太大关系。
      默认情况下,my.cnf文件中可能没有此行,如果需要设置此数值,手动添加即可。

原文链接:https://blog.csdn.net/fanyun_01/article/details/50922922

功能与作用
     一般来说建议数据库服务器不监听来自网络的连接,仅仅通过sock连接,这样可以防止绝大多数针对mysql的攻击;如果必须要开启mysql的网络连接,则最好设置此值,以防止穷举密码的攻击手段。

由于是内网使用,仅做Hive的元数据库使用,因此使用一下解决方案:

1、果断 set global max_connect_errors = 10000; 

2、同时,在crontab增加一个定时任务,定时执行mysqladmin flush-hosts 命令清理一下hosts文件

修改完成后,问题解决,任务正常运行,后面是否还有问题,还需要继续观察!

Hive连接Spark报错java.sql.SQLException: null, message from server: Host 'datanode03' is blocked becaus相关推荐

  1. java.sql.SQLException: null, message from server: “Host ‘XXX‘ is not allowed to connect异常(22.11.26)

    项目场景: 瑞吉外码项目优化部分,项目实现读写分离,配置两个数据源 问题描述 报错java.sql.SQLException: null, message from server: "Hos ...

  2. java.sql.SQLException: null, message from server: Host 'XXXXX' is not allowed to connect

    本人问题出现在,在linux的spark shell上,使用JDBC从其他数据库读取数据时,已导入mysql-connector-java-5.1.47-bin.jar包,运行代码时报错. //以下x ...

  3. Caused by: java.sql.SQLException: null, message from server: “Host ‘allen‘ is not allowed to connec

    启动metastore的报错 Caused by: java.sql.SQLException: null, message from server: "Host 'allen' is no ...

  4. java.sql.SQLException : null, message from server: “Host ‘‘ is not allowed to connect to this Maria

    文章目录 错误详情 错误原因 解决方案 最后 错误详情 今天在初始化云主机中Hive时报错如下: Underlying cause: java.sql.SQLException : null, mes ...

  5. java.sql.SQLException: null, message from server: “Host ‘xxx.xxx.xxx.xxx‘ is not allowed to

    迁移项目或是修改数据库密码后,项目访问数据库时报的这个异常.这个异常是数据库只允许localhost或127.0.0.1访问,不允许远程访问.我用的本机IP都不行. 解决办法:修改访问权限即可. 打开 ...

  6. java.sql.SQLException: null, message from server: “Host ‘xxx’ is not allowed to connect异常解决

    表示不能被允许远程访问,ip地址必须是localhost或者127.0.0.1,就算是局域网内也不行. 出现此异常的原因一般是在迁移项目后,只要你项目的数据库配置文件下的ip不是localhost或者 ...

  7. mysql_java.sql.SQLException: null, message from server: Host 'xxx' is not allowed to connect

    在连接远程服务器上的数据库的时候,出现mysql_java.sql.SQLException: null, message from server: "Host 'xxx' is not a ...

  8. 【问题篇】Springboot解决报错“java.sql.SQLException: Unable to load authentication plugin ‘caching_sha2_passw”

    场景:从代码仓库拉取以前的代码,运行时发现报错"java.sql.SQLException: Unable to load authentication plugin 'caching_sh ...

  9. maxIdle is deprecated+DruidDataSourceFactory报错+java.sql.SQLException: url not set

    maxldle已经被弃用,在配置文件删除即可. DruidDataSourceFactory报错:没有导入或找到相应的jar包. java.sql.SQLException: url not set: ...

最新文章

  1. 200秒=超算1万年,谷歌实现“量子霸权”论文上架随即被撤回,引发全球热议...
  2. DX使用随记--ImageComboBoxEdit
  3. 结构体数组实现的简易学生信息管理系统
  4. C# 3.0入门系列(二)
  5. 又一国产开源微内核操作系统上线!源代码已开放下载
  6. [转]微信小程序登录逻辑梳理
  7. LeetCode之两数之和
  8. element-ui简单使用
  9. JAXB实现java对象与xml之间转换
  10. Android 偶见花屏 bug,无法手动重现
  11. 记录一个Markdown编写的接口文档模版
  12. Axure 8.1.0.3381版安装包+注册码百度云盘下载
  13. 计算机如何更新苹果系统,苹果电脑怎么更新系统升级
  14. 上月用得好好的支付宝获取月账单的Java接口,月初突然返回“入参不合法”的解决方法
  15. 论文查重软件怎么选择
  16. 《Android开发艺术探索》图书勘误
  17. 读书笔记-人月神话14
  18. IP座席接入系统方案
  19. 【Excel常用函数】VLookup函数使用教程,附视频教程
  20. 怎么去禁止QQ的安全组件,来解决QQ和360的冲突问题

热门文章

  1. radio checkbox 点击文本实现选中效果
  2. mysql新加一列_mysql如何增加表中新的列?
  3. VSCode替换掉/去掉空行
  4. linux firefox严重卡顿,火狐浏览器卡顿怎么办 卡顿解决方法一览
  5. HikariCP探活机制如何保证链接有效
  6. 测绘用计算机吗,测绘工程中计算机制图应用
  7. 财报前瞻 | 互联网告别粗放经营,精耕行业价值成腾讯音乐年报看点
  8. Java计算数组中元素的总和
  9. rj45插座尺寸图_rj45接口尺寸、标准、电压、颜色介绍
  10. nssl 1454 2018CodeM总决赛 最短路