Hadoop

  • hadoop fs -ls -R /

  • 查看hadoop中所有文件

  • hadoop fs -rm /wordcount/input/asw.txt

  • 删除指定文件

  • hadoop fs -get /wordcount/input/asw.txt /root/

  • 下载文件到指定目录

  • hadoop fs -mv /wordcount/input/some.txt /wordcount/input/asw.txt

  • 为指定目录下的文件改名字

  • hadoop fs -cat /wordcount/input/ss.txt

  • 显示指定文件的内容

  • hadoop fs -put boot.sh /wordcount/input/

  • 将本地文件存放至hadoop上

  • hadoop fs -touchz /wordcount/input1

  • 在hadoop中指定位置下用touchz创建空文件

  • hadoop fs -mkdir /hff

  • 在hdfs中创建 hff目录

  • hadoop fs -mkdir -p /wordcount/input2

  • -p创建多级目录

  • hadoop dfs -rmr /hff

  • 删除HDFS下的 hff目录

  • hadoop fs -rm -R /tests

  • 删除文件夹

  • hadoop fs -cat /wordcount/output/part-r-00000

  • 查看所有数据

  • hadoop fs -cat /wordcount/input/test.txt

  • 查看指定文件的内容

  • Exception in thread “main” java.lang.UnsupportedClassVersionError: com/zhiyou/hadoop/mr/WordcountDriver : Unsupported major.minor version 52.0

  • jdk版本问题,保证版本一直即可

  • hadoop jar Wordcount.jar com.zhiyou.hadoop.mr.WordcountDriver /wordcount/input /wordcount/output2

(mapReduce程序封装在jar包中上传)在hadoop上运行封装好的MapReduce程序

HDFS

  • hdfs dfs -ls / 查看当前目录

  • hdfs dfs -lsr / 递归查看当前目录

  • hdfs dfs -mkdir /xxx/xxx 创建文件夹

  • hdfs dfs -touchz /xxx/xxx 创建文件

  • hdfs dfs –cp 原目录 目标目录

  • hdfs dfs -cp /file1 /xxx/ 复制文件

  • hdfs dfs -mv 原目录 目标目录 重命名

  • hdfs dfs –chmod 777 /xxx/xxx 赋予权限

  • hdfs dfs -put /test/* /xxx 上传test整个文件夹(含文件夹)

  • hdfs dfs -put /test /xxx 上传test整个文件夹(含文件夹)

  • hdfs dfs -copyFromLocal /test /xxx 作用同put

  • hdfs dfs -copyFromLocal /test /xxx 作用同put 但上传后会自动删除源文件

  • hdfs dfs -get 源文件夹 目标文件夹 下载文件

  • hdfs dfs -copyToLocal 源文件夹 目标文件夹 作用同get

  • hdfs dfs -moveToLocal 源文件夹 目标文件夹 get后删除源文件

  • hadoop fs -cat /xxx/file1 从头查看这个文件

  • hadoop fs -tail /xxx/file1 从尾部查看最后1K

  • hdfs dfs -rm /zhao/test.txt 删除test.txt文件

  • hdfs dfs –rm -R /xxx 递归删除xxxx文件夹