hadoop(五): shell命令
hdfs dfs
- -cat URI : 查看文件内容
- hdfs dfs -cat hdfs dfs -cat hdfs://mycluster/user/root/rcc1
- hdfs dfs -cat file:///usr/hdp/2.4.2.0-258/hadoop/bin/rcc
- -ls <args>: 查文件列表
- 返回格式:permissions number_of_replicas userid groupid filesize modification_date modification_time filename
[root@hdp2 ~]# hdfs dfs -ls
Found items
drwx------ - root hdfs -- : .Trash
drwxr-xr-x - root hdfs -- : .hiveJars
-rw-r--r-- root hdfs -- : mapred
-rw-r--r-- root hdfs -- : rcc1
- -mkdir <paths> : 创建目录
- The behavior is much like unix mkdir -p creating parent directories along the path
[root@hdp2 ~]# hdfs dfs -ls
Found items
drwx------ - root hdfs -- : .Trash
drwxr-xr-x - root hdfs -- : .hiveJars
-rw-r--r-- root hdfs -- : mapred
-rw-r--r-- root hdfs -- : rcc1
[root@hdp2 ~]# hdfs dfs -mkdir hdfs://mycluster/user/root/zhu
[root@hdp2 ~]# hdfs dfs -ls
Found items
drwx------ - root hdfs -- : .Trash
drwxr-xr-x - root hdfs -- : .hiveJars
-rw-r--r-- root hdfs -- : mapred
-rw-r--r-- root hdfs -- : rcc1
drwxr-xr-x - root hdfs -- : zhu - -copyFromLocal <localsrc> URI: 上传文件,类似于put
- -put <localsrc> ... <dst>
[root@hdp2 ~]# hdfs dfs -ls /user/root/zhu
[root@hdp2 ~]# hdfs dfs -put /usr/zhu/a1.png /user/root/zhu
[root@hdp2 ~]# hdfs dfs -copyFormLocal /usr/zhu/a2.png /user/root/zhu
-copyFormLocal: Unknown command
[root@hdp2 ~]# hdfs dfs -copyFromLocal /usr/zhu/a2.png /user/root/zhu
[root@hdp2 ~]# hdfs dfs -ls /user/root/zhu
Found items
-rw-r--r-- root hdfs -- : /user/root/zhu/a1.png
-rw-r--r-- root hdfs -- : /user/root/zhu/a2.png
[root@hdp2 ~]#
- -copyToLocal [-ignorecrc] [-crc] URI <localdst> : 下载到本地
- -get [-ignorecrc] [-crc] <src> <localdst>
[root@hdp2 ~]# clear
[root@hdp2 ~]# hdfs dfs -ls /user/root/zhu
Found items
-rw-r--r-- root hdfs -- : /user/root/zhu/a1.png
-rw-r--r-- root hdfs -- : /user/root/zhu/a2.png
[root@hdp2 ~]# hdfs dfs -copyToLocal hdfs://mycluster/user/root/zhu/a1.png /usr/zhu/tmp
[root@hdp2 ~]# hdfs dfs -get /usr/root/zhu/a2.png /usr/zhu/tmp
get: `/usr/root/zhu/a2.png': No such file or directory
[root@hdp2 ~]# hdfs dfs -get /user/root/zhu/a2.png /usr/zhu/tmp
[root@hdp2 ~]# cd /usr/zhu/tmp
[root@hdp2 tmp]# ll
total
-rw-r--r-- root root Sep : a1.png
-rw-r--r-- root root Sep : a2.png
[root@hdp2 tmp]#
- -count [-q] <paths> :统计
- The output columns with -count are: DIR_COUNT, FILE_COUNT, CONTENT_SIZE FILE_NAME
- The output columns with -q are: QUOTA, REMAINING_QUATA, SPACE_QUOTA, REMAINING_SPACE_QUOTA
[root@hdp2 tmp]# hdfs dfs -count /user/root/zhu
/user/root/zhu
[root@hdp2 tmp]# hdfs dfs -count -q /user/root/zhu
none inf none inf /user/root/zhu
[root@hdp2 tmp]# - -du [-s] [-h] URI [URI …]: 统计大小
- The -s option will result in an aggregate summary of file lengths being displayed, rather than the individual file
- The -h option will format file sizes in a "human-readable" fashion (e.g 64.0m instead of 67108864)
[root@hdp2 tmp]# hdfs dfs -du -h /user/root/zhu
84.9 K /user/root/zhu/a1.png
54.5 K /user/root/zhu/a2.png
[root@hdp2 tmp]#
- -rm -r [-skipTrash] URI [URI …]
- -r: Recursive version of delete
[root@hdp2 tmp]# hdfs dfs -ls /user/root/zhu
Found items
-rw-r--r-- root hdfs -- : /user/root/zhu/a1.png
[root@hdp2 tmp]# hdfs dfs -rm -r /user/root/zhu
// :: INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = minutes, Emptier interval = minutes.
Moved: 'hdfs://mycluster/user/root/zhu' to trash at: hdfs://mycluster/user/root/.Trash/Current
[root@hdp2 tmp]# hdfs dfs -ls /user/root/zhu
ls: `/user/root/zhu': No such file or directory
[root@hdp2 tmp]#
- -touchz URI [URI …]
- Create a file of zero length
[root@hdp2 tmp]# hdfs dfs -ls
Found items
drwx------ - root hdfs -- : .Trash
drwxr-xr-x - root hdfs -- : .hiveJars
-rw-r--r-- root hdfs -- : mapred
-rw-r--r-- root hdfs -- : rcc1
[root@hdp2 tmp]# hdfs dfs -touchz a.txt
[root@hdp2 tmp]# hdfs dfs -ls
Found items
drwx------ - root hdfs -- : .Trash
drwxr-xr-x - root hdfs -- : .hiveJars
-rw-r--r-- root hdfs -- : a.txt
-rw-r--r-- root hdfs -- : mapred
-rw-r--r-- root hdfs -- : rcc1
[root@hdp2 tmp]# hdfs dfs -cat /user/root/a.txt
[root@hdp2 tmp]#
- 小结:
- 本质就是linux文件操作命令
hadoop(五): shell命令的更多相关文章
- 【转】Hadoop FS Shell命令
FS Shell 调用文件系统(FS)Shell命令应使用 bin/hadoop fs <args> 的形式. 所有的的FS shell命令使用URI路径作为参数.URI格式是scheme ...
- hadoop入门:hadoop使用shell命令总结
第一部分:Hadoop Bin后面根据项目的实际需要Hadoop Bin 包括:Hadoop hadoop的Shellhadoop-config.sh 它的作用是对一些变量进行赋值 HAD ...
- Hadoop常见shell命令
Hadoop中常见的shell命令 1.如何将Linux本地的数据上传到HDFS中? hadoop fs -put 本地的文件 HDFS中的目录hdfs dfs -put 本地的文件 HDFS中的目录 ...
- hadoop(五)scp命令copy文件和配置(完全分布式准备二)|7
机器的克隆参考centos7克隆ip|机器名|映射关系|别名配置(hadoop完全分布式准备一) 那么问题来了,如果我们有30台机器,之间可以互相访问,那我们如何快速安装配置环境如jdk hadoop ...
- Hadoop Shell命令字典(可收藏)
可以带着下面问题来阅读: 1.chmod与chown的区别是什麽?2.cat将路径指定文件的内容输出到哪里?3.cp能否是不同之间复制?4.hdfs如何查看文件大小?5.hdfs如何合并文件?6.如何 ...
- Hadoop Shell命令字典
转载自:https://www.aboutyun.com//forum.php/?mod=viewthread&tid=6983&extra=page%3D1&page=1&a ...
- Hadoop Shell命令大全
hadoop支持命令行操作HDFS文件系统,并且支持shell-like命令与HDFS文件系统交互,对于大多数程序猿/媛来说,shell-like命令行操作都是比较熟悉的,其实这也是Hadoop的极大 ...
- Hadoop学习记录(2)|HDFS shell命令|体系结构
HDFS的shell 调用文件系统(FS)shell命令使用hadoop fs的形式 所有的FS shell命令使用URI路径作为参数. URI格式是scheme://authority/path.H ...
- 部分linux系统命令(shell 命令)和hadoop命令
linux系统命令(shell 命令): ls : 只列出文件/目录 ls -l : 会显示文件的详情,如大小等 ls -lh : 会显示文件的详情,但大小以k或者M为单位 ls ../ : ...
随机推荐
- 使用Inno Setup 打包.NET程序,并自动安装.Net Framework
使用Inno Setup 打包.NET程序,并自动安装.Net Framework http://www.cnblogs.com/xiaogangqq123/archive/2012/03/19/24 ...
- 多线程编程4 - GCD
一.简介 在iOS所有实现多线程的方案中,GCD应该是最有魅力的,因为GCD本身是苹果公司为多核的并行运算提出的解决方案.GCD在工作时会自动利用更多的处理器核心,以充分利用更强大的机器.GCD是Gr ...
- caffe编译关于imread问题的解决
change Makefile: LIBRARIES += glog gflags protobuf leveldb snappy \ lmdb boost_system hdf5_hl hdf5 m ...
- LeetCode Binary Tree Paths(简单题)
题意: 给出一个二叉树,输出根到所有叶子节点的路径. 思路: 直接DFS一次,只需要判断是否到达了叶子,是就收集答案. /** * Definition for a binary tree node. ...
- 长方形—C++
编程之美一道简单的热身题,活生生的组合数学例子啊. 题意如下: 在 N 条水平线与 M 条竖直线构成的网格中,放 K 枚石子,每个石子都只能放在网格的交叉点上.问在最优的摆放方式下,最多能找到多少四边 ...
- 关于项目中用到的流程的sql和表
select * from FLOW_MAIN SEQCODE FULL_NAME SHORT_NAME FLOW_DESC CREATE_TIME UPDATE_TIME 1 CoursePackF ...
- 199. Binary Tree Right Side View
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nod ...
- AttributeError: 'NoneType' object has no attribute 'bytes' python3.4 win64
解决方法: easy_install -U pip 详见: https://github.com/pypa/pip/issues/2669
- URAL 1077 Travelling Tours(统计无向图中环的数目)
Travelling Tours Time limit: 1.0 secondMemory limit: 64 MB There are N cities numbered from 1 to N ( ...
- ABB机器人添加串口模块后无法使用的解决办法
[环境] ABB机器人1520,IRC5,RobotWare5.6,Win10 64bits,RobotStudio6.0 [过程和表现] 由于项目需要和机器人通信,DeviceNet又不能满足要求, ...