HDFS Commands and Operations
In this page, you’ll know about the HDFS operations and commands
In HDFS operations it consists of five types is:
i) Starting HDFS.
ii)Listing files in HDFS.
iii) Inserting Data into HDFS.
iv)Retrieving Data from HDFS.
v) Shutting down the HDFS.
Starting HDFS:
First, we need to format the configure HDFS data system and open namenode (HDFS server) then compile the given command.
$ hadoop namenode -format |
Once formatting the HDFS is done, it begins with the distributed file system. Then given command will start the name-node as well as the data nodes will work as a cluster.
$ start-dfs.sh |
Listing files in HDFS:
If the information is loaded on the server, we can see the list of files in a directory, status of a file, using ‘ls’. Given below is the syntax of ls that you can pass to a directory or a filename as an argument.
$ $HADOOP_/bin/hadoop fs -ls |
Inserting Data into HDFS:
Suppose we have data in the file called file.txt in the local system which is ought to be saved in the hdfs file system. Follow the steps given below to insert the required file in the Hadoop file system.
Step1: You can create an input directory.
$ $HADOOP_HOME/bin/hadoop fs -mkdir /user/input |
Step 2: Transfer and store a data file from local systems to the Hadoop file system utilizing the “put” command.
$ $HADOOP_HOME/bin/hadoop fs -put /home/file.txt /user/input |
Step 3: You can verify the file using “ls” command.
$ $HADOOP_HOME/bin/hadoop fs -ls /user/input |
Retrieving Data from HDFS:
Suppose if we produce a file in HDFS called outfile. Given below is an easy illustration for retrieving the specified file from the Hadoop file system.
Step 1: Initially, view the data from HDFS using cat command.
$ $HADOOP_HOME/bin/hadoop fs -cat /user/output/outfile |
Step 2: Get the file from HDFS to the local file system using get command.
$ $HADOOP_HOME/bin/hadoop fs -get /user/output/ /home/hadoop_tp/ |
Shutting Down the HDFS:
We can shut down the HDFS by using the following command.
$ stop-dfs.sh |
Arun Gandham
Author