Skip to Content
Java数据科学实战
book

Java数据科学实战

by Michael R. Brzustowicz, PhD
January 2020
Intermediate to advanced
202 pages
5h 41m
Chinese
Posts & Telecom Press
Content preview from Java数据科学实战
162
|
第
6
章
bash$
hadoop fs <command> <args>
该命令是由前导连字符以及任意数目的标准
UNIX
文件系统命令组成的,例如
ls
、
cd
或
mkdir
。例如,为了列出
HDFS
根目录中的所有项,可以键入下述命令:
bash$
hadoop fs -ls /
注意,访问根目录时要加上斜杠
/
。如果没有加上斜杠,那么上述命令什么结果也不会返
回,这样会让你误以为自己的
HDFS
是空的。键入命令
hadoop fs
将打印出所有可用的文
件系统操作。一些更有用的操作包括:把数据复制到
HDFS
,或者把数据从
HDFS
复制到
其他地方;删除目录;在目录中合并数据。
把本地文件复制到
Hadoop
文件系统中的命令如下:
bash$
hadoop fs -copyFromLocal <localSrc> <dest>
把文件从
HDFS
复制到本地驱动器的命令如下:
bash$
hadoop fs -copyToLocal <hdfsSrc> <localDest>
运行
MapReduce
任务之后,在任务的输出目录中很可能有许多文件。用户不需要逐个获取
这些文件,
Hadoop
有个便利的操作,可以把这些文件合并为一个文件,然后把结果存储
在本地。
bash$
hadoop fs -getmerge <hdfs_output_dir> <my_local_dir>
如果
MapReduce
检测到输出目录已经存在,则几乎会马上导致
MapReduce
任务失败。因此,
运行
MapReduce
任务的一项必要操作是,如果输出目录已经存在,则首先要移除该目录。 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

云安全实用指南

云安全实用指南

Chris Dotson
Kafka权威指南

Kafka权威指南

Neha Narkhede, Gwen Shapira, Todd Palino

Publisher Resources

ISBN: 9787115533302