当前位置: 代码迷 >> Web前端 >> HDFS 二中Namenode启动时WebUI的变化
  详细解决方案

HDFS 二中Namenode启动时WebUI的变化

热度:471   发布时间:2013-10-08 16:38:32.0
HDFS 2中Namenode启动时WebUI的变化
在HDFS1中NameNode启动顺序是这样的:
1. 读取Fsimage文件
2. 读取edit logs文件,逐行执行里面的操作
3. 写checkpoint,生成新的Fsimage(老的Fsimage + editlogs)
4. 进入safe mode,等待datanodes的block reports,直到达到最小的replication数的block百分比才退出

在安全模式期间,client是不能修改namespace信息,也不允许复制blocks,client基本上是被block住的
而且有些问题导致从namenode启动到client能请求request会耗费很长时间
1. 如果editlogs变得很大(比如由于secondary namenode服务挂了,没有及时merge一个比较新的fsimage),导致读入很大的editlogs,执行操作会比较慢
2. 一般fsimage和editlogs的文件都会做raid 1镜像, 在写新的fsimage checkpoint的时候会写多份,这就要求多份都写成功后这个操作才算成功,所以任何一块盘有性能瓶颈,都会导致延迟

另外一个问题是Namenode的Web UI Server是在写checkpoint之后才会启动的,这就导致了如果长时间在startup期间,管理员是无法直观通过WwebUI来看到整个启动进度,只能通过namenode.hadoop.log来看。

不过在2.1.0beta中已经加上了一个feature,能在WebUI上查看NM startup status(https://issues.apache.org/jira/browse/HDFS-4249),它的做法是将Web UI Server启动放到NM启动顺序的很前面,让用户可以尽早看到。而且在UI上,增加了不同stage的详细信息,包括加载的fsimage在NM节点上的绝对路径,它的文件大小,加载的inode的个数等,在safe mode的时候,也有显示已经收到的block数和block总数的占比,用户能大致估算出退出safe mode的时间。HDFS不仅仅是内部变得更健壮和稳定,在外围的用户体验也在变得越来越棒啊.

NM Startup progress:


除了WebUI,用户还可以wget http://namenode-address:50070/startupProgress?,获取JSON格式StartUp信息
{
    "elapsedTime": 35866, 
    "percentComplete": 1, 
    "phases": [
        {
            "name": "LoadingFsImage", 
            "status": "COMPLETE", 
            "percentComplete": 1, 
            "elapsedTime": 165, 
            "file": "/data/yarn/name/current/fsimage_0000000000000002434", 
            "size": 22763, 
            "steps": [
                {
                    "name": "Inodes", 
                    "count": 215, 
                    "total": 215, 
                    "percentComplete": 1, 
                    "elapsedTime": 25
                }, 
                {
                    "name": "DelegationKeys", 
                    "count": 0, 
                    "total": 0, 
                    "percentComplete": 1, 
                    "elapsedTime": 0
                }, 
                {
                    "name": "DelegationTokens", 
                    "count": 0, 
                    "total": 0, 
                    "percentComplete": 1, 
                    "elapsedTime": 0
                }
            ]
        }, 
        {
            "name": "LoadingEdits", 
            "status": "COMPLETE", 
            "percentComplete": 1, 
            "elapsedTime": 171, 
            "steps": [
                {
                    "count": 1, 
                    "file": "/data/yarn/name/current/edits_0000000000000002435-0000000000000002435", 
                    "size": 1048576, 
                    "total": 1, 
                    "percentComplete": 1, 
                    "elapsedTime": 15
                }, 
                {
                    "count": 1044, 
                    "file": "/data/yarn/name/current/edits_0000000000000002436-0000000000000003479", 
                    "size": 1048576, 
                    "total": 1044, 
                    "percentComplete": 1, 
                    "elapsedTime": 155
                }
            ]
        }, 
        {
            "name": "SavingCheckpoint", 
            "status": "COMPLETE", 
            "percentComplete": 1, 
            "elapsedTime": 77, 
            "steps": [
                {
                    "name": "Inodes", 
                    "count": 299, 
                    "file": "/data/yarn/name", 
                    "total": 299, 
                    "percentComplete": 1, 
                    "elapsedTime": 14
                }, 
                {
                    "name": "DelegationKeys", 
                    "count": 0, 
                    "file": "/data/yarn/name", 
                    "total": 0, 
                    "percentComplete": 1, 
                    "elapsedTime": 0
                }, 
                {
                    "name": "DelegationTokens", 
                    "count": 0, 
                    "file": "/data/yarn/name", 
                    "total": 0, 
                    "percentComplete": 1, 
                    "elapsedTime": 0
                }
            ]
        }, 
        {
            "name": "SafeMode", 
            "status": "COMPLETE", 
            "percentComplete": 1, 
            "elapsedTime": 35118, 
            "steps": [
                {
                    "name": "AwaitingReportedBlocks", 
                    "count": 218, 
                    "total": 218, 
                    "percentComplete": 1, 
                    "elapsedTime": 0
                }
            ]
        }
    ]
}
参考jira:
https://issues.apache.org/jira/browse/HDFS-4249

本文链接http://blog.csdn.net/lalaguozhe/article/details/10586555,转载请注明
  相关解决方案