Support Questions
Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Innovation Accelerator group hub.

[Closed] : How to create user in HDFS

Contributor

I have read many documents and implements many solutions. I have made directory as `<user_name>` by following commands and gave ownership and permission to the folder as HDFS user.

[root@sandbox ~]# su hdfs
[hdfs@sandbox root]$ hdfs dfs -mkdir /user/tempuser
[hdfs@sandbox root]$ hdfs dfs -chown tempuser:hdfs /user/tempuser
[hdfs@sandbox root]$ hdfs dfs -chmod 700 /user/tempuser
[hdfs@sandbox root]$ su tempuser
su: user tempuser does not exist
[hdfs@sandbox root]$

But is throwing error as user <username> does not exist.
Please help me to resolve it.

Regards,

Jay.

1 ACCEPTED SOLUTION

Mentor

@JAy PaTel

The above code snippet is for creating a user's home directory in HDFS.

You will need to create the local Linux user, to do so a root or if you have sudo privileges do the following

# useradd  tempuser

To set the password, you will be prompted twice

# passwd tempuser 


Using sudo privileges

$ sudo useradd tempuser

See aabove

$ sudo  passwd tempuser

This will also create a user home on the local Linux box in /home/tempuser this is different from the hdfs user home /user/tempuser with MUST exst if the tempuser is to run and hive queries etc

Hope that helps

View solution in original post

7 REPLIES 7

Mentor

@JAy PaTel

The above code snippet is for creating a user's home directory in HDFS.

You will need to create the local Linux user, to do so a root or if you have sudo privileges do the following

# useradd  tempuser

To set the password, you will be prompted twice

# passwd tempuser 


Using sudo privileges

$ sudo useradd tempuser

See aabove

$ sudo  passwd tempuser

This will also create a user home on the local Linux box in /home/tempuser this is different from the hdfs user home /user/tempuser with MUST exst if the tempuser is to run and hive queries etc

Hope that helps

Contributor

@Geoffrey Shelton Okot

Is it for CentOS? Because I am using Hortonworks Sandbox on Oracle Virtual Machine.

Mentor

@JAy PaTel

Yes that okay the same commands will work

Contributor

Thank you @Geoffrey Shelton Okot It helps.

Actually, I was thinking it will create a user in CentOS only. But It has created a user in HDFS as well.

Explorer

I'm just curious. Why do hive jobs need the home directory to run the job?

Mentor

@Mokkan Mok

Hive jobs need a temporary working directory where hiveJars used during the execution are temporarily stored. See example

$ hdfs dfs -ls /user/hive
Found 3 items
drwx------   - hive hdfs          0 2018-04-25 20:00 /user/hive/.Trash
drwxr-xr-x   - hive hdfs          0 2018-04-13 23:04 /user/hive/.hiveJars
-rw-r--r--   3 hive hdfs        642 2018-05-24 08:43 /user/hive/derby.log
$ hdfs dfs -ls /user/hive/.hiveJars
Found 1 items
-rw-r--r--   3 hive hdfs   22006904 2018-04-13 23:04 /user/hive/.hiveJars/hive-exec-1.2.1000.2.6.2.0-205-79292bba9a3e076ad6d7a33c604b892fa0d45f6f60ae07a507e5e659a297f665.jar

Hope that helps explain

Mentor

@JAy PaTel

If you found this answer addressed your question, please take a moment to log in and click the "accept" link on the answer.