当前位置: 首页 > 知识库问答 >
问题:

连接到cloudera impala环境时发生Kerberos错误

曹和正
2023-03-14

连接到kerberized hadoop环境时错误:[Simba]ImpalaJdbcDriver无法连接到服务器:[Simba]ImpalaJdbcDriver Kerberos身份验证失败。

我已经在virtualbox中安装了cloudera quickstart vm,启用了kerberos,编写了连接到imapala db的java代码,并得到了kerberos身份验证失败的错误。

public static void main(String[] args) throws Exception {

        Configuration conf = new Configuration();
        conf.set("hadoop.security.authentication", "Kerberos");
        UserGroupInformation.setConfiguration(conf);
        UserGroupInformation ugi = UserGroupInformation
                .loginUserFromKeytabAndReturnUGI("hdfs/quickstart.cloudera@CLOUDERA", "hdfs.keytab");

        Class.forName("com.cloudera.impala.jdbc41.Driver");
        Connection conn = (Connection) ugi.doAs(new PrivilegedExceptionAction<Object>() {
            public Object run() {
                Connection tcon = null;
                try {
                    tcon = DriverManager.getConnection(
                            "jdbc:impala://quickstart.cloudera:21050;AuthMech=1;KrbHostFQDN=quickstart.cloudera;KrbRealm=CLOUDERA;KrbServiceName=hdfs");
                    System.out.println("Connected!");
                } catch (SQLException e) {
                    e.printStackTrace();
                }
                return tcon;
            }
        });

        Statement stmt = conn.createStatement();

        String sql = "show tables";
        System.out.println("Running: " + sql);
        ResultSet res = stmt.executeQuery(sql);
        while (res.next()) {
            System.out.println(res.getString(1));
        }
    }

我已启用调试模式,我得到的异常:


    ...
    Client Principal = hdfs/quickstart.cloudera@CLOUDERA
    Server Principal = hdfs/quickstart.cloudera@CLOUDERA
    Session Key = EncryptionKey: keyType=23 keyBytes (hex dump)=
    0000: 8A B3 79 07 A5 06 05 9F   CE 37 84 8A 15 2E 7E B5  ..y......7......


    Forwardable Ticket true
    Forwarded Ticket false
    Proxiable Ticket false
    Proxy Ticket false
    Postdated Ticket false
    Renewable Ticket false
    Initial Ticket false
    Auth Time = Sun Jun 23 11:52:03 PDT 2019
    Start Time = Sun Jun 23 11:52:03 PDT 2019
    End Time = Mon Jun 24 11:52:03 PDT 2019
    Renew Till = null
    Client Addresses  Null 
    >>> KrbApReq: APOptions are 00100000 00000000 00000000 00000000
    >>> EType: sun.security.krb5.internal.crypto.ArcFourHmacEType
    Krb5Context setting mySeqNumber to: 925793988
    Created InitSecContextToken:
    0000: 01 00 6E 82 02 2E 30 82   02 2A A0 03 02 01 05 A1  ..n...0..*......

    0220: 4A 3E 74 0A 67 B6 5E 16   3B B8 1D FB 91 75 53 33  J>t.g.^.;....uS3
    0230: 76 5E 40 81                                        v^@.

    java.sql.SQLException: [Simba][ImpalaJDBCDriver](500164) Error initialized or created transport for authentication: [Simba][ImpalaJDBCDriver](500169) Unable to connect to server: [Simba][ImpalaJDBCDriver](500591) Kerberos Authentication failed..
        at com.cloudera.hivecommon.api.HiveServer2ClientFactory.createTransport(Unknown Source)
        at com.cloudera.hivecommon.api.HiveServer2ClientFactory.createClient(Unknown Source)
        at com.cloudera.hivecommon.core.HiveJDBCCommonConnection.establishConnection(Unknown Source)
        at com.cloudera.impala.core.ImpalaJDBCConnection.establishConnection(Unknown Source)
        at com.cloudera.jdbc.core.LoginTimeoutConnection.connect(Unknown Source)
        at com.cloudera.jdbc.common.BaseConnectionFactory.doConnect(Unknown Source)
        at com.cloudera.jdbc.common.AbstractDriver.connect(Unknown Source)
        at java.sql.DriverManager.getConnection(DriverManager.java:571)
        at java.sql.DriverManager.getConnection(DriverManager.java:233)
        at ImpalaJDBC$1.run(ImpalaJDBC.java:64)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:415)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1917)
    Caused by: com.cloudera.support.exceptions.GeneralException: [Simba][ImpalaJDBCDriver](500164) Error initialized or created transport for authentication: [Simba][ImpalaJDBCDriver](500169) Unable to connect to server: [Simba][ImpalaJDBCDriver](500591) Kerberos Authentication failed..
        ... 13 more
    Caused by: java.lang.RuntimeException: [Simba][ImpalaJDBCDriver](500169) Unable to connect to server: [Simba][ImpalaJDBCDriver](500591) Kerberos Authentication failed.
        at com.cloudera.hivecommon.api.HiveServerPrivilegedAction.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:356)
        at com.cloudera.hivecommon.api.HiveServer2ClientFactory.createTransport(Unknown Source)
        at com.cloudera.hivecommon.api.HiveServer2ClientFactory.createClient(Unknown Source)
        at com.cloudera.hivecommon.core.HiveJDBCCommonConnection.establishConnection(Unknown Source)
        at com.cloudera.impala.core.ImpalaJDBCConnection.establishConnection(Unknown Source)
        at com.cloudera.jdbc.core.LoginTimeoutConnection.connect(Unknown Source)
        at com.cloudera.jdbc.common.BaseConnectionFactory.doConnect(Unknown Source)
        at com.cloudera.jdbc.common.AbstractDriver.connect(Unknown Source)
        at java.sql.DriverManager.getConnection(DriverManager.java:571)
        at java.sql.DriverManager.getConnection(DriverManager.java:233)
        at ImpalaJDBC$1.run(ImpalaJDBC.java:64)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:415)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1917)
        at ImpalaJDBC.main(ImpalaJDBC.java:60)
    Caused by: org.apache.thrift.transport.TTransportException
        at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:132)
        at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84)
        at org.apache.thrift.transport.TSaslTransport.receiveSaslMessage(TSaslTransport.java:178)
        at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:258)
        at org.apache.thrift.transport.TSaslClientTransport.open(TSaslClientTransport.java:37)
        ... 17 more

