zoukankan      html  css  js  c++  java
  • 熟悉常用的HDFS操作

    编程实现以下指定功能,并利用Hadoop提供的Shell命令完成相同任务:

    1. 在本地Linux文件系统的“/home/hadoop/”目录下创建一个文件txt,里面可以随意输入一些单词.
    cd /home/hadoop
    
    touch test.txt

              2. 在本地查看文件位置(ls)

    ./bin/hdfs dfs -ls

              3. 在本地显示文件内容

    cat test.txt
    
    ./bin/hdfs dfs -cat test.txt

              4. 使用命令把本地文件系统中的“txt”上传到HDFS中的当前用户目录的input目录下。

     ./sbin/start-dfs.sh
     ./bin/hdfs dfs -mkdir -p /user/hadoop
     ./bin/hdfs dfs -mkdir input
     ./bin/hdfs dfs -put ./test.txt input

              5. 查看hdfs中的文件(-ls)

    ./bin/hdfs dfs -ls
    
    ./bin/hdfs dfs -ls input

              6. 显示hdfs中该的文件内容

    ./bin/hdfs dfs -cat input/test.txt

              7. 删除本地的txt文件并查看目录

    cd /home/hadoop
    
    rm test.txt
    
    ls /home/hadoop

              8. 从hdfs中将txt下载地本地原来的位置。

    ./bin/hdfs dfs -get test.txt /home/hadoop

              9. 从hdfs中删除txt并查看目录

    ./bin/hdfs dfs -rm -ls input/test.txt
  • 相关阅读:
    Best code水题之路
    我的CodeF水A题之路
    studing(来自转载)
    BFS
    fibonacci数列(五种)
    Redis阻塞队列原理学习
    the enum hack
    Divide Two Integers
    Surrounded Regions
    Search in Rotated Sorted Array
  • 原文地址:https://www.cnblogs.com/wumeiying/p/8946744.html
Copyright © 2011-2022 走看看