0

我正在尝试通过 Simba JDBC(Databricks 推荐方式)从 PERL 代码连接 Spark Databricks。对于参考,这是 JDBC 驱动程序:https ://databricks-bi-artifacts.s3.us-east-2.amazonaws.com/simbaspark -drivers/jdbc/2.6.17/SimbaSparkJDBC42-2.6.17.1021.zip

到目前为止,我设法设置了 PERL 和所有与 PERL 相关的模块配置,下面的问题与我坚信的 PERL 无关。

我有下面的代码试图连接 Spark Databricks。注意:密码中的“replaceme”是databricks 个人访问令牌。

#!/usr/bin/perl

use strict;
use DBI;

my $user = "token";
my $pass = "replaceme";
my $host = "DBhost.azuredatabricks.net";
my $port = 9001;
my $url = "jdbc:spark://DBhost.azuredatabricks.net:443/default;transportMode=http;ssl=1;httpPath=sql/protocolv1/o/853imaskedthis14/1005-imaskedthis-okra138;AuthMech=3;UID=token;PWD=replaceme";  # Get this URL from JDBC data src

my %properties = ('user' => $user, 
                  'password' => $pass, 
                  'host.name' => $host, 
                  'host.port' => $port);

my $dsn = "dbi:JDBC:hostname=localhost;port=$port;url=$url";
my $dbh = DBI->connect($dsn, undef, undef, 
          { PrintError => 0, RaiseError => 1, jdbc_properties => \%properties })
          or die "Failed to connect: ($DBI::err) $DBI::errstr\n";
my $sql = qq/select * from table/;
my $sth = $dbh->prepare($sql);
$sth->execute();
my @row;
while (@row = $sth->fetchrow_array) {
 print join(", ", @row), "\n";
}

我以 SIMBA 驱动程序连接到 SPARK THRIFT 服务器作为身份验证问题结束了以下问题和错误。

failed: [Simba][SparkJDBCDriver](500164) Error initialized or created transport for authentication: Invalid status 21
Also, could not send response: com.simba.spark.jdbc42.internal.apache.thrift.transport.TTransportException: java.net.SocketException: Broken pipe (Write failed). at ./perldatabricksconntest.pl line 18.

记录器记录在 Java 堆栈跟踪下方:

[Thread-1] 05:40:16,718 WARN  - Error
java.sql.SQLException: [Simba][SparkJDBCDriver](500164) Error initialized or created transport for authentication: Invalid status 21
Also, could not send response: com.simba.spark.jdbc42.internal.apache.thrift.transport.TTransportException: java.net.SocketException: Broken pipe (Write failed).
        at com.simba.spark.hivecommon.api.HiveServer2ClientFactory.createTransport(Unknown Source)
        at com.simba.spark.hivecommon.api.ServiceDiscoveryFactory.createClient(Unknown Source)
        at com.simba.spark.hivecommon.core.HiveJDBCCommonConnection.establishConnection(Unknown Source)
        at com.simba.spark.spark.core.SparkJDBCConnection.establishConnection(Unknown Source)
        at com.simba.spark.jdbc.core.LoginTimeoutConnection.connect(Unknown Source)
        at com.simba.spark.jdbc.common.BaseConnectionFactory.doConnect(Unknown Source)
        at com.simba.spark.jdbc.common.AbstractDriver.connect(Unknown Source)
        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:189)
        at com.vizdom.dbd.jdbc.Connection.handleRequest(Connection.java:417)
        at com.vizdom.dbd.jdbc.Connection.run(Connection.java:211)
Caused by: com.simba.spark.support.exceptions.GeneralException: [Simba][SparkJDBCDriver](500164) Error initialized or created transport for authentication: Invalid status 21
Also, could not send response: com.simba.spark.jdbc42.internal.apache.thrift.transport.TTransportException: java.net.SocketException: Broken pipe (Write failed).
        ... 11 more

另外根据 SIMBA JDBC 连接器文档,我尝试了 NO 身份验证模式,用户名、用户名/密码都没有工作。

所以想知道传输层中的身份验证问题在哪里。注意我已经创建了令牌,并在启动 jdbc:spark call 时在密码部分提到了这一点。

在此处输入图像描述

4

1 回答 1

1

您需要生成个人访问令牌并将其而不是replaceme字符串放在 JDBC url 中吗?user之后,您无需password%properties.

于 2021-04-29T17:25:36.560 回答