Hive 数据库仅列出默认数据库
Hive Databases Only List default DB
当我尝试通过 Spark (1.6) 列出所有 Hive 数据库时
scala> val tdf = sqlContext.sql("SHOW DATABASES");
tdf: org.apache.spark.sql.DataFrame = [result: string]
scala> tdf.show
+-------+
| result|
+-------+
|default|
+-------+
当我尝试通过 hive 列出所有 hive 数据库时 shell
hive> show databases;
OK
default
Time taken: 0.621 seconds, Fetched: 1 row(s)
在我的蜂巢中,实际上我已经有很多数据库了。我是否错过了 Cloudera 集群上的某些配置?还是我的 Hive Metastore 有问题?
使用 HiveContext 从配置单元中获取数据。设置 hive.metastore.uris
为
火花代码-
System.setProperty("hive.metastore.uris","thrift://hostserver:9083")
val hivecontext = new HiveContext(sparkContext)
val tdf = hivecontext.sql("SHOW DATABASES");
火花-shell
spark-shell --driver-java-options "-Dhive.metastore.uris=thrift://hostserver:9083"
因为 Hive
shell 也只显示 default
数据库,所以可以检查 Hive
元存储配置。
首先,您可以登录到具有 Metastore 的数据库,然后 运行 这个应该列出 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
.
配置 Metastore 的文档参考:
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>
当我尝试通过 Spark (1.6) 列出所有 Hive 数据库时
scala> val tdf = sqlContext.sql("SHOW DATABASES");
tdf: org.apache.spark.sql.DataFrame = [result: string]
scala> tdf.show
+-------+
| result|
+-------+
|default|
+-------+
当我尝试通过 hive 列出所有 hive 数据库时 shell
hive> show databases;
OK
default
Time taken: 0.621 seconds, Fetched: 1 row(s)
在我的蜂巢中,实际上我已经有很多数据库了。我是否错过了 Cloudera 集群上的某些配置?还是我的 Hive Metastore 有问题?
使用 HiveContext 从配置单元中获取数据。设置 hive.metastore.uris
为
火花代码-
System.setProperty("hive.metastore.uris","thrift://hostserver:9083")
val hivecontext = new HiveContext(sparkContext)
val tdf = hivecontext.sql("SHOW DATABASES");
火花-shell
spark-shell --driver-java-options "-Dhive.metastore.uris=thrift://hostserver:9083"
因为 Hive
shell 也只显示 default
数据库,所以可以检查 Hive
元存储配置。
首先,您可以登录到具有 Metastore 的数据库,然后 运行 这个应该列出 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
.
配置 Metastore 的文档参考:
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>