失效链接处理 |
大数据技术之Hadoop(HDFS) PDF 下载
本站整理下载:
相关截图:
主要内容:
第2章 HDFS的Shell操作(开发重点)
2.1 基本语法
bin/hadoop fs 具体命令 OR bin/hdfs dfs 具体命令
两个是完全相同的。
2.2 命令大全
[lxx@hadoop102 hadoop-3.1.3]$ bin/hadoop fs
[-appendToFile <localsrc> ... <dst>]
[-cat [-ignoreCrc] <src> ...]
[-checksum <src> ...]
[-chgrp [-R] GROUP PATH...]
[-chmod [-R] <MODE[,MODE]... | OCTALMODE> PATH...]
[-chown [-R] [OWNER][:[GROUP]] PATH...]
[-copyFromLocal [-f] [-p] <localsrc> ... <dst>]
[-copyToLocal [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]
[-count [-q] <path> ...]
[-cp [-f] [-p] <src> ... <dst>]
[-createSnapshot <snapshotDir> [<snapshotName>]]
[-deleteSnapshot <snapshotDir> <snapshotName>]
[-df [-h] [<path> ...]]
[-du [-s] [-h] <path> ...]
[-expunge]
[-get [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]
[-getfacl [-R] <path>]
[-getmerge [-nl] <src> <localdst>]
[-help [cmd ...]]
[-ls [-d] [-h] [-R] [<path> ...]]
[-mkdir [-p] <path> ...]
[-moveFromLocal <localsrc> ... <dst>]
[-moveToLocal <src> <localdst>]
[-mv <src> ... <dst>]
[-put [-f] [-p] <localsrc> ... <dst>]
[-renameSnapshot <snapshotDir> <oldName> <newName>]
[-rm [-f] [-r|-R] [-skipTrash] <src> ...]
[-rmdir [--ignore-fail-on-non-empty] <dir> ...]
[-setfacl [-R] [{-b|-k} {-m|-x <acl_spec>} <path>]|[--set <acl_spec> <path>]]
[-setrep [-R] [-w] <rep> <path> ...]
[-stat [format] <path> ...]
[-tail [-f] <file>]
[-test -[defsz] <path>]
[-text [-ignoreCrc] <src> ...]
[-touchz <path> ...]
[-usage [cmd ...]]
2.3 常用命令实操
2.3.1 准备工作
1)启动Hadoop集群(方便后续的测试)
[lxx@hadoop102 hadoop-3.1.3]$ sbin/start-dfs.sh
[lxx@hadoop103 hadoop-3.1.3]$ sbin/start-yarn.sh
2)-help:输出这个命令参数
[lxx@hadoop102 hadoop-3.1.3]$ hadoop fs -help rm
2.3.2 上传
1)-moveFromLocal:从本地剪切粘贴到HDFS
[lxx@hadoop102 hadoop-3.1.3]$ touch kongming.txt
[lxx@hadoop102 hadoop-3.1.3]$ hadoop fs -moveFromLocal ./kongming.txt /sanguo/shuguo
2)-copyFromLocal:从本地文件系统中拷贝文件到HDFS路径去
[lxx@hadoop102 hadoop-3.1.3]$ hadoop fs -copyFromLocal README.txt /
3)-appendToFile:追加一个文件到已经存在的文件末尾
[lxx@hadoop102 hadoop-3.1.3]$ touch liubei.txt
[lxx@hadoop102 hadoop-3.1.3]$ vi liubei.txt
输入
san gu mao lu
[lxx@hadoop102 hadoop-3.1.3]$ hadoop fs -appendToFile liubei.txt /sanguo/shuguo/kongming.txt
4)-put:等同于copyFromLocal
[lxx@hadoop102 hadoop-3.1.3]$ hadoop fs -put ./zaiyiqi.txt /user/lxx/test/
2.3.3 下载
1)-copyToLocal:从HDFS拷贝到本地
[lxx@hadoop102 hadoop-3.1.3]$ hadoop fs -copyToLocal /sanguo/shuguo/kongming.txt ./
2)-get:等同于copyToLocal,就是从HDFS下载文件到本地
[lxx@hadoop102 hadoop-3.1.3]$ hadoop fs -get /sanguo/shuguo/kongming.txt ./
3)-getmerge:合并下载多个文件,比如HDFS的目录 /user/lxx/test下有多个文件:log.1, log.2,log.3,...
[lxx@hadoop102 hadoop-3.1.3]$ hadoop fs -getmerge /user/lxx/test/* ./zaiyiqi.txt
|