Support Questions
Find answers, ask questions, and share your expertise

How to create user in hadoop?

How to create user in hadoop?

4 REPLIES 4

Explorer

Steps

  1. Connect to a host in the cluster that includes the HDFS client.
  2. Switch to the hdfs system account user. su - hdfs.
  3. Using the HDFS client, make an HDFS directory for the user. For example, if your username is admin, you would create the following directory. ...
  4. Set the ownership on the newly created directory

Super Mentor

@rinu shrivastav


Example: Suppose you want to create a new user "newuser1" on HDFS.

So first create a user on your Host (client machine) and add it to "hadoop" group

# useradd newuser1 -G hadoop

.

Create Home directory for this user on HDFS.

# su - hdfs -c "hdfs dfs -mkdir /user/newuser1"
# su - hdfs -c "hdfs dfs -chown newuser1:hadoop /user/newuser1"
# su - hdfs -c "hdfs dfs -chmod 755 /user/newuser1"

.

Now you can switch to this "newuser1" and then can work on hdfs like putting a file to HDFS.

# su - newuser1
# hdfs dfs -put /etc/passwd  /user/newuser1
# hdfs dfs -cat  /user/newuser1/passwd


Super Mentor

@rinu shrivastav

If you are using Ambari then it is more easy ... as soon as you create a user on HDFS it will automatically create the Home Directory for that user on HDFS and set the permission accordingly.

You can enable this feature via ambari as mentioned in the doc: https://docs.hortonworks.com/HDPDocuments/Ambari-2.6.2.0/bk_ambari-administration/content/create_use...

The users can be created using below steps:

a)Get the information from user as to which machine is he working from.

b)create the user in in OS first.

c)Create the user in Hadoop by creating his home folder /user/username in Hadoop

d)make sure that we have 777 permission for temp directory in HDFS

e)using chown command change ownership from Hadoop to user for only his home directory so that he can write into only his directory and not other users.

f)add his name into name node hdfs dfsadmin -refreshUserToGroupMappings

G)If needed set a space limit for the user to limit the amount of data stored by him.hdfs dfsadmin -setSpaceQuota 50g /user/username