说明
Spark on Hive 方式,SparkSQL 连接 Hive 的 metastore 服务,获取 元数据,然后 获取表结构、读取 HDFS 文件
作用
通过本文的配置,可以直接使用
spark-sql命令,操作 Hive 表编写代码时,启用 Hive 后,直接操作 Hive 表,不需要指定 Hive 的
metastore服务
提示
不进行本文的配置,编写代码时,启用 Hive 后,需要指定 Hive 的 metastore 服务,才能操作 Hive 表
要求
Hive必须配置并开启
metastore服务,详见 链接尽量不要使用
-without-hadoop版本,需要额外加入一些 jar包
配置
登录 hadoop1 服务器,将 hive 的 /program/hive-3.1.2/conf/hive-site.xml 文件复制到 /program/spark-3.0.0/conf 目录下
cp /program/hive-3.1.2/conf/hive-site.xml /program/spark-3.0.0/conf/
without-hadoop版本
如果使用 without-hadoop 版本的 spark,还需要额外加上以下jar包
antlr-runtime-3.5.2.jar
datanucleus-api-jdo-4.2.4.jar
datanucleus-core-4.1.17.jar
datanucleus-rdbms-4.1.19.jar
jdo-api-3.0.1.jar
hive-beeline-2.3.7.jar
hive-cli-2.3.7.jar
hive-common-2.3.7.jar
hive-exec-2.3.7-core.jar
hive-jdbc-2.3.7.jar
hive-llap-common-2.3.7.jar
hive-metastore-2.3.7.jar
hive-serde-2.3.7.jar
hive-shims-0.23-2.3.7.jar
hive-shims-2.3.7.jar
hive-shims-common-2.3.7.jar
hive-shims-scheduler-2.3.7.jar
hive-storage-api-2.7.1.jar
hive-vector-code-gen-2.3.7.jar
jline-2.14.6.jar
joda-time-2.10.5.jar
libfb303-0.9.3.jar
libthrift-0.12.0.jar
spark-hive-thriftserver_2.12-3.0.0.jar
spark-hive_2.12-3.0.0.jar