Time for action – using HDFS
As the preceding example shows, there is a familiar-looking interface to HDFS that allows us to use commands similar to those in Unix to manipulate files and directories on the filesystem. Let's try it out by typing the following commands:
Type in the following commands:
$ hadoop -mkdir /user $ hadoop -mkdir /user/hadoop $ hadoop fs -ls /user Found 1 items drwxr-xr-x - hadoop supergroup 0 2012-10-26 23:09 /user/Hadoop $ echo "This is a test." >> test.txt $ cat test.txt This is a test. $ hadoop dfs -copyFromLocal test.txt . $ hadoop dfs -ls Found 1 items -rw-r--r-- 1 hadoop supergroup 16 2012-10-26 23:19/user/hadoop/test.txt $ hadoop dfs -cat test.txt This is a test. $ rm test.txt $ hadoop dfs -cat test.txt This is a test. $ hadoop fs -copyToLocal test.txt $ cat test.txt This is a test.
What just happened?
This example shows the use of the fs
subcommand to the Hadoop utility. Note that both dfs
and fs
commands are equivalent). Like...