Impala JDBC连接在集群模式下运行SPARK作业时的异常下方。Spark Job创建了Hive Table,并且使用JDBC进行Impala Table无效/刷新。同一工作在Spark客户端模式下成功执行。
java.sql.SQLException: [Simba][ImpalaJDBCDriver](500164) Error initialized or created transport for authentication: [Simba][ImpalaJDBCDriver](500169) Unable to connect to server: GSS initiate failed. at om.cloudera.hivecommon.api.HiveServer2ClientFactory.createTransport(Unknown Source)
at com.cloudera.hivecommon.api.HiveServer2ClientFactory.createClient(Unknown Source)
at com.cloudera.hivecommon.core.HiveJDBCCommonConnection.connect(Unknown Source)
at com.cloudera.impala.core.ImpalaJDBCConnection.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:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
protected def getImpalaConnection(impalaJdbcDriver: String, impalaJdbcUrl: String): Connection = {
if (impalaJdbcDriver.length() == 0) return null
try {
Class.forName(impalaJdbcDriver).newInstance
UserGroupInformation.getLoginUser.doAs(
new PrivilegedAction[Connection] {
override def run(): Connection = DriverManager.getConnection(impalaJdbcUrl)
}
)
} catch {
case e: Exception => {
println(e.toString() + " --> " + e.getStackTraceString)
throw e
}
} }
val impalaJdbcDriver = "com.cloudera.impala.jdbc41.Driver"
val impalaJdbcUrl = "jdbc:impala://<Impala_Host>:21050/default;AuthMech=1;SSL=1;KrbRealm=HOST.COM;KrbHostFQDN=_HOST;KrbServiceName=impala;REQUEST_POOL=xyz"
println("Start impala connection")
val impalaConnection = getImpalaConnection(impalaJdbcDriver,impalaJdbcUrl)
val result = impalaConnection.createStatement.executeQuery(s"SELECT COUNT(1) FROM testTable")
println("End impala connection")
建立厚罐,并在下面使用给定的Spark提交命令。您可以传递其他参数,例如文件,如有需要。
火花提交命令:
spark-submit --master yarn-cluster --keytab /home/testuser/testuser.keytab --principal testuser@host.COM --queue xyz--class com.dim.UpdateImpala
按照您的Spark版本进行更改
spark1:usergroupinformation.getLoginuser
for spark2:usergroupinformation.getCurrentuser