zoukankan      html  css  js  c++  java
  • hadoop常见shell命令

    • 常见命令:

      # 将本地/myfield/a.txt文件上传到linux01的hdfs中。
      hdfs dfg -put /myfield/a.txt hdfs://linux01:9000/
      

    hadoop常用操作命令

    注意:需先配置环境变量

    • 列出根目录下所有目录或文件

      hdfs dfs -ls /
      
    • 列出/myfield目录下的所有目录和文件

      hdfs dfs -ls /myfield
      
    • 列出/myfield目录下的所有目录下的所有子文件

      hdfs dfs -ls -R /myfield
      
    • 创建/test目录

      hdfs dfs -mkdir /test
      
    • 创建多级目录

      hdfs dfs -mkdir -p /test/apps/demo1
      
    • 将本地文件/mnt/1.txt上传到 /test目录下

      hdfs dfs -put /mnt/1.txt  /test
      
    • 下载1.txt文件到本地

      hdfs dfs -get /test/1.txt
      
    • 将 /test/1.txt文件拷贝到本地

      hdfs dfs -copyToLocal /test/1.txt
      
    • 将word.txt文件拷贝到/test/apps目录下

      hdfs dfs -copyFromLocal word.txt /test/apps
      
    • 将word.txt文件从本地移动到 /myfield 目录下

      hdfs dfs -moveFromLocal word.txt /myfield
      
    • 将/myfield/word.txt 拷贝一份为 /myfield/word.txt.bak

      hdfs dfs -cp /myfield/word.txt /myfield/word.txt.bak
      
    • 将目录下的子目录或文件都拷贝到/logs目录(如果此目录不存在会创建)下

      hdfs dfs -cp /test/ /logs
      
    • 将/1.txt文件重命名为/2.txt

      hdfs dfs -mv /1.txt /2.txt
      
    • 将/words.txt文件移动到/myfield/目录下

      hdfs dfs -mv /2.txt /myfield/
      
    • 将/logs目录以及子目录和文件都删除

      hdfs dfs -rm -r /logs
      
    • 删除以 “xbs-”开头的目录及其子目录

      hdfs dfs -rm -r /xbs-*
      
    • 将/test/1.txt文件删除

      hdfs dfs -rm /test/1.txt
      
    • 将/test/目录下面的所有文件都删除 (是文件不是文件夹)

      hdfs dfs -rm /test/*
      
    • 查看HDFS集群的磁盘空间使用情况

      hdfs dfs -df -h
      
    • 获取/test_hdp.txt文件内容

      hdfs dfs -cat /test_hdp.txt
      
    • 将/field_test/f1.txt 文件中内容添加到 test_hdp.txt文件中

      hdfs dfs -appendToFile /field_test/f1.txt /test_hdp.txt
      
    • 动态查看/field_test/f1.txt文件的内容

      hdfs dfs -tail -f /field_test/f1.txt
      
    • 统计/myfield目录总大小

      hdfs dfs -du -s -h /myfield
      或
      hdfs dfs -du -h /myfield
      
      
    • 分别统计/test目录下各个子目录(或文件)大小

      hdfs dfs -du -s -h /test/*
      
    • 查看hdfs集群状态

      hdfs dfsadmin -report
      
    • 清空回收站

      hdfs dfs -expunge
      
    • 修改 /test_hdp.txt文件权限

      hdfs dfs -chmod 777 /test_hdp.txt
      
    • 进入安全模式

      hdfs dfsadmin -safemode enter
      
    • 离开安全模式

      hdfs dfsadmin -safemode leave
      
  • 相关阅读:
    Flink资料(5) -- Job和调度
    Flink资料(4) -- 类型抽取和序列化
    Flink资料(3)-- Flink一般架构和处理模型
    Flink资料(2)-- 数据流容错机制
    Flink资料(1)-- Flink基础概念(Basic Concept)
    联系InfoSphere Streams和OpenMI时对水利模型联系的设计模式的一些考虑
    [Azure][CLI][02]Basic OPS
    [Azure][PowerShell][ARM][01]Connect
    [Azure][PowerShell][ASM][13]Reset Password
    [Azure][PowerShell][ASM][12]ACL
  • 原文地址:https://www.cnblogs.com/xujunkai/p/13920185.html
Copyright © 2011-2022 走看看