共有1个答案

松铭
2023-03-14

在Impala重新启动后,我的web项目遇到了同样的问题。将连接池设置为在空闲时释放所有连接,并让下一个查询重新申请连接。这时,就不会出现这个问题了。

 类似资料:
  • 问题内容: 在Windows上安装了Docker,并额外安装了2个Oracle VM VirualBox和Kitematic。我在Windows 10 PC中禁用了Hyper-V。现在的问题是我无法从DockerHub下载任何Docker映像,甚至我都无法以如下方式运行命令 两端都显示以下错误。 尝试连接时发生错误:获取 http:// localhost:2375 / v1.21 / info

  • 我是的新手,遇到以下错误。 运行以下代码时会出现此错误(可在GitHub中获得:https://github.com/ddraj/hbase-trunk-mttr/blob/master/hbase-examples/src/main/java/org/apache/hadoop/hbase/mapreduce/sampleuploader.java) 我正在使用CDH5.2.6 我可以像这样获得

  • 我创建了一个扩展DriverManagerDataSource的SecureImpalaDataSource类,并使用< code > user group information . doas()用keytab文件连接到impala。但是我得到的错误如下: java.sql.SQLException:[Simba]ImpalaJDBCDriver为身份验证初始化或创建传输时出错:[Simba]I

  • 更新时间:2019-08-31 11:22:33 服务分为生产环境与开发环境,未发布的服务认为是在开发环境,发布后的服务为生产环境的服务。生产环境的服务才可以在web工作台,或代码工程内调用。生产环境的服务不可再进行修改,需要在开发环境中修改部署发布服务后,才可生效。 服务运维监控功能是为生产环境的服务提供的,您可以在此查看生产环境服务的调用量及运行日志。

  • 我对docker和mysql有一个问题(我对docker很陌生),我正在尝试将Symfony3.4与docker一起使用。 我有这个错误: 在AbstractMysqldriver.php第103行中: 驱动程序中发生异常:SQLSTATE[HY000][2002]PHP_NETWORK_GETADDRE SSS:getaddrinfo失败:名称未解析 在pdoConnection.php第47行

  • 问题内容: 有一个类似的问题,但尚未解决: W /CameraBase:连接相机时发生错误:camera.open()调用为0 我有一个(自然)正在使用相机的应用程序。它一直很好。但是,如果在构建之间没有代码更改,则应用程序开始崩溃(通过Git提交历史记录验证没有代码更改)。 为了进一步验证问题是否出在硬件中,我在另一部手机上运行了相同的代码,并且工作正常。相机以某种方式被锁定,无法打开。 以下是