Exercise 03
Exercise 03
We will take a look at the most common file management tasks in Hadoop, which
include:
SYNTAX AND COMMANDS TO ADD, RETRIEVE AND DELETE DATA FROM HDFS
Before you can run Hadoop programs on data stored in HDFS, you‘ll need
to put the data into HDFS first. Let‘s create a directory and put a file in it. HDFS
has a default working directory of /user/$USER, where $USER is your login user
name. This directory isn‘t automatically created for you, though, so let‘s create it
with the mkdir command. For the purpose of illustration, we use chuck. You
should substitute your user name in the example commands.
hadoop fs -mkdir /user/chuck
hadoop fs -put example.txt
hadoop fs -put example.txt /user/chuck
Step-2 : Retrieving Files from HDFS
The Hadoop command get copies files from HDFS back to the local
filesystem. To retrieve example.txt, we can run the following command.
hadoop fs -cat example.txt
Copying from directory command is “hdfs dfs –copyFromLocal /home /lendi/ Desktop/ shakes/
glossary /lendicse/”
View the file by using the command “hdfs dfs –cat /lendi_english/glossary”
Command for listing of items in Hadoop is “hdfs dfs –ls hdfs://localhost:9000/”
Command for Deleting files is “hdfs dfs –rm r /kartheek”
EXPECTED OUTPUT:
Result: Thus the Installing of Hadoop in three operating modes has been successfully
completed