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 ../ : ...
随机推荐
- magento启用SSL改http成https
Magento是电子商务网站,对于网站的用户信息安全来说,让Magento使用SSL连接是一个很好的解决方案.如果在页面的边栏或者底部放上些表明本站使用安全连接的图片,显得更专业,让客户有安全感,对于 ...
- CentOS 6.6 FTP install
/************************************************************************* * CentOS 6.6 FTP install ...
- xcrun: error: active developer path ("/Volumes/Xcode/Xcode6-Beta.app/Contents/Developer") does not exist, use xcode-select to change
When using MacOS with xcode6.4, i always meet these error: xcrun: error: active developer path (&quo ...
- Install Oracle Java JDK/JRE 7u55 on Fedora 20/19, CentOS/RHEL 6.5/5.10
What’s new in Sun/Oracle Java 7 VM Compressed 64-bit object pointers Garbage-First GC (G1) JSR 292: ...
- 硬盘缓存的最佳方案,DiskLruCache完全解析
收藏自:http://blog.csdn.net/guolin_blog/article/details/28863651
- ZOJ 1115 Digital Roots
原题链接 题目大意:给一个数字,每一位相加求和,不断重复过程,直到剩一位数字. 解法:考虑到输入的数字可以很大,把输入按照字符串格式读入,再逐位处理. 参考代码: #include <iostr ...
- php部分--例子:租房子(复选框的全选、数组拼接成字符串、设置复选框的name值、)
1.链接数据库 <?php include("DBDA.class.php"); $db=new DBDA(); $sql="select * from fangz ...
- Java动物声音模拟器
abstract class Animal{ abstract void cry(); abstract String getAnimalName(); } class Simulator{ void ...
- leetcode 93 Restore IP Addresses ----- java
Given a string containing only digits, restore it by returning all possible valid IP address combina ...
- Fortran编译多个文件(转载)
最近需要在Linux系统下编译多个Fortran程序,在网上搜索了一下,但是资料不多,也许因为这个问题比较简单,不值一提,但还是把我知道的写出来,供大家参考: 方法一: 假如现在有两个Fortran程 ...