Skip to main content

Hadoop and HDFS Commands Guide

Hadoop and HDFS Commands Guide

Start Hadoop

hdoop@hadoop:~$ start-all.sh

WARNING: Attempting to start all Apache Hadoop daemons as hdoop in 10 seconds.
WARNING: This is not a recommended production deployment configuration.
WARNING: Use CTRL-C to abort.
Starting namenodes on [localhost]
Starting datanodes
Starting secondary namenodes [hadoop]
WARNING: YARN_CONF_DIR has been replaced by HADOOP_CONF_DIR. Using value of YARN_CONF_DIR.
Starting resourcemanager
WARNING: YARN_CONF_DIR has been replaced by HADOOP_CONF_DIR. Using value of YARN_CONF_DIR.
Starting nodemanagers
WARNING: YARN_CONF_DIR has been replaced by HADOOP_CONF_DIR. Using value of YARN_CONF_DIR.
hdoop@hadoop:~$
    

Check Hadoop Service Running or Not

hdoop@hadoop:~$ jps

24294 ResourceManager
24087 SecondaryNameNode
23879 DataNode
23738 NameNode
24444 NodeManager
24989 Jps
hdoop@hadoop:~$
    

Check Hadoop Version

hdoop@hadoop:~$ hadoop version
Hadoop 3.2.1
Source code repository https://gitbox.apache.org/repos/asf/hadoop.git -r b3cbbb467e22ea829b3808f4b7b01d07e0bf3842
Compiled by rohithsharmaks on 2019-09-10T15:56Z
Compiled with protoc 2.5.0
From source with checksum 776eaf9eee9c0ffc370bcbc1888737
This command was run using /home/hdoop/hadoop-3.2.1/share/hadoop/common/hadoop-common-3.2.1.jar
hdoop@hadoop:~$
    

Check HDFS Health

hdoop@hadoop:~$ hdfs dfs -fsck /
    

Check Size of Directory/File

hdoop@hadoop:~$ hdfs dfs -du /demo
0  0  /demo/newfile.txt

hdoop@hadoop:~$ hdfs dfs -du -s /demo
0  0  /demo
    

Change to Sudo User

hdoop@hadoop:~$ sudo su
root@hadoop:/home/hdoop#
    

Change to Regular User

root@hadoop:/home/hdoop# su hdoop
hdoop@hadoop:~$
    

Super User Access

1. useradd 
2. userdel 
3. usermod 
4. usermod -l 
5. userrename 
    

Usage of -mkdir Command

hdoop@hadoop:~$ hdfs dfs -usage mkdir
Usage: hadoop fs [generic options] -mkdir [-p]  ...
    

List HDFS Commands

hdoop@hadoop:~$ hdfs dfs -help 
Usage: hadoop fs [generic options]
    

Show Files and Directories with Path

hdoop@hadoop:~$ hdfs dfs -ls /
Found 10 items
drwxr-xr-x   - hdoop  supergroup      	0 2022-08-26 18:52 /august_old
drwxr-xr-x   - hdoop  supergroup      	0 2022-02-21 10:03 /data2
-rw-r--r--   1 hdoop  supergroup     	57 2022-08-26 19:07 /input.txt
-rwxrwxrwx   1 Local Admin         	18 2022-02-21 09:36 /.txt
-rw-r--r--   1 hdoop  supergroup     	18 2022-08-26 18:55 /learnhdfs_cp.txt
drwxr-xr-x   - hdoop  supergroup      	0 2021-11-23 11:07 /test
drwxr-xr-x   - hdoop  supergroup      	0 2021-12-20 21:03 /testfile
-rwxrw-rw-   3 Local Admin         	6456 2021-11-27 09:32 /testfile.txt
drwxrwxrwx   - hdoop  supergroup      	0 2021-11-30 10:47 /tmp
drwxr-xr-x   - hdoop

Comments

Popular posts from this blog

10 Key Skills to Become a Data Engineer's

   If you’re aspiring to become a proficient data engineer, it can be daunting to know where to begin. This guide outlines ten essential skills that will set you on the right path. Start with the first topic and work your way through the list to build a solid foundation. 1. Master Linux Linux systems are the backbone of many applications, making it vital to understand how to navigate and manipulate them. Key concepts include:  File System Commands: Get comfortable with `ls`, `cd`, `pwd`, `mkdir`, and `rmdir`.  Metadata Commands: Use `head`, `tail`, `wc`, `grep`, `ls -lh` to glean information about your files.  Data Processing Commands: Master `awk` and `sed` for efficient data manipulation.  Bash Scripting: Learn control flow, looping, and passing input parameters for automation.  2. Proficiency in SQL SQL is essential for accessing and managing your data, whether for analysis or application use. Key areas to focus on are:  CRUD Operations: Under...