我创建了一个Spark Context对象,并尝试从hadoop服务器上的文本文件中检索文本(不在我的本地),我能够检索它 .
当我试图检索Hive Table(它位于独立的机器,群集上)时,我无法做到,当我创建一个hive表时,它会在metastore_db中本地创建
objHiveContext.sql(“创建表yahoo_orc_table(日期STRING,open_price FLOAT,high_price FLOAT,low_price FLOAT,close_price FLOAT,卷INT,adj_price FLOAT)”存储为orc“)
我尝试设置Metastore
objHiveContext.setConf(“hive.metastore.warehouse.dir”,“hdfs:// ServerIP:HiveportNum / apps / hive / warehouse”)
&&也是objHiveContext.hql(“SET hive.metastore.warehouse.dir = hdfs:// serverIp:portNumber / apps / hive / warehouse”)
我甚至将hive-site xml放在spark machine conf文件夹中,
如何让我的scala应用程序联系hive-site.xml并从该xml获取Metastore信息以及我应该在哪里放置我的Hive-site.xml
我把它放在我的应用程序中,因为它建议在ClassPath中添加,我添加并且可以看到mypom.xml文件上方,但我的scala应用程序仍处于本地模式
表(yahoo_orc_table)在D:\ user \ hive \ warehouse中本地创建
2 回答
它唯一应该放在spark conf目录中 . 如果你把它放在那里仍然没有工作,这意味着问题出在其他地方,也许在hive-site.xml的内容中 .
这个问题在spark2上解决了,将hive-site xml文件放在spark machine conf文件夹中后你可以使用:
此代码在群集上的配置单元中创建表“yahoo_orc_table” .