DataNode 上的数据块以文件形式存储在本地磁盘上,包括两个文件:
超时时长。HDFS 默认的超时时长为 10分钟 + 30秒。如果定义超时时间为 timeout,则超时时长的计算公式为:
timeout = 2 * dfs.namenode.heartbeat.recheck-interval + 10 * dfs.heartbeat.interval
dfs.namenode.heartbeat.recheck-interval 默认为 5分钟,
dfs.heartbeat.interval 默认为 3秒。
因此,总的超时时间为:10分钟 + 30秒
通过 hdfs-site.xml 配置文件,修改超时时长和心跳间隔。
<property>
<name>dfs.namenode.heartbeat.recheck-interval</name>
<value>300000</value>
<description>心跳重新检查间隔(毫秒)</description>
</property>
<property>
<name>dfs.heartbeat.interval</name>
<value>3</value>
<description>心跳间隔(秒)</description>
</property>
[root@hadoop-01 ~]# ls -l /data1/dfs/dn/current/BP-1494942513-172.20.4.81-1610618575835/current/finalized/subdir99/subdir99/
total 16
-rw-r--r-- 1 hdfs hdfs 49 Jul 8 16:51 blk_1080255312
-rw-r--r-- 1 hdfs hdfs 11 Jul 8 16:51 blk_1080255312_6514554.meta
-rw-r--r-- 1 hdfs hdfs 49 Jul 8 16:51 blk_1080255316
-rw-r--r-- 1 hdfs hdfs 11 Jul 8 16:51 blk_1080255316_6514558.meta
可以看出,HDFS 数据块的文件名组成格式为:
hadoop-hdfs-2.7.jar 里面的 hdfs-default.xml 文件的相关配置,设置相关 DataNode 数据目录。如下所示:
<property>
<name>dfs.datanode.data.dir</name>
<value>file://${hadoop.tmp.dir}01/dfs/data,file://${hadoop.tmp.dir}02/dfs/data</value>
</property>
Hadoop Archives 是特殊的归档格式。Hadoop Archive 映射到文件系统目录,且后缀名为 *.har。Hadoop 归档目录包含元数据(采用 _index 和 _masterindx 的形式)和数据(part-*)文件。_index 文件包含了归档文件的文件名和位置信息。
# 创建3个目录
[root@hadoop-01 ~]# hdfs dfs -mkdir /tmp/test/dir1
[root@hadoop-01 ~]# hdfs dfs -mkdir /tmp/test/dir2
[root@hadoop-01 ~]# hdfs dfs -mkdir /tmp/test/dir3
2、上传小文件
[root@hadoop-01 ~]# ls -l
total 12
-rw-r--r-- 1 root root 12 Aug 24 14:05 1.txt
-rw-r--r-- 1 root root 12 Aug 24 14:05 2.txt
-rw-r--r-- 1 root root 12 Aug 24 14:05 3.txt
[root@hadoop-01 ~]# hdfs dfs -put 1.txt /tmp/test/dir1
[root@hadoop-01 ~]# hdfs dfs -put 2.txt /tmp/test/dir2
[root@hadoop-01 ~]# hdfs dfs -put 3.txt /tmp/test/dir3
[root@hadoop-01 ~]# hdfs dfs -cat /tmp/test/dir1/1.txt
hello 1.txt
3、创建存放归档文件目录
[root@hadoop-01 ~]# hdfs dfs -mkdir /tmp/zoo
4、创建归档
[root@hadoop-01 ~]# hadoop archive -archiveName test.har -p /tmp/test dir1 dir2 dir3 /tmp/zoo/
5、查看归档文件
[root@hadoop-01 ~]# hdfs dfs -ls /tmp/zoo/test.har
Found 4 items
-rw-r--r-- 3 hdfs supergroup 0 2021-08-24 14:20 /tmp/zoo/test.har/_SUCCESS
-rw-r--r-- 3 hdfs supergroup 439 2021-08-24 14:20 /tmp/zoo/test.har/_index
-rw-r--r-- 3 hdfs supergroup 23 2021-08-24 14:20 /tmp/zoo/test.har/_masterindex
-rw-r--r-- 3 hdfs supergroup 36 2021-08-24 14:20 /tmp/zoo/test.har/part-0
6、使用 har URL 访问
索引、标识等文件会被隐藏,只显示创建归档前的原文件
[root@hadoop-01 ~]# hdfs dfs -ls har:///tmp/zoo/test.har
Found 3 items
drwxr-xr-x - hdfs supergroup 0 2021-08-24 13:56 har:///tmp/zoo/test.har/dir1
drwxr-xr-x - hdfs supergroup 0 2021-08-24 13:56 har:///tmp/zoo/test.har/dir2
drwxr-xr-x - hdfs supergroup 0 2021-08-24 13:56 har:///tmp/zoo/test.har/dir3
[root@hadoop-01 ~]# hdfs dfs -cat har:///tmp/zoo/test.har/dir1/1.txt
hello 1.txt
7、解除归档文件
# 使用 cp 解除归档
[root@hadoop-01 ~]# hdfs dfs -cp har:///tmp/zoo/test.har/dir1 /tmp
# 使用 distcp 解除归档,使用 Map/Reduce job
[root@hadoop-01 ~]# hadoop distcp har:///tmp/zoo/test.har/dir1 /tmp
[root@hadoop-01 ~]#
[root@hadoop-01 ~]# hdfs dfs -ls /tmp
Found 3 items
drwxr-xr-x - hdfs supergroup 0 2021-08-24 14:40 /tmp/dir1
drwxr-xr-x - hdfs supergroup 0 2021-08-24 13:54 /tmp/test
drwxr-xr-x - hdfs supergroup 0 2021-08-24 14:20 /tmp/zoo
[root@hadoop-01 ~]# hdfs dfs -ls /tmp/dir1
Found 1 items
-rw-r--r-- 3 hdfs supergroup 12 2021-08-24 14:40 /tmp/dir1/1.txt
[root@hadoop-01 ~]# hdfs dfs -cat /tmp/dir1/1.txt
hello 1.txt
在 NameNode 中启动一个后台线程(Emptier),该线程专门管理和监控文件系统回收站下面的文件,对于放进回收站的文件且超过生命周期,就会自动删除。
通过修改 core-site.xml 文件的相关配置,如下所示:
<property>
<name>fs.trash.interval</name>
<value>1</value>
</property>
fs.trash.interval=0,表示禁用回收站机制,1 表示开启。
我有一个字符串input="maybe(thisis|thatwas)some((nice|ugly)(day|night)|(strange(weather|time)))"Ruby中解析该字符串的最佳方法是什么?我的意思是脚本应该能够像这样构建句子:maybethisissomeuglynightmaybethatwassomenicenightmaybethiswassomestrangetime等等,你明白了......我应该一个字符一个字符地读取字符串并构建一个带有堆栈的状态机来存储括号值以供以后计算,还是有更好的方法?也许为此目的准备了一个开箱即用的库?
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我正在使用ruby1.9解析以下带有MacRoman字符的csv文件#encoding:ISO-8859-1#csv_parse.csvName,main-dialogue"Marceu","Giveittohimóhe,hiswife."我做了以下解析。require'csv'input_string=File.read("../csv_parse.rb").force_encoding("ISO-8859-1").encode("UTF-8")#=>"Name,main-dialogue\r\n\"Marceu\",\"Giveittohim\x97he,hiswife.\"\
我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳
关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭8年前。Improvethisquestion在首页我有:汽车:VolvoSaabMercedesAudistatic_pages_spec.rb中的测试代码:it"shouldhavetherightselect"dovisithome_pathit{shouldhave_select('cars',:options=>['volvo','saab','mercedes','audi'])}end响应是rspec./spec/request
在Rails4.0.2中,我使用s3_direct_upload和aws-sdkgems直接为s3存储桶上传文件。在开发环境中它工作正常,但在生产环境中它会抛出如下错误,ActionView::Template::Error(noimplicitconversionofnilintoString)在View中,create_cv_url,:id=>"s3_uploader",:key=>"cv_uploads/{unique_id}/${filename}",:key_starts_with=>"cv_uploads/",:callback_param=>"cv[direct_uplo
简而言之错误:NOTE:Gem::SourceIndex#add_specisdeprecated,useSpecification.add_spec.Itwillberemovedonorafter2011-11-01.Gem::SourceIndex#add_speccalledfrom/opt/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:91./opt/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/gem_dependency.rb:275:in`==':und
使用Ruby1.9.2运行IDE提示说需要gemruby-debug-base19x并提供安装它。但是,在尝试安装它时会显示消息Failedtoinstallgems.Followinggemswerenotinstalled:C:/ProgramFiles(x86)/JetBrains/RubyMine3.2.4/rb/gems/ruby-debug-base19x-0.11.30.pre2.gem:Errorinstallingruby-debug-base19x-0.11.30.pre2.gem:The'linecache19'nativegemrequiresinstall