【问题标题】:Hive Databases Only List default DBHive 数据库仅列出默认数据库
【发布时间】:2018-12-10 05:07:27
【问题描述】:

当我尝试通过 Spark (1.6) 列出所有配置单元数据库时

scala> val tdf = sqlContext.sql("SHOW DATABASES");
tdf: org.apache.spark.sql.DataFrame = [result: string]
scala> tdf.show
+-------+
| result|
+-------+
|default|
+-------+

当我尝试通过 hive shell 列出所有 hive 数据库时

hive> show databases;
OK
default
Time taken: 0.621 seconds, Fetched: 1 row(s)

在我的蜂巢中,实际上我已经有很多数据库了。我错过了 Cloudera 集群上的一些配置吗?或者我的 hive 元存储有问题?

【问题讨论】:

  • 你如何设置 spark .. 我认为你在 spark conf 目录中缺少应对 hive-site.xml 副本..
  • FWIW,你应该考虑安装 Spark2
  • 我已经尝试复制文件,但它返回另一个错误

标签: apache-spark hadoop hive cloudera cloudera-manager


【解决方案1】:

使用 HiveContext 从配置单元中获取数据。通过

设置hive.metastore.uris

火花码 -

System.setProperty("hive.metastore.uris","thrift://hostserver:9083")
val hivecontext = new HiveContext(sparkContext)
val tdf = hivecontext.sql("SHOW DATABASES");

火花壳

spark-shell --driver-java-options "-Dhive.metastore.uris=thrift://hostserver:9083"

【讨论】:

  • 是的,它在传递 thrift url 作为参数后工作: spark-shell --driver-java-options "-Dhive.metastore.uris=thrift://hostserver:9083"
【解决方案2】:

由于Hive shell 也只显示default 数据库,因此可以检查Hive 元存储配置。

首先,您可以登录到具有元存储的数据库,然后运行应该列出 Hive 数据库的查询。 MySQL 数据库的示例查询是:

mysql> SELECT NAME, DB_LOCATION_URI FROM hive.DBS;

然后,您可以按照以下方式验证和更新hive-site.xml。这个文件在CDH上的位置一般在/usr/lib/hive/conf/hive-site.xml,在HDP上一般在/usr/hdp/current/hive-client/conf/hive-site.xml

元存储的配置文档参考:

a)https://cwiki.apache.org/confluence/display/Hive/AdminManual+MetastoreAdmin#AdminManualMetastoreAdmin-RemoteMetastoreDatabase

b) (CDH) https://www.cloudera.com/documentation/enterprise/5-6-x/topics/cdh_ig_hive_metastore_configure.html(参考章节:4. 配置 Metastore 服务与 MySQL 数据库通信

配置示例:

<property>
  <name>javax.jdo.option.ConnectionDriverName</name>
  <value>com.mysql.jdbc.Driver</value>
</property>

<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:mysql://localhost/hive?createDatabaseIfNotExist=true</value>
</property>

<property>
  <name>javax.jdo.option.ConnectionUserName</name>
  <value>hive</value>
</property>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-11
    • 2013-02-16
    • 1970-01-01
    • 1970-01-01
    • 2021-07-01
    • 2011-01-24
    • 2022-01-04
    • 2021-11-19
    相关资源
    最近更新 更多