在hdfs目录中,创建/test目录
[root@Master current]# hadoop fs -mkdir /test
查看ls命令
[root@Master current]# hadoop fs -ls /test
在本地生成一个文件
[root@Master dfs]# ifconfig >> /1.txt
将本地文件复制到hdfs的/test(等价于copyFromLocal)
[root@Master dfs]# hadoop fs -put /1.txt /test
查看hdfs下的/test下是否有1.txt文件
[root@Master dfs]# hadoop fs -ls /test
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:11 /test/1.txt
将hdfs下的/test目录下的文件复制到2.txt下(等价于copyToLocal)
[root@Master current]# hadoop fs -get /test/1.txt /2.txt
清空回收站
[root@Master current]# hadoop fs -expunge
16/03/27 19:32:51 INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 0 minutes, Emptier interval = 0 minutes.
查看hdfs下文件的大小
[root@Master current]# hadoop fs -dus /test/1.txt
961 /test/1.txt
将2.txt文件上传到/test下
[root@Master current]# hadoop fs -put /2.txt /test
查看是否上传成功
[root@Master current]# hadoop fs -ls /test
Found 2 items
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:11 /test/1.txt
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:38 /test/2.txt
[root@Master current]#
验证/test下的文件的大小
[root@Master current]# hadoop fs -du /test
961 /test/1.txt
961 /test/2.txt
复制文件
[root@Master current]# hadoop fs -cp /test/1.txt /test/3.txt
验证复制成功
[root@Master current]# hadoop fs -ls /test
Found 3 items
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:11 /test/1.txt
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:38 /test/2.txt
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:42 /test/3.txt
[root@Master current]#
查看文件的内容
[root@Master current]# hadoop fs -cat /test/1.txt
Java HotSpot(TM) Server VM warning: You have loaded library
eth0 Link encap:Ethernet HWaddr 00:0C:29:D0:F1:C7
inet addr:10.114.51.132 Bcast:10.114.51.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fed0:f1c7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1600321 errors:3 dropped:3 overruns:0 frame:0
TX packets:1222043 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:799233372 (762.2 MiB) TX bytes:1029831155 (982.1 MiB)
Interrupt:19 Base address:0x2000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:53162 errors:0 dropped:0 overruns:0 frame:0
TX packets:53162 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5155687 (4.9 MiB) TX bytes:5155687 (4.9 MiB)
[root@Master current]#
创建一个二级目录
[root@Master current]# hadoop fs -mkdir /test/2016/
查看/test目录
[root@Master current]# hadoop fs -lsr /test
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:11 /test/1.txt
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:38 /test/2.txt
drwxr-xr-x - root supergroup 0 2016-03-27 19:47 /test/2016
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:42 /test/3.txt
复制1.txt到/test/2016/目录下
[root@Master current]# hadoop fs -cp /test/1.txt /test/2016/
递归列举
[root@Master current]# hadoop fs -lsr /test
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:11 /test/1.txt
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:38 /test/2.txt
drwxr-xr-x - root supergroup 0 2016-03-27 19:48 /test/2016
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:48 /test/2016/1.txt
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:42 /test/3.txt
[root@Master current]#
[root@Master current]# hadoop fs -mkdir /test
查看ls命令
[root@Master current]# hadoop fs -ls /test
在本地生成一个文件
[root@Master dfs]# ifconfig >> /1.txt
将本地文件复制到hdfs的/test(等价于copyFromLocal)
[root@Master dfs]# hadoop fs -put /1.txt /test
查看hdfs下的/test下是否有1.txt文件
[root@Master dfs]# hadoop fs -ls /test
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:11 /test/1.txt
将hdfs下的/test目录下的文件复制到2.txt下(等价于copyToLocal)
[root@Master current]# hadoop fs -get /test/1.txt /2.txt
清空回收站
[root@Master current]# hadoop fs -expunge
16/03/27 19:32:51 INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 0 minutes, Emptier interval = 0 minutes.
查看hdfs下文件的大小
[root@Master current]# hadoop fs -dus /test/1.txt
961 /test/1.txt
将2.txt文件上传到/test下
[root@Master current]# hadoop fs -put /2.txt /test
查看是否上传成功
[root@Master current]# hadoop fs -ls /test
Found 2 items
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:11 /test/1.txt
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:38 /test/2.txt
[root@Master current]#
验证/test下的文件的大小
[root@Master current]# hadoop fs -du /test
961 /test/1.txt
961 /test/2.txt
复制文件
[root@Master current]# hadoop fs -cp /test/1.txt /test/3.txt
验证复制成功
[root@Master current]# hadoop fs -ls /test
Found 3 items
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:11 /test/1.txt
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:38 /test/2.txt
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:42 /test/3.txt
[root@Master current]#
查看文件的内容
[root@Master current]# hadoop fs -cat /test/1.txt
Java HotSpot(TM) Server VM warning: You have loaded library
eth0 Link encap:Ethernet HWaddr 00:0C:29:D0:F1:C7
inet addr:10.114.51.132 Bcast:10.114.51.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fed0:f1c7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1600321 errors:3 dropped:3 overruns:0 frame:0
TX packets:1222043 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:799233372 (762.2 MiB) TX bytes:1029831155 (982.1 MiB)
Interrupt:19 Base address:0x2000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:53162 errors:0 dropped:0 overruns:0 frame:0
TX packets:53162 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5155687 (4.9 MiB) TX bytes:5155687 (4.9 MiB)
[root@Master current]#
创建一个二级目录
[root@Master current]# hadoop fs -mkdir /test/2016/
查看/test目录
[root@Master current]# hadoop fs -lsr /test
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:11 /test/1.txt
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:38 /test/2.txt
drwxr-xr-x - root supergroup 0 2016-03-27 19:47 /test/2016
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:42 /test/3.txt
复制1.txt到/test/2016/目录下
[root@Master current]# hadoop fs -cp /test/1.txt /test/2016/
递归列举
[root@Master current]# hadoop fs -lsr /test
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:11 /test/1.txt
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:38 /test/2.txt
drwxr-xr-x - root supergroup 0 2016-03-27 19:48 /test/2016
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:48 /test/2016/1.txt
-rw-r--r-- 3 root supergroup 961 2016-03-27 19:42 /test/3.txt
[root@Master current]#