You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-user@hadoop.apache.org by Xiaohua Chen <xi...@gmail.com> on 2014/09/29 22:50:44 UTC

Kerberosed Hadoop HDFS

Hi Experts:

I write the following java program to access Kerberosed Hadoop File system:
-----------------------------------------------
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FileStatus;
import java.net.URI;


public class HDFSExample {
  public static void main(String[] args) throws Exception{
    Path path = new Path("/user/sochen");
    if ( args.length == 1){
      path = new Path(args[0]);
    }
    Configuration conf = new Configuration();
    System.out.println("fs.defaultFS = " + conf.get("fs.defaultFS"));
    URI uri = new URI("hdfs://my.namenode.com:8020");
    FileSystem fs = FileSystem.get(uri, conf);
    System.out.println("List of files in " + path);
    FileStatus [] files = fs.listStatus(path);
    for (FileStatus file : files ){
      System.out.println(file.getPath().getName());
    }
  }
}
------------------------------------------------------

It work fine as long as I issued kinit for  my principal "sochen"
(which is also my current linux login account user name).

But if I changed one line above from: FileSystem fs =
FileSystem.get(uri, conf); to FileSystem fs = FileSystem.get(uri,
conf, "sochen"), I will hit below error:
14/09/29 13:47:32 ERROR security.UserGroupInformation:
PriviledgedActionException as:sochen (auth:SIMPLE)
cause:javax.security.sasl.SaslException: GSS initiate failed [Caused
by GSSException: No valid credentials provided (Mechanism level:
Failed to find any Kerberos tgt)]

What I want to do  is: to specify a username "sochen"  to explicitly
to get a FileSystem, but underneath hadoop changed the authentication
mode to "SIMPLE"  , why ?
Then how can I  get a FileSystem based on a login user ?

Thanks.

Sophia