2

I am trying create a directory with the below commands:

  1. hadoop fs -mkdir sample

  2. hadoop fs -mkdir /user/cloudera/sample1

Either way i receive the error:

Could not find or load main class fs

How do I resolve this issue?

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Ramya B
  • 21
  • 1
  • 1
  • 2
  • What happens if you execute: `hadoop version`? – Serhiy Feb 01 '17 at 15:17
  • the version of hadoop is displayed.. hadoop 2.6.0-cdh5.8.0 – Ramya B Feb 01 '17 at 17:23
  • 1
    Have you tried using `hadoop dfs` ? – Serhiy Feb 01 '17 at 18:48
  • This is the result : DEPRECATED: Use of this script to execute hdfs command is deprecated. Instead use the hdfs command for it. mkdir: Cannot create directory /user/cloudera/sample. Name node is in safe mode. – Ramya B Feb 02 '17 at 05:09
  • Even i tried to leave the safemode by using "hadoop dfsadmin -safemode leave". This is the issue --> DEPRECATED: Use of this script to execute hdfs command is deprecated. Instead use the hdfs command for it. safemode: Access denied for user cloudera. Superuser privilege is required – Ramya B Feb 02 '17 at 05:13
  • Issue resolved by giving : sudo su - hdfs and then hadoop dfsadmin -safemode leave.. i was able to run the commands – Ramya B Feb 03 '17 at 11:44
  • 1
    Post it as an answer then and accept it yourself. Maybe someone will face the same issue and your answer will help em :) – Serhiy Feb 03 '17 at 11:46

2 Answers2

4

These two Stack Overflow posts illustrate that the hadoop fs and hadoop dfs commands are deprecated and have been for some time.

Ideally you should be using hdfs dfs instead. As Ramya B states, you need to become the hdfs user in order to use this type of command and ensure that safe mode is turned off. If you have Ambari, you can easily access the NameNode UI to check that this isn't the case.

Usage:

hdfs dfs -mkdir [hdfs location]

I would assume that the reason you're getting an error is because hadoop fs is no longer a command you can use to execute filesystem changes on HDFS.

Community
  • 1
  • 1
Fredulom
  • 908
  • 1
  • 10
  • 23
0

First give sudo su - hdfs and give hadoop dfsadmin -safemode leave Then user can run the commands

Ramya B
  • 21
  • 1
  • 1
  • 2