我正在尝试从Spark应用程序连接到Hive-metastore,但是每次它陷入尝试连接并因超时而崩溃的情况下:
INFO metastore:376 - Trying to connect to metastore with URI thrift://hive-metastore:9083
WARN metastore:444 - set_ugi() not successful, Likely cause: new client talking to old server. Continuing without it.
org.apache.thrift.transport.TTransportException: java.net.SocketTimeoutException: Read timed out
应用程序在我创建外部Hive表的那一行崩溃
我在Kubernetes集群中运行Hive-metastore以及Spark应用程序(使用Spark K8s运算符)。我使用telnet(节点ip:服务节点端口)检查了群集外部Hive-metastore服务的可访问性,并将服务卷曲在群集内部,该服务似乎是可评估的。该错误的原因可能是什么?
这是Spark应用程序中Hive-metastore uri的配置
val sparkSession = SparkSession
.builder()
.config(sparkConf)
.config("hive.metastore.uris", "thrift://hive-metastore:9083")
.config("hive.exec.dynamic.partition", "true")
.config("hive.exec.dynamic.partition.mode", "nonstrict")
.enableHiveSupport()
.getOrCreate()
Hive-metastore yaml配置如下:
apiVersion: v1
kind: Service
metadata:
name: hive-metastore-np
spec:
selector:
app: hive-metastore
ports:
- protocol: TCP
targetPort: 9083
port: 9083
nodePort: 32083
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: hive-metastore
spec:
replicas: 1
selector:
matchLabels:
app: hive-metastore
template:
metadata:
labels:
app: hive-metastore
spec:
containers:
- name: hive-metastore
image: mozdata/docker-hive-metastore:1.2.1
imagePullPolicy: Always
env:
- name: DB_URI
value: postgresql
- name: DB_USER
value: hive
- name: DB_PASSWORD
value: hive-password
- name: CORE_CONF_fs_defaultFS
value: hdfs://hdfs-namenode:8020
ports:
- containerPort: 9083
更新:当我尝试卷曲hive-metastore:9083时,该服务是可访问的,但它返回一个空响应,这意味着hive-metastore K8s定义可能存在问题
> GET / HTTP/1.1
> User-Agent: curl/7.35.0
> Host: hive-metastore:9083
> Accept: */*
答案 0 :(得分:1)
当群集中的配置单元jar版本与Spark使用的配置单元jar之间存在差异时(通常与您使用的Spark版本一致),就会发生此错误。您需要确定集群中使用的配置单元jar的版本,并将这些jar添加到Spark映像中。然后,可以通过向SparkSession添加以下配置,使SparkSession使用那些兼容的配置单元jar:
.conf("spark.sql.hive.metastore.version", "<your hive metastore version>")
.conf("spark.sql.hive.metastore.version", "<your hive version>")
.conf("spark.sql.hive.metastore.jars", "<uri of all the correct hive jars>")