zoukankan      html  css  js  c++  java
  • hadoop集群管理之 Namenode恢复

    1.修改conf/core-site.xml,增加 

    Xml代码  
    1. <property>  
    2.         <name>fs.checkpoint.period</name>    
    3.         <value>3600</value>    
    4.         <description>The number of seconds between two periodic checkpoints.  </description>  
    5. </property>  
    6. <property>    
    7.         <name>fs.checkpoint.size</name>    
    8.         <value>67108864</value>    
    9.         <description>The size of the current edit log (in bytes) that triggers       a periodic checkpoint even if the fs.checkpoint.period hasn't expired.  </description>  
    10. </property>  
    11.   
    12. <property>    
    13.         <name>fs.checkpoint.dir</name>    
    14.         <value>/data/work/hdfs/namesecondary</value>    
    15.         <description>Determines where on the local filesystem the DFS secondary      name node should store the temporary images to merge.      If this is a comma-delimited list of directories then the image is      replicated in all of the directories for redundancy.  </description>  
    16. </property>  


    fs.checkpoint.period表示多长时间记录一次hdfs的镜像。默认是1小时。 
    fs.checkpoint.size表示一次记录多大的size,默认64M 

    2.修改conf/hdfs-site.xml,增加 

    Xml代码  
    1. <property>    
    2.         <name>dfs.http.address</name>    
    3.         <value>master:50070</value>    
    4.         <description>    The address and the base port where the dfs namenode web ui will listen on.    If the port is 0 then the server will start on a free port.  </description>  
    5. </property>  


    0.0.0.0改为namenode的IP地址 

    3.重启hadoop,然后检查是否启动是否成功。 
    登录secondarynamenode所在的机器,输入jps查看secondarynamenode进程 
    进入secondarynamenode的目录/data/work/hdfs/namesecondary 
    正确的结果: 
     
    如果没有,请耐心等待,只有到了设置的checkpoint的时间或者大小,才会生成。 

    4.恢复 
    制造namenode宕机的情况 
    1) kill 掉namenode的进程 

    Java代码  
    1. [root@master name]# jps  
    2. 11749 NameNode  
    3. 12339 Jps  
    4. 11905 JobTracker  
    5. [root@master name]# kill 11749  



    2)删除dfs.name.dir所指向的文件夹,这里是/data/work/hdfs/name 

    Java代码  
    1. [root@master name]# rm -rf *  


      删除name目录下的所有内容,但是必须保证name这个目录是存在的 

    3)从secondarynamenode远程拷贝namesecondary文件到namenode的namesecondary 

    Java代码  
    1. [root@master hdfs]# scp -r slave-001:/data/work/hdfs/namesecondary/ ./  



    4)启动namenode 

    Java代码  
    1. [root@master /data]# hadoop namenode –importCheckpoint  


    正常启动以后,屏幕上会显示很多log,这个时候namenode就可以正常访问了 

    5)检查 
    使用hadoop fsck /user命令检查文件Block的完整性 

    6)停止namenode,使用crrl+C或者会话结束 

    7)删除namesecondary目录下的文件(保存干净) 

    Java代码  
    1. [root@master namesecondary]# rm -rf *  



    8)正式启动namenode 

    Java代码  
    1. [root@master bin]# ./hadoop-daemon.sh  start namenode  



    恢复工作完成,检查hdfs的数据 



    balancer 

    在使用start-balancer.sh时, 
    默认使用1M/S(1048576)的速度移动数据(so slowly...) 
    修改hdfs-site.xml配置,这里我们使用的是20m/S 
    <property> 
    <name>dfs.balance.bandwidthPerSec</name> 
    <value>20971520</value> 
    <description>  Specifies the maximum bandwidth that each datanode can utilize for the balancing purpose in term of the number of bytes per second. </description> 
    </property> 

    然后结果是导致job运行变得不稳定,出现一些意外的长map单元,某些reduce时间处理变长(整个集群负载满满的情况下,外加20m/s的balance),据说淘宝的为10m/s,需要调整后实验,看看情况如何。 

    Java代码  
    1. hadoop balancer -threshold 5  




    安全模式 
    有两个方法离开这种安全模式: 
    (1)修改dfs.safemode.threshold.pct为一个比较小的值,缺省是0.999。 
    dfs.safemode.threshold.pct(缺省值0.999f) 
    HDFS启动的时候,如果DataNode上报的block个数达到了元数据记录的block个数的0.999倍才可以离开安全模式,否则一直是这种只读模式。如果设为1则HDFS永远是处于SafeMode。 

    (2)hadoop dfsadmin -safemode leave命令强制离开 
    dfsadmin -safemode value 参数value的说明: 
    enter - 进入安全模式 
    leave - 强制NameNode离开安全模式 
    get -  返回安全模式是否开启的信息 
    wait - 等待,一直到安全模式结束。

  • 相关阅读:
    BNU 51002 BQG's Complexity Analysis
    BNU OJ 51003 BQG's Confusing Sequence
    BNU OJ 51000 BQG's Random String
    BNU OJ 50999 BQG's Approaching Deadline
    BNU OJ 50998 BQG's Messy Code
    BNU OJ 50997 BQG's Programming Contest
    CodeForces 609D Gadgets for dollars and pounds
    CodeForces 609C Load Balancing
    CodeForces 609B The Best Gift
    CodeForces 609A USB Flash Drives
  • 原文地址:https://www.cnblogs.com/JohnLiang/p/2244547.html
Copyright © 2011-2022 走看看