错误org.apache.thrift.transport.TSaslTransport-SASL协商失败javax.security.sasl.SaslException:GSS启动失败

时间:2018-11-06 09:08:56

标签: java hive kerberos

尝试编写可与Kerberos一起使用的蜂巢客户端。

IDEA在Windows 2012 R2操作系统中可以正常运行, 我确实准备了包含Hadoop文件的文件夹(已从那里winutils复制到本地文件夹

c:\hadoop

设置环境后

  set HOME_HADOOP=c:\hadoop

然后写了这段代码

public static void main (String args[]) {
    try {
        org.apache.hadoop.conf.Configuration conf = new     org.apache.hadoop.conf.Configuration();
        conf.set("hadoop.security.authentication", "Kerberos");
        UserGroupInformation.setConfiguration(conf);
        UserGroupInformation.loginUserFromKeytab("testuser@DOM.COM", "C:\\Servers\\Repository\\Templates\\HiveClient\\src\\main\\resources\\testuser.keytab");
        Class.forName("org.apache.hive.jdbc.HiveDriver");
        System.out.println("getting connection");
        Connection con = DriverManager.getConnection("jdbc:hive2://rnd-server02:10010/default;principal=testuser@DOM.COM");
        System.out.println("Connected");
        con.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
}

尝试执行并返回错误

00:49:05.950 [main] ERROR org.apache.thrift.transport.TSaslTransport - SASL negotiation failure
javax.security.sasl.SaslException: GSS initiate failed
    at com.sun.security.sasl.gsskerb.GssKrb5Client.evaluateChallenge(GssKrb5Client.java:211) ~[?:1.8.0_121]
    at org.apache.thrift.transport.TSaslClientTransport.handleSaslStartMessage(TSaslClientTransport.java:94) ~[libthrift-0.9.3.jar:0.9.3]
    at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:271) [libthrift-0.9.3.jar:0.9.3]
    at 

如何解决这个问题?

0 个答案:

没有答案