HDFS

  • hdfs的命令行使用

    hdfs  dfs   -ls  /
    
    //递归执行
    hdfs  dfs -lsr 
    
    //-p 递归
    hdfs  dfs -mkdir -p 
    
    //从本地文件系统拷贝到目标文件系统中
    hdfs dfs -put  /rooot/a.txt  /dir1
    
    //和put命令类似,但是拷贝后自身被删除
    hdfs  dfs -moveFromLocal  /root/install.log  /
    
    //将文件拷贝到本地文件系统
    hdfs dfs  -get   /install.log  /export/servers
    
    //不能跨文件系统
    hdfs  dfs  -mv  /dir1/a.txt   /dir2
    
    hdfs  dfs  -rm  -r  /dir1
    
    hdfs dfs -cp /dir1/a.txt  /dir2/b.txt
    
    hdfs dfs  -cat /install.log
    
    hdfs dfs -chmod -R 777 /install.log
    
    hdfs  dfs  -chown  -R hadoop:hadoop  /install.log
    
    //追加一个或多个文件到hdfs指定文件中
    hdfs dfs -appendToFile  a.xml b.xml  /big.xml
    
  • hdfs文件限额配置

    hdfs dfs -count -q -h /user/root/dir1  #查看配额信息
     
    hdfs dfs  -mkdir -p /user/root/dir    #创建hdfs文件夹
    hdfs dfsadmin -setQuota 2  dir      # 给该文件夹下面设置最多上传两个文件,发现只能上传一个文件
    hdfs dfsadmin -clrQuota /user/root/dir  # 清除文件数量限制
    
    hdfs dfsadmin -setSpaceQuota 4k /user/root/dir   # 限制空间大小4KB
    hdfs dfsadmin -clrSpaceQuota /user/root/dir
    
  • 安全模式操作命令

    hdfs  dfsadmin  -safemode  get #查看安全模式状态
    hdfs  dfsadmin  -safemode  enter #进入安全模式
    hdfs  dfsadmin  -safemode  leave #离开安全模式
    
上一篇:HDFS写文件流程


下一篇:024.hive-hive查询表、查询表的格式(内部表还是外部表、表的存储格式)