hadoop-hdfs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Xiaohua Chen <xiaohua.c...@gmail.com>
Subject Kerberosed Hadoop HDFS
Date Mon, 29 Sep 2014 20:50:44 GMT
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 ){

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 ?



View raw message