hadoop hdfs dfs基本操作


1、查询
使用命令:
hdfs dfs -ls / 这条执行会列出/目录下的文件和目录
hdfs dfs -ls -R /这条会列出/目录下的左右文件,由于有-R参数,会在文件夹和子文件夹下执行ls

 
2、添加文件夹
使用命令;
hdfs dfs -mkdir -p  /data/collection
 
/xytest/testdata001/
 
这里需要注意的是,root用户是否拥有hdfs 的权限,如果有,我们可以继续操作,如果没有,我们可以直接使用hdfs用户,默认安装完cdh后,用户hdfs拥有所有的权限。如果对于权限有不明白的,推荐看一下我的另一篇文章:
http://blog.csdn.net/wild46cat/article/details/69664376

 
 
3、增加文件
使用命令:
hdfs dfs -copyFromLocal ~/123.txt /xytest/testdata001/

 
 
4、查看hdfs文件中的内容
使用命令:
hdfs dfs -cat /xytest/testdata001/123.txt

 
 
或者,可以把hdfs中的文件copy到本地
使用命令:
hdfs dfs -copyToLocal  /xytest/testdata001/123.txt ~/222.txt

 
 
5、删除文件
使用命令:
hdfs dfs -rm -f /cloudera/spark/application.log

 
 
6、删除文件夹
使用命令:
hdfs dfs -rm -r /cloudera/spark

 
 
 
 
spark.eventLog.dir = /user/spark/applicationHistory
spark.eventLog.enabled =ture
 

发布了29 篇原创文章 · 获赞 3 · 访问量 9495

猜你喜欢

转载自blog.csdn.net/chshgod1/article/details/85075581