Hadoop 文件系统的操作
hadoop 操作
语法
hadoop fs -[linux 命令]
hdfs fs -[linux 命令]
查看根路径目录
hadoop fs -ls /
创建 test 目录
hadoop fs -mkdir /test
查看根/test 目录
hadoop fs -ls /test
上传文件
hadoop fs -put [本地目录或者文件] [hdfs 文件系统的目录]
hadoop fs -put hello.txt /test
查看文件
hadoop fs -cat [hdfs 文件系统的文件]
hadoop fs -cat /test/hello.txt
删除文件
hadoop fs -rm -r [hdfs 文件系统的文件]
删除目录
hadoop fs -rmdir [hdfs 文件系统的目录]
hadoop jar xxx.jar [程序名] [输入的目录或者文档] [输出的目录]
例子:hadoop 里跑一些 MR 程序
启动 start-dfs.sh
启动 start-yarn.sh
1.新建立一个 words.txt 写一些单词
hello john
hello tom
hello amy
hello tim
hello tom
2.上传文件到 hadoop
hadoop fs –mkdir –p /word/input
hadoop fs –put words.txt /word/input
3.执行下面的程
hadoop jar /opt/apps/hadoop/share/hadoop/mapreduce(此处不换行)
/hadoop-mapreduce-examples-2.8.3.jar wordcount /word/input /word/out
4.查看输出
hadoop fs -cat /word/out/part-r-00000
本文档详细介绍了Hadoop文件系统的常用操作,包括使用hadoopfs和hdfsfs命令进行目录创建、文件上传、查看、删除等。通过实例演示了如何上传文件、执行MapReduce任务并查看输出结果。这些步骤对于理解和使用Hadoop生态系统至关重要。

被折叠的 条评论
为什么被折叠?



