使用 hadoop fs 和直接使用hdfs dfs 是一样的
且dfs中的很多命令同Linux 一致。
一、上传
# 1. 剪切
hadoop hdfs -moveFromLocal <localsrc>... <dst>
# localsrc是Linux下的路径
# dst是dfs中的路径
# 2. 复制
hadoop hdfs -copyFromLocal <localsrc>... <dst>
# 生产环境更多
hadoop hdfs -put [-f] [-p] [-l] [-d] <localsrc> ... <dst>
#Flags:
#-p Preserves access and modification times, ownership and the mode.
#-f Overwrites the destination if it already exists.
#-l Allow DataNode to lazily persist the file to disk. Forces
# replication factor of 1. This flag will result in reduced
# durability. Use with care.
#-d Skip creation of temporary file(<dst>._COPYING_).
# 3. 追加
-appendToFile <localsrc> ... <dst>
二、下载
# 复制
hadoop hdfs -copyToLocal <localsrc>... <dst>
# 生产环境更多
hadoop hdfs -get [-f] [-p] [-l] [-d] <localsrc> ... <dst>
三、直接操作hdfs
hadoop fs指令和linux本地指令中文件系统指令非常的相似。
setrep是hadoop fs独有的。PS:每个节点至多只能存储一个副本
当只有三台机器,但是设置了十个副本的话,实际只会存在三个副本。如果集群增加一个DataNode,副本数量会加一,直到十个。