Hadoop SecondaryNameNode备份及恢复
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备份及恢复的更多相关文章
- HBase数据备份及恢复(导入导出)的常用方法
一.说明 随着HBase在重要的商业系统中应用的大量增加,许多企业需要通过对它们的HBase集群建立健壮的备份和故障恢复机制来保证它们的企业(数据)资产.备份Hbase时的难点是其待备份的数据集可能非 ...
- 我的MYSQL学习心得(十四) 备份和恢复
我的MYSQL学习心得(十四) 备份和恢复 我的MYSQL学习心得(一) 简单语法 我的MYSQL学习心得(二) 数据类型宽度 我的MYSQL学习心得(三) 查看字段长度 我的MYSQL学习心得(四) ...
- postgresql数据库备份和恢复
PostgreSQL自带一个客户端pgAdmin,里面有个备份,恢复选项,也能对数据库进行备份 恢复(还原),但最近发现数据库慢慢庞大的时候,经常出错,备份的文件过程中出错的几率那是相当大,手动调节灰 ...
- Sql Server数据库备份和恢复:原理篇
本文与您探讨为什么Sql Server有完整备份.差异备份和事务日志备份三种备份方式,以及为什么数据库又有简单模式.完整模式和大容量日志模式这三种恢复模式.本文内容适用于2005以上所有版本的Sql ...
- 云与备份之(1):VMware虚机备份和恢复
本系列文章会介绍云与备份之间的关系,包括: (1)VMware 虚机备份和恢复 (2)KVM 虚机备份和恢复 (3)云与备份 (4)OpenStack 与备份 (5)公有云与备份 1. 与备份有关的V ...
- c# 备份数据库恢复数据库
/// <summary> /// 对数据库的备份和恢复操作,Sql语句实现 /// </summary> /// <param name="cmdText&q ...
- sql server远程备份和恢复
sql server远程备份和恢复 SQLSERVER服务实例名称:192.168.0.2需要备份的数据库名称: a备份机器名称(Client端):192.168.0.3备份机用户:zf 密码:123 ...
- mysql学习(4)-mysqldump备份和恢复数据
背景 最近在公司做数据迁移方面的工作,使用mysql数据库在测试环境模拟数据迁移,在迁移测试的过程中需要做数据备份和恢复 mysql数据备份和恢复比较简单,可以选择mysqldump工具,这里简单提一 ...
- Windows Server 2003 服务器备份和恢复技巧
1.系统备份与恢复 现在很多中小型企业服务器并没有采用专业的服务器备份机制进行备份,对于个人站长而言这似乎更不可能.但是再好的服务器维护人员总有失误的时候,为了防止万一我们最好还是采用一些备 ...
随机推荐
- CF 518 D. Ilya and Escalator
Ilya got tired of sports programming, left university and got a job in the subway. He was given the ...
- Red hat 5挂载U盘
装在虚拟机上的Linux 一.挂载U盘 ...
- Ecshop(二次开发) - 后台添加左侧菜单导航
1.链接地址:修改 admin\includes\inc_menu.php 文件. $modules['17_syn_data']['view_syn'] = 'synchroni ...
- php中at @符号的作用使用说明
一次,下载别人的源码来看,看到无数@记号,开始以为是注释:后来发现@后面的语句也是会执行的.纳闷了,这个记号究竟是做什么的呢..... 随着学习的不断深入,总算是明白了.这个记号的作用有点类似于asp ...
- Java多线程之新类库中的构件CountDownLatch
使用CountDownLatch类 一个同步辅助类,在完成一组正在其他线程中执行的操作之前,它允许一个或多个线程一直等待. 主要方法 public CountDownLatch(int count); ...
- Xcode5创建自己的静态库详解
首先声明: 本人屌丝一枚,如有不对不妥之处,请大牛指正! 1.静态库工程的建立: Xcode New一个新的project,选择IOS下面的Framework&Library,下面有一个Coc ...
- 解决xcode打开时loading假死的问题
症状如下: 点击打开xcode后,就一直会看到loading,但是CPU消耗很高,基本上就是死了(动弹不得),通过活动监测器看到xcode显示为“未响应” 以为是安装程序的问题,结果选中xcode拉到 ...
- [Flex] Accordion系列 - Header图标的设置
<?xml version="1.0" encoding="utf-8"?> <!--Flex中如何通过getHeaderAt()函数以及se ...
- Go Mobile 例子 basic 源码分析
OpenGL ES(OpenGL for Embedded Systems)是 OpenGL 三维图形API的子集,针对手机.PDA和游戏主机等嵌入式设备而设计.该API由Khronos集团定义推广, ...
- Python访问私有变量
代码: class Counter(object): __secount=0 publicfs=0 def getcount(self): self.__secount+=1 self.publicf ...