Database Reference
In-Depth Information
The Cp Command
The cp command can copy multiple sources to a destination. The sources and destination might be on HDFS or on
the local file system. If multiple sources are specified, the destination must be a directory:
[hadoop@hc1nn flume]$ hdfs dfs -ls /tmp/flume/agent*
Found 1 items
-rw-r--r-- 2 hadoop hadoop 1343 2014-07-26 20:09 /tmp/flume/agent1.cfg
Found 1 items
-rw-r--r-- 2 hadoop hadoop 1483 2014-07-26 20:09 /tmp/flume/agent1.cfg.nl
[hadoop@hc1nn flume]$ hdfs dfs -cp /tmp/flume/agent1.cfg /tmp/flume/agent2.cfg
[hadoop@hc1nn flume]$ hdfs dfs -ls /tmp/flume/agent*
Found 1 items
-rw-r--r-- 2 hadoop hadoop 1343 2014-07-26 20:09 /tmp/flume/agent1.cfg
Found 1 items
-rw-r--r-- 2 hadoop hadoop 1483 2014-07-26 20:09 /tmp/flume/agent1.cfg.nl
Found 1 items
-rw-r--r-- 2 hadoop hadoop 1343 2014-07-26 20:19 /tmp/flume/agent2.cfg
This example shows that an HDFS-based file agent1.cfg is being copied to another HDFS-based file agent2.cfg.
The Get Command
The get command copies HDFS-based files to the local Linux file system. The get command is similar to
copyToLocal , except that copyToLocal must copy to a local Linux file system based file.
[hadoop@hc1nn tmp]$ hdfs dfs -get /tmp/flume/agent2.cfg
[hadoop@hc1nn tmp]$ ls -l ./agent2.cfg
-rwxr-xr-x. 1 hadoop hadoop 1343 Jul 26 20:23 ./agent2.cfg
This example copies the HDFS-based file agent2.cfg to the local Linux directory (“.”).
The Put Command
The put command copies a single file or multiple source files and writes them to a destination. This command
can also read from STDIN (the input file stream). The put command is similar to copyFromLocal , except that
copyFromLocal must copy from a local Linux file system based file.
[hadoop@hc1nn tmp]$ ps -ef | hdfs dfs -put - /tmp/ps/list.txt
[hadoop@hc1nn tmp]$ hdfs dfs -cat /tmp/ps/list.txt | head -10
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 13:48 ? 00:00:01 /sbin/init
root 2 0 0 13:48 ? 00:00:00 [kthreadd]
root 3 2 0 13:48 ? 00:00:00 [migration/0]
root 4 2 0 13:48 ? 00:00:03 [ksoftirqd/0]
 
Search WWH ::




Custom Search