无法从spark应用程序连接到配置单元元存储

mefy6pfw  于 2021-07-14  发布在  Java
关注(0)|答案(1)|浏览(399)

我正在尝试从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

应用程序在我创建外部配置单元表的那一行崩溃
我在kubernetes集群中运行hivemetastore和spark应用程序(使用spark8s操作符)。我使用telnet(node-ip:service-node-port)检查了集群外部的hive metastore服务的可访问性,并将该服务 curl 到集群内部,该服务似乎是可评估的。这个错误的原因是什么?
这是spark应用程序中配置单元元存储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()

配置单元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

更新:当我试图 curl Hive-metastore:9083,该服务是可访问的,但它返回一个空响应,这意味着配置单元元存储区k8s定义可能有问题

> GET / HTTP/1.1
> User-Agent: curl/7.35.0
> Host: hive-metastore:9083
> Accept: */*
wwodge7n

wwodge7n1#

当集群中的配置单元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>")

相关问题