Hi,all:
     recently,I  attempted to access Kerberized hadoop cluster by launching 
JAVA applications from Windows workstations. And I hava configured kerberos in 
my windows7, and can successfully access hdfs50070. But when I launch JDBC from 
windows to connection remote hiveserver,errors accured:
java.sql.SQLException:could not open client transport with JDBC 
Uri:jdbc:hive2://hm:10000/default;principal=hive/h...@hadoom.com: GSS initiate 
failed
     at 
org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:231)
     at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:176)
     at org.apache.hive.jdbc.HiveDriver.connection(HiveDriver.java:105)
     at java.sql.DriverManager.getConnection(Unknown Source)
     at java.sql.DriverManager.getConnection(Unknown Source)
     at 
org.apache.hadoop.hive.ql.security.authorization.plugin.KerberosTest.main(KerberosTest.java:41)
Caused by: org.apache.thrift.transport.TTransportException:GSS initiate failed
     at 
org.apache.thrift.transport.TSaslTransport.sendAndThrowMessage(TSaslTransport.java:232)
     at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:316)
     at 
org.apache.thrift.transport.TSaslClientTransport.open(TSaslClientTransport.java:37)
     at 
org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport$1.run(TUGIAssumingTransport.java:52)
     at 
org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport$1.run(TUGIAssumingTransport.java:49)
     at java.security.AccessController.doPrivileged(Native Method)
     at javax.security.auth.Subject.doAs(Unknow source)
     at 
org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628)
     at  
org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport.open(TUGIAssumingTransport.java:49)
     at 
org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:204)
... 5 more 
------------------------------------------------------------------------------
below are my test codes:

public static void main(String[] args) {
    String principal = "hive/h...@hadoom.com"; 
    String keytab = "E:\\Program Files 
(x86)\\java\\jre7\\lib\\security\\hive.keytab";
    String url = "jdbc:hive2://hm:10000/default;principal=hive/h...@hadoom.com";

    conf.addResource(new File("hdfs-site.xml").toURI().toURL());
    conf.addResource(new File("core-site.xml").toURI().toURL());
    conf.addResource(new File("yarn-site.xml").toURI().toURL());
    conf.addResource(new File("hive-site.xml").toURI().toURL());
    
    conf.set("hadoop.security.authentication", "Kerberos");
    UserGroupInformation.setConfiguration(conf); 
    UserGroupInformation.loginUserFromKeytab(principal, keytab);

    Class.forName("org.apache.hive.,jdbc.HiveDriver");
    Connection conn =DriverManager.getConnection(url);

    Statement stmt = conn.createStatement();
    String sql = "select * from testkerberos";
    ResultSet rs = stmt.executeQuery(sql);
    while (rs.next()) {
       system.out.println(rs.getString(1));
    }
} 

Does anyone had the same problem? Or know how to solve it ?

Thanks in advance.

Maria.

Reply via email to