Hadoop SecondaryNameNode备份及恢复

时间:2022-12-08 09:29:39

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处于安全状态
Hadoop SecondaryNameNode备份及恢复

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

Hadoop SecondaryNameNode备份及恢复

在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数据备份及恢复&lpar;导入导出&rpar;的常用方法

    一.说明 随着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&num; 备份数据库恢复数据库

    /// <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学习&lpar;4&rpar;-mysqldump备份和恢复数据

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

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

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

随机推荐

  1. Ubuntu 查询 so 归属的 package

    . . . . . 今天 LZ 在运行一个程序的时候,出现找不到 so 库的情况: >$ ./core ./core: error : cannot open shared object fil ...

  2. python中隐式的内存共享

    在python中,基本上使用的是引用,那么就会造成一个隐式的内存共享,特别是在容器对象中,例如list,dictionary 对于不可变对象,是不会造成隐式的内存共享情况,如下所示: >> ...

  3. redis 多实例配置

    (redis的安装, 配置, 登陆等基础不再多说, 网上很多资料的, 这里只说个人对redis多实例的理解与配置) 我自己使用的redis版本是 2.8.13, 环境是 ubuntu 个人对多实例的理 ...

  4. Linux操作系统报:read-only file system

    在对集群测试过程中发现系统中某一节点中的磁盘变成read-only file system,从而导致测试任务出错,从网上查找资料,找到以下解决方案: 这个报错的意思是硬盘属性变成只读,不可写入: VO ...

  5. flexigrid 修改json格式

    1.修改默认的json格式为key:value 修改前 rows: [{id:'ZW',cell:['ZW','ZIMBABWE','Zimbabwe','ZWE','716']},{id:'ZW', ...

  6. dell服务器从硬盘导入阵列信息

    前几天去南京客户那里更新新的业务系统,客户要求将服务器上的旧的硬盘拆下来,换上新的硬盘,重新做raid,客户自己要插入旧的硬盘读取旧数据,昨天做了几个实验,两台Dell R710服务器各4块硬盘,一台 ...

  7. 树莓派安装 dig命令

     apt-get install  dnsutils

  8. ARKit 初体验

    ARKIT是苹果公司在今年发布的一个AR开发包,用于现有的IOS设备,是的,就是用在手机或者平板上,类似于pokemon go的效果.看了下演示视屏,嗯,看起来很厉害. 对于一个资深软粉,居然被要求研 ...

  9. iOS 中捕获截屏操作

    转自:iOS知识小集 在iOS 7后,苹果提供了UIApplicationUserDidTakeScreenshotNotification通知来告诉App用户做了截屏操作.苹果的描述如下: // T ...

  10. &period;Net&lpar;C&num;&rpar;用正则表达式清除HTML标签(包括script和style),保留纯本文&lpar;UEdit中编写的内容上传到数据库&rpar;

    去官网下载,本Demo用的MVC模式 下载地址:http://ueditor.baidu.com/website/download.html 加入文件夹中的结构: 引入了函数公式的图标: @{ Vie ...