gss initiate在尝试打开从java到hive的jdbc连接时失败

ws51t4hk  于 2021-05-29  发布在  Hadoop
关注(0)|答案(0)|浏览(769)

我正在尝试从java应用程序打开jdbc连接,在windows pc上运行时。
配置单元已安装在oracle linux服务器上。我正在使用kerberos进行安全身份验证。当keytab在linux服务器上运行时,我使用了keytab。它工作得很好。在创建连接之前,我在windows pc中获取keytab文件以用于创建票证。
我的java代码是

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.apache.hadoop.security.UserGroupInformation;

public class Ana {
    private static String driverName = "org.apache.hive.jdbc.HiveDriver";
    public static void main(String[] args) throws SQLException, IOException {
        try {
            org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration();
            conf.set("hadoop.security.authentication", "Kerberos");
            conf.set("hive.server2.authentication", "Kerberos");
            UserGroupInformation.setConfiguration(conf);
            UserGroupInformation.loginUserFromKeytab(
                    "neverwinter@FW.XXX.COM.TR", "C:\\Users\\neverwinter\\Documents\\calisan\\yeni2\\neverwinter.keytab");
            Class.forName(driverName);
        } catch ( ClassNotFoundException e ) {
            e.printStackTrace();
            System.exit(1);
        }
        Connection con = DriverManager
                .getConnection("jdbc:hive2://myHost:10000/TGAR;principal=hive/neverwinter@FW.XXX.COM.TR");
        Statement stmt = con.createStatement();
        String tableName = "newTable";
        stmt.execute("drop table if exists " + tableName);
        stmt.execute("create table " + tableName + " (key int, value string)");
    }
}

我的pom xml是

<dependency>
    <groupId>org.apache.hive</groupId>
    <artifactId>hive-jdbc</artifactId>
    <version>1.2.1</version>
            <exclusions>
            <exclusion>
            <groupId>jdk.tools</groupId>
            <artifactId>jdk.tools</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
      <groupId>org.apache.hive</groupId>
      <artifactId>hive-exec</artifactId>
      <version>0.13.0</version>
</dependency>
<dependency>
      <groupId>org.apache.hive</groupId>
      <artifactId>hive-jdbc</artifactId>
      <version>0.13.0</version>
</dependency>
<dependency>
      <groupId>org.apache.thrift</groupId>
      <artifactId>libthrift</artifactId>
      <version>0.9.0</version>
</dependency>
<dependency>
      <groupId>org.apache.thrift</groupId>
      <artifactId>libfb303</artifactId>
      <version>0.9.0</version>
</dependency>
<dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1.3</version>
</dependency>
<dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-client</artifactId>
      <version>2.6.0</version>
</dependency>

当行getconnection时,它抛出以下错误:
原因:org.apache.thrift.transport.ttTransportException:gss initiate在org.apache.thrift.transport.tsasltransport.sendAndRowMessage(tsasltransport)失败。java:221)在org.apache.thrift.transport.tsasltransport.open(tsasltransport。java:297)在org.apache.thrift.transport.tsaslclienttransport.open(tsaslclienttransport。java:37)在org.apache.hadoop.hive.thrift.client.tugiassumingtransport$1.run(tugiassumingtransport。java:52)在org.apache.hadoop.hive.thrift.client.tugiassumingtransport$1.run(tugiassumingtransport。java:49)位于javax.security.auth.subject.doas(未知源)的java.security.accesscontroller.doprivileged(本机方法)org.apache.hadoop.security.usergroupinformation.doas(用户组信息。java:1628)在org.apache.hadoop.hive.thrift.client.tugiassumingtransport.open(tugiassumingtransport。java:49)在org.apache.hive.jdbc.hiveconnection.opentransport(hiveconnection)上。java:203) ... 5个以上
jvm参数

-Djava.security.krb5.debug=true 
-Djava.security.krb5.conf="‪C:\Users\neverwinter\Desktop\krb5.conf"
-Djava.security.auth.login.config="C:\Users\neverwinter\Desktop\gss-jaas.conf"

我查了gss的资料,但对那个案子毫无帮助。我错过了什么?有什么好主意都行。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题