我正在使用spark-java来访问hive Metastore . 在我的机器上只安装了火花而没有别的 . 我没有hadoop目录或Hive文件夹 . 我在 spark/conf
目录中创建了 hive-site.xml
, hdfs-site.xml
, core-site.xml
和 yarn-site.xml
. 我的hive Metastore是在另一台机器上设置的,它是hadoop集群的一部分,是namenode . 我可以从桌面上的 spark/bin/beeline
和 spark/bin/spark-shell
访问hive Metastore,但是当我尝试从java-api访问hive-Metoreore时,我得到了 metastore_db
文件夹和 derby.log
文件在我的项目中创建,这意味着我无法访问hive Metastore .
SparkSession spark = SparkSession
.builder()
.appName("Java Spark SQL basic example")
.enableHiveSupport()
.config("spark.sql.warehouse.dir", "hdfs://bigdata-namenode:9000/user/hive/warehouse")
.config("mapred.input.dir.recursive", true)
.config("hive.mapred.supports.subdirectories", true)
.config("spark.sql.hive.thriftServer.singleSession", true)
.config("hive.exec.dynamic.partition.mode", "nonstrict")
.master("local")
.getOrCreate();
spark.sql("show databases").show();
当我在我的桌面上启动thrift服务器(即客户端机器)时,我得到这个日志thriftserver.log,其中 spark.sql.warehouse.dir
设置为 my local file system path
,即不是hdfs,其中是实际仓库 .
/spark/conf/core-site.xml
/spark/conf/hive-site.xml