Hadoop MapReduce Task Log 无法查看syslog问题
现象:
由于多个map task共用一个JVM,所以只输出了一组log文件
|
datanode01:/data/hadoop-x.x.x/logs/userlogs$ ls -R .: attempt_201211220735_0001_m_000000_0 attempt_201211220735_0001_m_000002_0 attempt_201211220735_0001_m_000005_0 attempt_201211220735_0001_m_000001_0 attempt_201211220735_0001_m_000003_0 ./attempt_201211220735_0001_m_000000_0: log.index ./attempt_201211220735_0001_m_000001_0: log.index ./attempt_201211220735_0001_m_000002_0: log.index stderr stdout syslog |
通过http://xxxxxxxx:50060/tasklog?attemptid= attempt_201211220735_0001_m_000000_0 获取task的日志时,会出现syslog无法获取
原因:
1.TaskLogServlet.doGet()方法
if (filter == null) {
printTaskLog(response, out, attemptId,start, end, plainText,
TaskLog.LogName.STDOUT,isCleanup);
printTaskLog(response, out, attemptId,start, end, plainText,
TaskLog.LogName.STDERR,isCleanup);
if(haveTaskLog(attemptId, isCleanup, TaskLog.LogName.SYSLOG)) {
printTaskLog(response, out,attemptId, start, end, plainText,
TaskLog.LogName.SYSLOG,isCleanup);
}
if(haveTaskLog(attemptId, isCleanup, TaskLog.LogName.DEBUGOUT)) {
printTaskLog(response, out,attemptId, start, end, plainText,
TaskLog.LogName.DEBUGOUT, isCleanup);
}
if(haveTaskLog(attemptId, isCleanup, TaskLog.LogName.PROFILE)) {
printTaskLog(response, out,attemptId, start, end, plainText,
TaskLog.LogName.PROFILE,isCleanup);
}
} else {
printTaskLog(response, out, attemptId,start, end, plainText, filter,
isCleanup);
}
尝试将filter=SYSLOG参数加上,可以访问到syslog,但去掉就不行。
看了代码多了一行
haveTaskLog(attemptId, isCleanup,TaskLog.LogName.SYSLOG)
判断,跟进代码发现,检查的是原来
attempt_201211220735_0001_m_000000_0目录下是否有syslog文件?
而不是从log.index找location看是否有syslog文件,一个bug出现了!
2.TaskLogServlet. printTaskLog方法
获取日志文件时会从log.index读取。
InputStreamtaskLogReader =
new TaskLog.Reader(taskId,filter, start, end, isCleanup);
TaskLog.Reader
public Reader(TaskAttemptIDtaskid, LogName kind,
long start,long end, boolean isCleanup) throwsIOException {
// find the right log file
Map<LogName, LogFileDetail>allFilesDetails =
getAllLogsFileDetails(taskid, isCleanup); static Map<LogName, LogFileDetail> getAllLogsFileDetails(
TaskAttemptID taskid, booleanisCleanup) throws IOException { Map<LogName, LogFileDetail>allLogsFileDetails =
newHashMap<LogName, LogFileDetail>(); File indexFile = getIndexFile(taskid,isCleanup);
BufferedReader fis;
try {
fis = newBufferedReader(new InputStreamReader(
SecureIOUtils.openForRead(indexFile,obtainLogDirOwner(taskid))));
} catch(FileNotFoundException ex) {
LOG.warn("Index file for the log of " + taskid + " does not exist."); //Assume no task reuse is used and files exist on attemptdir
StringBuffer input = newStringBuffer();
input.append(LogFileDetail.LOCATION
+ getAttemptDir(taskid,isCleanup) + "\n");
for(LogName logName : LOGS_TRACKED_BY_INDEX_FILES) {
input.append(logName + ":0 -1\n");
}
fis = newBufferedReader(new StringReader(input.toString()));
}
………………….
问题解决:
类似getAllLogsFileDetails一样,先从log.index获取日志目录获取logdir,
File indexFile = getIndexFile(taskid,isCleanup);
BufferedReader fis;
try {
fis = newBufferedReader(new InputStreamReader(
SecureIOUtils.openForRead(indexFile,obtainLogDirOwner(taskid))));
} catch(FileNotFoundException ex) {
LOG.warn("Index file for the log of " + taskid + " does not exist."); //Assume no task reuse is used and files exist on attemptdir
StringBuffer input = newStringBuffer();
input.append(LogFileDetail.LOCATION
+ getAttemptDir(taskid,isCleanup) + "\n");
for(LogName logName : LOGS_TRACKED_BY_INDEX_FILES) {
input.append(logName + ":0 -1\n");
}
fis = newBufferedReader(new StringReader(input.toString()));
}
String str = fis.readLine();
if (str== null) { //thefile doesn't have anything
throw newIOException ("Index file for the log of " + taskid+"is empty.");
}
String loc =str.substring(str.indexOf(LogFileDetail.LOCATION)+
LogFileDetail.LOCATION.length());
从logdir中判断是否有syslog。
Workaround:
查询时加入在url上加入filter=SYSLOG就可以看到,不需要修改代码。
Hadoop MapReduce Task Log 无法查看syslog问题的更多相关文章
- Hadoop MapReduce Task的进程模型与Spark Task的线程模型
Hadoop的MapReduce的Map Task和Reduce Task都是进程级别的:而Spark Task则是基于线程模型的. 多进程模型和多线程模型 所谓的多进程模型和多线程模型,指的是同一个 ...
- [Hadoop] - Hadoop Mapreduce Error: GC overhead limit exceeded
在运行mapreduce的时候,出现Error: GC overhead limit exceeded,查看log日志,发现异常信息为 2015-12-11 11:48:44,716 FATAL [m ...
- Hadoop Mapreduce 参数 (一)
参考 hadoop权威指南 第六章,6.4节 背景 hadoop,mapreduce就如MVC,spring一样现在已经是烂大街了,虽然用过,但是说看过源码么,没有,调过参数么?调过,调到刚好能跑起来 ...
- Hadoop MapReduce编程 API入门系列之多个Job迭代式MapReduce运行(十二)
推荐 MapReduce分析明星微博数据 http://git.oschina.net/ljc520313/codeexample/tree/master/bigdata/hadoop/mapredu ...
- Hadoop MapReduce编程 API入门系列之网页排序(二十八)
不多说,直接上代码. Map output bytes=247 Map output materialized bytes=275 Input split bytes=139 Combine inpu ...
- Hadoop MapReduce编程 API入门系列之倒排索引(二十四)
不多说,直接上代码. 2016-12-12 21:54:04,509 INFO [org.apache.hadoop.metrics.jvm.JvmMetrics] - Initializing JV ...
- Hadoop MapReduce编程 API入门系列之二次排序(十六)
不多说,直接上代码. -- ::, INFO [org.apache.hadoop.metrics.jvm.JvmMetrics] - Initializing JVM Metrics with pr ...
- Hadoop MapReduce编程 API入门系列之最短路径(十五)
不多说,直接上代码. ======================================= Iteration: 1= Input path: out/shortestpath/input. ...
- hadoop MapReduce Yarn运行机制
原 Hadoop MapReduce 框架的问题 原hadoop的MapReduce框架图 从上图中可以清楚的看出原 MapReduce 程序的流程及设计思路: 首先用户程序 (JobClient) ...
随机推荐
- Android——Activity练习
manifests里的AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> < ...
- MySQL单行注释和多行释
单行注释:# 或者 -- 多行注释:/* ... */ 使用 # 时,# 和注释的内容之间可以没有空格 使用 -- 时,-- 和注释内容之间必须有空格
- idea窗口下方滚动条不明显设置
在使用idea时,下方的滚动条老是显示不明显,每次点击拖拽都很费劲,在网上找了很多相关设置,最后确定了一个最好的办法解决问题: Shift (上档) + 鼠标滚动,这样就可以横向翻滚了,很方便 此方 ...
- hbase shell 命令
HBase使用教程 时间 2014-06-01 20:02:18 IT社区推荐资讯 原文 http://itindex.net/detail/49825-hbase 主题 HBase 1 基 ...
- TFS SDK
vs2013 已包含. 可参考 TFS SDK: Connecting to TFS 2010 & TFS 2012 Programmatically http://geekswithblog ...
- SpringMVC 学习 九 SSM环境搭建 (二) Spring配置文件的编写
spring配置文件中需要干的事情 (一)开启 Service与pojo包的注解扫描 注意:spring 扫描与表对应的实体类,以及service层的类,不能用来扫描Controller层的类,因为 ...
- 三连击(NOIP1998)
题目链接:三连击 典型的打表题,但cgg今天不是教你怎么打表的,而是教你正解. 这题方法多样,比如递归求解也行,反正数据也不大. 在这里我提供另一种思路,我们枚举第一个数,即最小的一个数,然后分解它以 ...
- css固宽截取字符串
width:200px; white-space:nowrap; word-break:keep-all; overflow:hidden; text-overflow:ellipsis; 移动端支持 ...
- 证明LDU分解的唯一性
首先上(下)三角矩阵乘以上(下)三角矩阵结果还是上(下)三角矩阵, 另外我们考虑相乘后的对角元素可发现,对角原始是原来2矩阵对应对角元素的乘积. 另外对角线都是1的上(下)三角矩阵必定可以只是用行运算 ...
- C++STL list
list双向链表 高效进行插入删除数据 不可以随机存取元素,所以不支持at()和[]操作符.it可以++ --,不能it+5 节点序号从0开始 list<int> l; l.push_b ...