Database Reference
In-Depth Information
Tutorial Links
Oftentimes you'll be interacting with HDFS through other tools like Hive (described here ) or
Pig (described here ) . That said, there will be times when you want to work directly with
HDFS; Yahoo! has published an excellent guide for configuring and exploring a basic sys-
tem.
Example Code
When you use the command-line interface (CLI) from a Hadoop client, you can copy a file
from your local filesystem to the HDFS and then look at the first 10 lines with the following
code snippet:
[hadoop@client-host ~]$ hadoop fs -ls /data
Found 4 items
drwxr-xr-x - hadoop supergroup 0 2012-07-12 08:55 /data/faa
-rw-r--r-- 1 hadoop supergroup 100 2012-08-02 13:29
/data/sample.txt
drwxr-xr-x - hadoop supergroup 0 2012-08-09 19:19 /data/wc
drwxr-xr-x - hadoop supergroup 0 2012-09-11 11:14 /data/weblogs
[hadoop@client-host ~]$ hadoop fs -ls /data/weblogs/
[hadoop@client-host ~]$ hadoop fs -mkdir /data/weblogs/in
[hadoop@client-host ~]$ hadoop fs -copyFromLocal
weblogs_Aug_2008.ORIG /data/weblogs/in
[hadoop@client-host ~]$ hadoop fs -ls /data/weblogs/in
Found 1 items
-rw-r--r-- 1 hadoop supergroup 9000 2012-09-11 11:15
/data/weblogs/in/weblogs_Aug_2008.ORIG
[hadoop@client-host ~]$ hadoop fs -cat
/data/weblogs/in/weblogs_Aug_2008.ORIG \
| head
10.254.0.51 - - [29/Aug/2008:12:29:13 -0700] "GGGG / HTTP/1.1"
200 1456
10.254.0.52 - - [29/Aug/2008:12:29:13 -0700] "GET / HTTP/1.1"
200 1456
10.254.0.53 - - [29/Aug/2008:12:29:13 -0700] "GET /apache_pb.gif
HTTP/1.1" 200 2326
10.254.0.54 - - [29/Aug/2008:12:29:13 -0700] "GET /favicon.ico
Search WWH ::




Custom Search