1、同步各个服务器时间

yum install ntp

ntpdate ntp.fudan.edu.cn

hdfs-site.xml配置

如果没有配置这一项,hadoop默认是0.0.0.0:50090,如果你的namenode和secondarynamenode配置在同一台服务器上,是没有问题的。如果分开部署没有指定该值,则hadoop会在namenode本机上找,就会出错

<property>
        <name>dfs.secondary.http.address</name>
        <value>snn0001:50090</value>
</property>

<property>
        <name>dfs.http.address</name>
        <value>nn0001:50070</value>
</property>

1、edits和fsimage

NameNode会把用户对FileSystem的操作保存在日志文件edits中

每次NameNode重启时,首先从镜像文件fsimage中读取HDFS数据,并把日志文件合并到fsimage中。

2、checkpoint

有两个参数控制SecondaryNameNode checkpoint

fs.checkpoint.period表示两次checkpoint的时间间隔,默认为3600s

fs.checkpoint.size规定edits文件最大值,超过该值即checkpoint,默认64M

可以通过NameNode的start-dfs.sh启动SecondaryNameNode

也可以通过./hadoop secondarynamenode -checkpoint或者./hadoop secondarynamenode -checkpoint force

3、恢复数据:

配置一台和NameNode一样的服务器

创建dfs.name.dir文件夹,注意:该文件夹不能包含合法的fsimage,否则会执行失败。因为NameNode会检查fs.checkpoint.dir目录下镜像的一致性,但是不会做任何改动。

注意:可以使用nfs备份dfs.name.dir和${hadoop.tmp.dir}/dfs/namesecondary

新建目录/hadoop/dfs/namenode和/hadoop/dfs/secondarynamenode

执行命令:./hadoop namenode -importCheckpoint,NameNode会读取checkpoint文件,保存到dfs.name.dir

出现以下错误:

12/01/24 00:02:56 WARN mortbay.log: /getimage: java.io.IOException: GetImage failed. java.net.ConnectException: Connection refused

这是因为没有在hdfs-site.xml配置dfs.secondary.http.address,上面已经配置了

下面的错误是由于数据块完整率没有达到hadoop规定的0.9990要求,所以namenode处于安全状态

把dfs.repliation值设置为2,重新格式化namenode,并上传数据,再次执行./hadoop namenode -importCheckpoint

在0.21.0中,可以通过Checkpoint Node和Backup Node做checkpoint

以下是官网对SecondaryNameNode的说明

The NameNode stores modifications to the file system as a log appended to a native file system file (edits). When a NameNode starts up, it reads HDFS state from an image file (fsimage) and then applies edits from the edits log file. It then writes new HDFS state to the fsimage and starts normal operation with an empty edits file. Since NameNode merges fsimage and edits files only during start up, the edits log file could get very large over time on a busy cluster. Another side effect of a larger edits file is that next restart of NameNode takes longer.

The secondary NameNode merges the fsimage and the edits log files periodically and keeps edits log size within a limit. It is usually run on a different machine than the primary NameNode since its memory requirements are on the same order as the primary NameNode. The secondary NameNode is started bybin/start-dfs.sh on the nodes specified in conf/masters file.

The start of the checkpoint process on the secondary NameNode is controlled by two configuration parameters.

  • fs.checkpoint.period, set to 1 hour by default, specifies the maximum delay between two consecutive checkpoints, and
  • fs.checkpoint.size, set to 64MB by default, defines the size of the edits log file that forces an urgent checkpoint even if the maximum checkpoint delay is not reached.

The secondary NameNode stores the latest checkpoint in a directory which is structured the same way as the primary NameNode's directory. So that the check pointed image is always ready to be read by the primary NameNode if necessary.

The latest checkpoint can be imported to the primary NameNode if all other copies of the image and the edits files are lost. In order to do that one should:

  • Create an empty directory specified in the dfs.name.dir configuration variable;
  • Specify the location of the checkpoint directory in the configuration variable fs.checkpoint.dir;
  • and start the NameNode with -importCheckpoint option.

The NameNode will upload the checkpoint from the fs.checkpoint.dir directory and then save it to the NameNode directory(s) set in dfs.name.dir. The NameNode will fail if a legal image is contained indfs.name.dir. The NameNode verifies that the image in fs.checkpoint.dir is consistent, but does not modify it in any way.

