Hadoop MapReduce Task Log 无法查看syslog问题
2013-11-14 19:23
162 查看
现象:
由于多个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 |
原因:
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,private boolean haveTaskLog(TaskAttemptID taskId, boolean isCleanup, TaskLog.LogName type) throws IOException { File f = TaskLog.getTaskLogFile(taskId, isCleanup, type); if (f.exists() && f.canRead()) { return true; } else { File indexFile = TaskLog.getIndexFile(taskId, isCleanup); if (!indexFile.exists()) { return false; } BufferedReader fis; try { fis = new BufferedReader(new InputStreamReader( SecureIOUtils.openForRead(indexFile, TaskLog.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 = new StringBuffer(); input.append(LogFileDetail.LOCATION + TaskLog.getAttemptDir(taskId, isCleanup) + "\n"); for (LogName logName : TaskLog.LOGS_TRACKED_BY_INDEX_FILES) { input.append(logName + ":0 -1\n"); } fis = new BufferedReader(new StringReader(input.toString())); } try { String str = fis.readLine(); if (str == null) { // thefile doesn't have anything throw new IOException("Index file for the log of " + taskId + "is empty."); } String loc = str.substring(str.indexOf(LogFileDetail.LOCATION) + LogFileDetail.LOCATION.length()); File tf = new File(loc, type.toString()); return tf.exists() && tf.canRead(); } finally { if (fis != null) fis.close(); } } }
从logdir中判断是否有syslog。
Workaround:
查询时加入在url上加入filter=SYSLOG就可以看到,不需要修改代码。相关文章推荐
- Hadoop MapReduce Task Log 无法查看syslog问题
- Hadoop MapReduce Task Log 无法查看syslog问题
- SVN-无法查看log,提示Want to go offline,时间显示1970问题
- SVN使用:用TortoiseSVN查看Log 无法显示最新的版本和Log信息问题
- SVN使用:用TortoiseSVN查看Log 无法显示最新的版本和Log信息问题
- SVN使用:用TortoiseSVN查看Log 无法显示最新的版本和Log信息问题
- hadoop 2.6 mapreduce 自定义log 的查看方法
- SVN-无法查看log,提示Want to go offline,时间显示1970问题
- hadoop通过log分析mapreduce的过程及定位错误、分析问题
- 解决linux下tomcat8上传图片无法通过Nginx查看的问题
- hadoop运行mapreduce作业无法连接0.0.0.0/0.0.0.0:10020
- 【hadoop】DataNode,NameNode,JobTracker,TaskTracker用jps查看无法启动解决办法
- SpringMVC中定时器继承Task后无法对service注入问题 收藏 Pig-man 发表于 1年前 阅读 1863 收藏 1 点赞 2 评论 0 330元/年抢阿里云香港云服务器,节省8
- 解决Debug JDK source 无法查看局部变量的问题方案(重新编译rt.jar包)
- 问题:在手动刷新aspx页面时,出现“不重新发送信息,则无法刷新网页。请单击“重试”,或单击“取消”返回正查看的页。”
- windows10 下不能访问Hadoop在虚拟机中部署的完全分布式的hdfs和mapreduce问题
- Hive code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask问题修复
- osx中使用navicat连接sqlserver查看functions中的存储过程的内容时无法显示的问题
- ASP.NET2.0中"无法显示 XML 页。 使用 XSL 样式表无法查看 XML 输入。"问题的解决
- Hadoop的DataNode无法启动问题解决