zoukankan      html  css  js  c++  java
  • hadoop 根据SecondaryNameNode恢复Namenode

    1.修改conf/core-site.xml

    增加

    复制代码
    <property> 
    <name>fs.checkpoint.period</name> 
    <value>3600</value> 
    <description>The number of seconds between two periodic checkpoints. </description> 
    </property> 
    <property> 
    <name>fs.checkpoint.size</name> 
    <value>67108864</value> 
    <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> 
    </property> 
    
    <property> 
    <name>fs.checkpoint.dir</name> 
    <value>/data/work/hdfs/namesecondary</value> 
    <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> 
    </property>
    复制代码

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

    2.修改conf/hdfs-site.xml

    增加

    <property> 
    <name>dfs.http.address</name> 
    <value>master:50070</value> 
    <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> 
    </property>

    0.0.0.0改为namenode的IP地址

    3.重启hadoop,然后检查是否启动是否成功

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

    4.恢复

    制造namenode宕机的情况 
    1) kill 掉namenode的进程

    [root@master name]# jps 
    11749 NameNode 
    12339 Jps 
    11905 JobTracker 
    [root@master name]# kill 11749

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

    [root@master name]# rm -rf *

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

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

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

    4)启动namenode

    [root@master /data]# hadoop namenode –importCheckpoint

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

    5)检查

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

    hadoop fsck /

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

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

    [root@master namesecondary]# rm -rf *


    8)正式启动namenode

    [root@master bin]# ./hadoop-daemon.sh start namenode

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

    9)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,需要调整后实验,看看情况如何。


    hadoop balancer -threshold 5

  • 相关阅读:
    系统的访问
    tomcat 和 数据库的连接
    实体类编写规则
    webmagic 爬虫
    docker安装官方Redis镜像并启用密码认证
    解决Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. 问题
    Springboot配置druid报错Failed to bind properties under 'spring.datasource' to javax.sql.DataSource
    阿里云centos7.6搭建SVN远程仓库和Git远程仓库
    java 三大特性封装继承多态
    使用easyui tab需要注意的问题
  • 原文地址:https://www.cnblogs.com/zlingh/p/3986333.html
Copyright © 2011-2022 走看看