由hbase.client.scanner.caching参数引发的血案(转)
转自:http://blog.csdn.net/rzhzhz/article/details/7536285
环境描述
问题描述
前几天,在HIVE执行SQL查询的时候出现了一个很奇怪的问题:就是每个SQL(涉及到MapReduce的SQL任务)在执行到某个百分比的时候,整个JOB会出现假死的情况。
- 2012-04-28 18:22:33,661 Stage-1 map = 0%, reduce = 0%
- 2012-04-28 18:22:59,760 Stage-1 map = 25%, reduce = 0%
- 2012-04-28 18:23:04,782 Stage-1 map = 38%, reduce = 0%
- 2012-04-28 18:23:07,796 Stage-1 map = 50%, reduce = 0%
- 2012-04-28 18:23:08,801 Stage-1 map = 50%, reduce = 8%
- 2012-04-28 18:23:17,839 Stage-1 map = 50%, reduce = 17%
- 2012-04-28 18:23:19,848 Stage-1 map = 63%, reduce = 17%
- 2012-04-28 18:23:32,909 Stage-1 map = 63%, reduce = 21%
- 2012-04-28 18:23:57,017 Stage-1 map = 75%, reduce = 21%
- 2012-04-28 18:24:09,075 Stage-1 map = 75%, reduce = 25%
- 2012-04-28 18:25:09,397 Stage-1 map = 75%, reduce = 25%
- 2012-04-28 18:26:09,688 Stage-1 map = 75%, reduce = 25%
- 2012-04-28 18:27:09,980 Stage-1 map = 75%, reduce = 25%
- 2012-04-28 18:28:10,262 Stage-1 map = 75%, reduce = 25%
- 2012-04-28 18:29:10,522 Stage-1 map = 75%, reduce = 25%
- 2012-04-28 18:30:10,742 Stage-1 map = 75%, reduce = 25%
- 2012-04-28 18:31:10,985 Stage-1 map = 75%, reduce = 25%
- 2012-04-28 18:32:11,238 Stage-1 map = 75%, reduce = 25%
- 2012-04-28 18:33:11,467 Stage-1 map = 75%, reduce = 25%
- 2012-04-28 18:34:11,731 Stage-1 map = 75%, reduce = 25%
- 2012-04-28 18:35:11,968 Stage-1 map = 75%, reduce = 25%
- 2012-04-28 18:36:12,213 Stage-1 map = 75%, reduce = 25%
- 2012-04-28 18:37:12,508 Stage-1 map = 75%, reduce = 25%
- 2012-04-28 18:38:12,747 Stage-1 map = 75%, reduce = 25%
- 2012-04-28 18:39:12,970 Stage-1 map = 75%, reduce = 25%
- 2012-04-28 18:40:13,205 Stage-1 map = 75%, reduce = 25%
之前几天还跑得挺好的,没有出现这种情况,然后是偶尔出现,到最后变成是几乎每个JOB都这样。
很头疼,检查了所有的日志(包括hadoop,hbase和hive),日志却没有任何异常。唯一让人有点疑虑的日志就是TaskTracker中这样的提示
- 2012-04-28 18:31:53,879 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:31:56,883 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:31:59,887 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:02,892 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:05,897 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:08,902 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:11,906 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:14,910 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:17,915 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:20,920 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:23,924 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:26,929 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:29,934 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:32,938 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:35,943 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:38,948 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:41,953 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:44,957 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:47,961 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:50,966 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:53,970 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:56,974 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:32:59,979 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:02,983 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:05,987 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:08,992 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:11,997 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:15,001 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:18,006 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:21,011 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:24,015 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:27,020 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:30,025 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:33,029 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:36,034 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:39,038 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:42,043 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:45,047 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:48,051 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:51,057 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
- 2012-04-28 18:33:54,062 INFO org.apache.hadoop.mapred.TaskTracker: attempt_201204281725_0002_m_000002_0 0.0%
查看日志无果,然后我很自然的想到了是不是网络或者内存、cpu的问题,查看系统参数,也没有出现异常的情况。
也怀疑过是否某个TT所在机器的性能问题,所以尝试停止了一些TT,但问题依旧存在。
继续纠结,完全不知道从何下手……
实在是没办法,只有在job监控页面查找锁定出现问题的task,记住其taskId,并追踪到相应的child进程(运行task的jvm)并kill掉,查看方法如下
jps -mvll |grep taskId
(此时JT检测到该task死亡并会重新分配该任务到其他TT)。最后奇迹发生了,该JOB顺利的执行完毕。
- 2012-04-28 18:40:51,324 Stage-1 map = 88%, reduce = 25%
- 2012-04-28 18:41:04,364 Stage-1 map = 88%, reduce = 29%
- 2012-04-28 18:41:31,448 Stage-1 map = 100%, reduce = 29%
- 2012-04-28 18:41:43,485 Stage-1 map = 100%, reduce = 100%
很意外,而且每个JOB假死时这个方法都凑效。从job监控界面看到假死的task都有一个备用的task也在运行。当时想到是hadoop本身的Speculative Task调度策略,然后就以为是hadoop本身的bug,还傻乎乎的去提bug……
等待无果,就只能自己动手了,从最简单的hive-hbase-handler-0.8.1.jar(因为不需要分开部署,哈哈,我其实还是蛮懒的)开始,查源码,加log。然后发现其实假死的task并没有被挂起,其实它还一直在运作,只是运作速度很慢。而且瓶颈就在hbase scan数据的时候,每取一条数据需要70+ms,神啊几十万的数据,这么个速度不慢才怪。
此时问题又出现了,为什么其他task的读取速度这么快呢?难道是本地数据的原因?
然后写log才发现,出现假死情况的task所处理的数据所在的regionServer不是本地的regionServer,其实Speculative Task调度策略也起作用了,只是该task比较点背,第二个分配的task也不在数据所在的regionServer上。所以才出现了hbase读取速度慢的原因。
但令人奇怪的是我明明在hbase-site.xml文件中设置了hbase.client.scanner.caching参数,scan数据的时候不应该是会在client端会有cache吗?为什么log中提现的是每取一条数据都会消耗70+ms的时间?难道是参数没有生效?
查看了scan的整个流程,hbase.client.scanner.caching的设置没有任何问题。只能又拿hive-hbase-handler-0.8.1.jar开刀了,修改HiveHBaseTableInputFormat这个类,在实例化Scan的手动设置一个cache值,最后发布,运行!问题解决,cache生效了。
奇怪的说,callable在设置cache的时候明明是先看Scan是否设置了cache,如果没设置就取配置文件中设置的值。为什么明明配置文件中设置了却不生效呢?
郁闷的时候出去溜达了一圈,才恍然大悟,我光在server端设置了cache,client端并没有设置,这个参数的名字这么明显是client端的。脑残了……
最后修改hadoop conf目录下的hbase-site.xml,问题解决。
结论
既然task所处理的数据所在的regionServer不是本地的regionServer时,取数据会比较慢,那就减少与非本地regionServer的交互次数。在保证内存足够的情况下适当的设置cache值对mapreduce的处理速度会提高不少。但这个参数是在client端参数,设置时请务必在client端设置。
由hbase.client.scanner.caching参数引发的血案(转)的更多相关文章
- spark shc hbase 超时问题 hbase.client.scanner.timeout.period 配置
异常信息 20/02/27 19:36:21 INFO TaskSetManager: Starting task 17.1 in stage 3.0 (TID 56, 725.slave.adh, ...
- 一个Tomcat配置参数引发的血案
转载:https://mp.weixin.qq.com/s/3IuTcDCTB3yIovp6o_vuKA 一.现象 有用户反馈访问PC首页偶尔会出现白页情况,也偶尔会收到听云的报警短信 二.监控(听云 ...
- 一个purge参数引发的惨案——从线上hbase数据被删事故说起
在写这篇blog前,我的心情久久不能平静,虽然明白运维工作如履薄冰,但没有料到这么一个细小的疏漏会带来如此严重的灾难.这是一起其他公司误用puppet参数引发的事故,而且这个参数我也曾被“坑过”. ...
- Hbase Scan的重要参数
Scan是操作Hbase中非常常用的一个操作,虽然前面的Hbase API操作简单的介绍了Scan的操作,但不够详细,由于Scan非常常用,关于其详细的整理也是很有必要的. Scan HBase中的数 ...
- PySpark操作HBase时设置scan参数
在用PySpark操作HBase时默认是scan操作,通常情况下我们希望加上rowkey指定范围,即只获取一部分数据参加运算.翻遍了spark的python相关文档,搜遍了google和stackov ...
- Java 向Hbase表插入数据报(org.apache.hadoop.hbase.client.HTablePool$PooledHTable cannot be cast to org.apac)
org.apache.hadoop.hbase.client.HTablePool$PooledHTable cannot be cast to org.apac 代码: //1.create HTa ...
- HBase Client API使用(二)---查询及过滤器
相关知识 创建表插入数据删除等见:http://www.cnblogs.com/wishyouhappy/p/3735077.html HBase API简介见:http://www.cnblogs. ...
- Java 向Hbase表插入数据报(org.apache.hadoop.hbase.client.HTablePool$PooledHTable cannot be cast to org.apac
org.apache.hadoop.hbase.client.HTablePool$PooledHTable cannot be cast to org.apac 代码: //1.create HTa ...
- 使用可变对象作为python函数默认参数引发的问题
写python的都知道,python函数或者方法可以使用默认参数,比如 1 def foo(arg=None): 2 print(arg) 3 4 foo() 5 6 foo("hello ...
随机推荐
- Vue----v-if 条件渲染
先看一个使用vue v-if的小例子 <div id="example"> <p>小明和小李和小新,小月正在捉迷藏此时</p> <p> ...
- NotePad++安装 html.css.js智能提示【转】
https://www.cnblogs.com/alirong/archive/2012/04/12/2443971.html
- canvas 绘制三次贝塞尔曲线
代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8 ...
- 2、pycharm中设置pytest为默认运行
1.打开File-setting 2.打开Tools-Python Integrated Tools 3.找到Default test runner选项,在下拉框中选择py.test 4.点Apply ...
- Yii Ar model 查询
Ar model 查询 参照表: CREATE TABLE tbl_user ( id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, username VA ...
- HTML知识梳理(笔记)
HTML常见元素 meta 定义和用法<meta> 元素可提供有关页面的元信息(meta-information),比如针对搜索引擎和更新频度的描述和关键词. <meta> 标 ...
- CentOS6.8 安装/升级Python2.7.x,并安装最新setuptools、pip、fabric程序总结
最终靠谱的可借鉴文档: 1.python官网 2.http://lovesoo.org/python-fabric-yuan-cheng-zi-dong-bu-shu-jian-jie.html 3. ...
- 【leetcode】433. Minimum Genetic Mutation
题目如下: 解题思路:我的思路很简单,就是利用BFS方法搜索,找到最小值. 代码如下: class Solution(object): def canMutation(self, w, d, c, q ...
- SpringMvc中乱码问题的解决
一:如果是前台传递的数据有问题. 在tomcat的service.xml中加上: URIEncoding="UTF-8" <Connector URIEncoding=&qu ...
- 9.28 linux系统基础优化
关闭SELinux(是美国安全局对强制访问的实现)功能 [root@wen ~]# sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selin ...