从远程 Spark 连接到 Hive 元存储

问题描述 投票:0回答:1

我有安装了 hive 和 Spark 的 hadoop 集群。此外,我有一台单独的工作站机器,我正在尝试从它连接到集群

我在这台机器上安装了 Spark 并尝试使用以下命令进行连接:

pyspark --name testjob --master spark://hadoop-master.domain:7077

在结果中我在 Spark WebUI 页面上看到了 sunning 应用程序。

我想从我的工作站连接到 hive 数据库(在集群中),但我不能这样做。我将 hive-site.xml 配置放入本地工作站上的 Spark conf 目录中,其中包含以下内容:

<configuration>
  <property>
    <name>metastore.thrift.uris</name>
    <value>thrift://hadoop-master.domain:9083</value>
    <description>IP address (or domain name) and port of the metastore host</description>
  </property>
  <property>
    <name>hive.metastore.warehouse.dir</name>
    <value>hdfs://hadoop-master.domain:9000/user/hive/warehouse</value>
    <description>Warehouse location</description>
  </property>
  <property>
    <name>metastore.warehouse.dir</name>
    <value>hdfs://hadoop-master.domain:9000/user/hive/warehouse</value>
    <description>Warehouse location</description>
  </property>
  <property>
    <name>spark.sql.hive.metastore.version</name>
    <value>3.1.0</value>
    <description>Metastore version</description>
  </property>
</configuration>

我绑定了这个结构,但无法使其与外部配置单元数据库一起使用:

spark = SparkSession \
 .builder \
 .appName('test01') \
 .config('hive.metastore.uris', "thrift://hadoop-master.domain:9083") \
 .config("spark.sql.warehouse.dir", "hdfs://hadoop-master.domain:9000/user/hive/warehouse") \
 .enableHiveSupport() \
 .getOrCreate()

如何从本地 pyspark 连接到远程 hive 数据库?

apache-spark hadoop pyspark hive
1个回答
0
投票

更换:

.config('hive.metastore.uris', "thrift://hadoop-master.domain:9083")

与:

.config('spark.hadoop.hive.metastore.uris', "thrift://hadoop-master.domain:9083")
© www.soinside.com 2019 - 2024. All rights reserved.