如何使用Spark Scala从IntelliJ IDEA连接到Virtual Box中的Hive

时间:2017-08-24 11:19:17

标签: scala apache-spark intellij-idea hive cloudera

我需要在本地Windows机器上的IntelliJ中创建的Spark - scala程序中连接到运行在virtualBox中的Cloudera CDH 5.8中的Hive。请帮忙。

1 个答案:

答案 0 :(得分:0)

您需要的主要是HDFS和Hive支持。您有两个选择:

1)。创建core-site.xml,配置的hive-site.xml:

核心网站资源

<property>
        <!--<name>fs.defaultFS</name>-->
        <name>fs.defaultFS</name>
        <value>maprfs://cdhdemo:7222</value>
    </property>

hive-site属性

<property>
        <name>hive.metastore.uris</name>
        <value>thrift://cdhdemo:9083</value>
    </property>
    <property>
        <name>hive.metastore.warehouse.dir</name>
        <value>/user/hive/warehouse</value>
    </property>

2)。或者您可以使用SparkSession以编程方式配置:

sparkSessionBuilder
      .config("hive.metastore.uris", "thrift://chddemo:9083")
      .config("hive.metastore.warehouse.dir", "/user/hive/warehouse")
      .config("fs.defaultFS", "maprfs://chddemo:7222")
      .enableHiveSupport()