大数据:hdfs操作命令手册

这里使用的hadoop版本是3.1.2

一些概念

使用hdfs和使用linux文件系统是相似的,这里列举出常用的几个命令。

在使用hdfs之前,我们必须对namenode进行格式化,这个步骤在部署伪分布式的时候已经执行过了

hdfs namenode -format

创建用户目录,进入hdfs时,默认目录就是/user/是linux用户名称。当执行hdfs dfs -ls默认输出的是/user/下的内容

hdfs dfs -mkdir /user
hdfs dfs -mkdir /user/

使用适合的文件uri方案,按列出根目录文件作为例子

1)使用dfs,hadoop dfs -ls hdfs://[host:port]/

2)使用本地文件系统,hadoop dfs -ls file:///

 

常用的操作命令

1)删除文件/目录

hdfs dfs -rm -r [name]

 

附录:hdfs dfs 列出所有的命令

Usage: hadoop fs [generic options]
	[-appendToFile  ... ]
	[-cat [-ignoreCrc]  ...]
	[-checksum  ...]
	[-chgrp [-R] GROUP PATH...]
	[-chmod [-R]  PATH...]
	[-chown [-R] [OWNER][:[GROUP]] PATH...]
	[-copyFromLocal [-f] [-p] [-l] [-d] [-t ]  ... ]
	[-copyToLocal [-f] [-p] [-ignoreCrc] [-crc]  ... ]
	[-count [-q] [-h] [-v] [-t []] [-u] [-x] [-e]  ...]
	[-cp [-f] [-p | -p[topax]] [-d]  ... ]
	[-createSnapshot  []]
	[-deleteSnapshot  ]
	[-df [-h] [ ...]]
	[-du [-s] [-h] [-v] [-x]  ...]
	[-expunge]
	[-find  ...  ...]
	[-get [-f] [-p] [-ignoreCrc] [-crc]  ... ]
	[-getfacl [-R] ]
	[-getfattr [-R] {-n name | -d} [-e en] ]
	[-getmerge [-nl] [-skip-empty-file]  ]
	[-head ]
	[-help [cmd ...]]
	[-ls [-C] [-d] [-h] [-q] [-R] [-t] [-S] [-r] [-u] [-e] [ ...]]
	[-mkdir [-p]  ...]
	[-moveFromLocal  ... ]
	[-moveToLocal  ]
	[-mv  ... ]
	[-put [-f] [-p] [-l] [-d]  ... ]
	[-renameSnapshot   ]
	[-rm [-f] [-r|-R] [-skipTrash] [-safely]  ...]
	[-rmdir [--ignore-fail-on-non-empty]  ...]
	[-setfacl [-R] [{-b|-k} {-m|-x } ]|[--set  ]]
	[-setfattr {-n name [-v value] | -x name} ]
	[-setrep [-R] [-w]   ...]
	[-stat [format]  ...]
	[-tail [-f] ]
	[-test -[defsz] ]
	[-text [-ignoreCrc]  ...]
	[-touch [-a] [-m] [-t TIMESTAMP ] [-c]  ...]
	[-touchz  ...]
	[-truncate [-w]   ...]
	[-usage [cmd ...]]

 

你可能感兴趣的:(大数据处理)