Hadoop可以创建自己的归档文件 即har文件(hadoop archive file)。下面的一个shell命令展示如何创建归档文件:
$ hadoop archive -archiveName geoway_portal.har /user/Administrator/geoway_port
al/(对这个目录下的文件进行归档) /tmp/(要保存的位置)
12/11/07 22:04:28 INFO mapred.JobClient: Running job: job_201211070851_0001
12/11/07 22:04:29 INFO mapred.JobClient: map 0% reduce 0%
12/11/07 22:04:46 INFO mapred.JobClient: map 42% reduce 0%
12/11/07 22:04:58 INFO mapred.JobClient: map 60% reduce 0%
12/11/07 22:05:04 INFO mapred.JobClient: map 100% reduce 0%
12/11/07 22:05:22 INFO mapred.JobClient: map 100% reduce 100%
12/11/07 22:05:24 INFO mapred.JobClient: Job complete: job_201211070851_0001
12/11/07 22:05:24 INFO mapred.JobClient: Counters: 17
12/11/07 22:05:24 INFO mapred.JobClient: Job Counters
12/11/07 22:05:24 INFO mapred.JobClient: Launched reduce tasks=1
12/11/07 22:05:24 INFO mapred.JobClient: Launched map tasks=1
12/11/07 22:05:24 INFO mapred.JobClient: FileSystemCounters
12/11/07 22:05:24 INFO mapred.JobClient: FILE_BYTES_READ=926
12/11/07 22:05:24 INFO mapred.JobClient: HDFS_BYTES_READ=474439229
12/11/07 22:05:24 INFO mapred.JobClient: FILE_BYTES_WRITTEN=1402
12/11/07 22:05:24 INFO mapred.JobClient: HDFS_BYTES_WRITTEN=474438973
12/11/07 22:05:24 INFO mapred.JobClient: Map-Reduce Framework
12/11/07 22:05:24 INFO mapred.JobClient: Reduce input groups=7
12/11/07 22:05:24 INFO mapred.JobClient: Combine output records=0
12/11/07 22:05:24 INFO mapred.JobClient: Map input records=7
12/11/07 22:05:24 INFO mapred.JobClient: Reduce shuffle bytes=0
12/11/07 22:05:24 INFO mapred.JobClient: Reduce output records=0
12/11/07 22:05:24 INFO mapred.JobClient: Spilled Records=14
12/11/07 22:05:24 INFO mapred.JobClient: Map output bytes=424
12/11/07 22:05:24 INFO mapred.JobClient: Map input bytes=569
12/11/07 22:05:24 INFO mapred.JobClient: Combine input records=0
12/11/07 22:05:24 INFO mapred.JobClient: Map output records=7
12/11/07 22:05:24 INFO mapred.JobClient: Reduce input records=7
由上面的shell命令执行过程,在进行hadoop har文件归档的时候使用了MapReduce。需要注意的是:在创建archive文件后,源文件不会被更改或者删除。archive作为文件系统暴漏给外界。所以所有的fs shell命令都能在archive上运行,但是需要使用不同的URI。另外注意的是archive是不可改变的。所以重命名、删除和创建都会返回错误。
hadoop archive的URI是:
har://scheme-hostname:port/archivepath/fileinarchive。
如果想查看刚创建的归档文件,可以执行以下命令:
$ hadoop fs -lsr har:///tmp/geoway_portal.har
drw-r--r-- - Administrator supergroup 0 2012-11-07 22:05 /tmp/geoway_
portal.har/user
drw-r--r-- - Administrator supergroup 0 2012-11-07 22:05 /tmp/geoway_
portal.har/user/Administrator
drw-r--r-- - Administrator supergroup 0 2012-11-07 22:05 /tmp/geoway_
portal.har/user/Administrator/geoway_portal
-rw-r--r-- 10 Administrator supergroup 419438592 2012-11-07 22:05 /tmp/geoway_
portal.har/user/Administrator/geoway_portal/SDE.DBF
-rw-r--r-- 10 Administrator supergroup 54993818 2012-11-07 22:05 /tmp/geoway_
portal.har/user/Administrator/geoway_portal/likehua.zip
-rw-r--r-- 10 Administrator supergroup 6144 2012-11-07 22:05 /tmp/geoway_
portal.har/user/Administrator/geoway_portal/tes2.dmp
创建Hadoop 归档文件
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:http://www.heiqu.com/2a0fc45dc6939866b8d9d62fbe15d67f.html