Hadoop SecondaryNameNode备份及恢复的更多相关文章

  1. HBase数据备份及恢复(导入导出)的常用方法

    一.说明 随着HBase在重要的商业系统中应用的大量增加,许多企业需要通过对它们的HBase集群建立健壮的备份和故障恢复机制来保证它们的企业(数据)资产.备份Hbase时的难点是其待备份的数据集可能非 ...

  2. 我的MYSQL学习心得(十四) 备份和恢复

    我的MYSQL学习心得(十四) 备份和恢复 我的MYSQL学习心得(一) 简单语法 我的MYSQL学习心得(二) 数据类型宽度 我的MYSQL学习心得(三) 查看字段长度 我的MYSQL学习心得(四) ...

  3. postgresql数据库备份和恢复

    PostgreSQL自带一个客户端pgAdmin,里面有个备份,恢复选项,也能对数据库进行备份 恢复(还原),但最近发现数据库慢慢庞大的时候,经常出错,备份的文件过程中出错的几率那是相当大,手动调节灰 ...

  4. Sql Server数据库备份和恢复:原理篇

    本文与您探讨为什么Sql Server有完整备份.差异备份和事务日志备份三种备份方式,以及为什么数据库又有简单模式.完整模式和大容量日志模式这三种恢复模式.本文内容适用于2005以上所有版本的Sql ...

  5. 云与备份之(1):VMware虚机备份和恢复

    本系列文章会介绍云与备份之间的关系,包括: (1)VMware 虚机备份和恢复 (2)KVM 虚机备份和恢复 (3)云与备份 (4)OpenStack 与备份 (5)公有云与备份 1. 与备份有关的V ...

  6. c# 备份数据库恢复数据库

    /// <summary> /// 对数据库的备份和恢复操作,Sql语句实现 /// </summary> /// <param name="cmdText&q ...

  7. sql server远程备份和恢复

    sql server远程备份和恢复 SQLSERVER服务实例名称:192.168.0.2需要备份的数据库名称: a备份机器名称(Client端):192.168.0.3备份机用户:zf 密码:123 ...

  8. mysql学习(4)-mysqldump备份和恢复数据

    背景 最近在公司做数据迁移方面的工作,使用mysql数据库在测试环境模拟数据迁移,在迁移测试的过程中需要做数据备份和恢复 mysql数据备份和恢复比较简单,可以选择mysqldump工具,这里简单提一 ...

  9. Windows Server 2003 服务器备份和恢复技巧

    1.系统备份与恢复      现在很多中小型企业服务器并没有采用专业的服务器备份机制进行备份,对于个人站长而言这似乎更不可能.但是再好的服务器维护人员总有失误的时候,为了防止万一我们最好还是采用一些备 ...

随机推荐

  1. 设置session的生存时间

    1.最有效的方法 修改php.ini中  #session的超时时间 session.gc_maxlifetime = 1440  2.通过php去修改这个值 $Lifetime = 3600; $S ...

  2. unity jiaoben

    transform.Translate(Input.GetAxis("Horizontal")*Time.deltaTime,0,0); 移动 transform.Translat ...

  3. ipython and bpython

    ipython: 1.安装easy_install工具 wget http://peak.telecommunity.com/dist/ez_setup.py python ez_setup.py 2 ...

  4. gridView自动列宽代码

    gridView1.OptionsView.ColumnAutoWidth = false; for (int I = 0; I < gridView1.Columns.Count; I++) ...

  5. Notepad++隐藏的用法

    Notepad++是一个非常强大的文本编辑器. 它里面有很多有用的插件. 我认为对我比较有帮助的一个是NppExporter.它可以将Notepad++中彩色的代码原样的复制到Word中. 想要获得彩 ...

  6. [ActionScript 3.0] 自定义顶级类

    为了结合FlashBuilder编译参数,达到发布项目时不编译trace代码方便,写一个顶级类: package { public function tracing(...args):void { C ...

  7. [SQJ]sql如何实现类似统计的功能

    假设mssql2000中, 有如下表: table Class class_No course_Name ----------------------------------- chinese mat ...

  8. tarjan 边双连通分量 对点进行分组 每组点都在一个双连通分量里边

    int dfn[N],low[N],id[N],s[N],p,num,t,son[N];//dfn记录dfs时间戳//low代表当前点到达的最小时间戳,id对点进行分组编号.num是时间戳//s临时存 ...

  9. poj 1459 Power Network : 最大网络流 dinic算法实现

    点击打开链接 Power Network Time Limit: 2000MS   Memory Limit: 32768K Total Submissions: 20903   Accepted:  ...

  10. 阿里RDS备份恢复

    未使用root用户操作: 数据库版本要一致 数据目录:/data/mysqlbak/ 先按阿里给的步骤操作,最后出现一步出现,无法找到back_xxx.conf,但该文件已经存在.解决方法: sudo ...