1

This trouble drives me crazy. I've been spending for 5 days on it. I have a hadoop-3.1.3 environment with hive-2.3.7 and spark-3.0.0 ; hive works well. However, spark-shell can't access hive metadata.

scala> spark.sql("show databases").show

+------------+
|databaseName|
+------------+
|     default|
+------------+


scala> spark.sql("show tables").show

+--------+---------+-----------+
|database|tableName|isTemporary|
+--------+---------+-----------+
+--------+---------+-----------+

I have copied "hive-site.xml" to directory "spark_home/conf", I thought there might be an incompatibility between hive and spark before, then I changed spark3.0.0 to sprk-2.4.5. it dosen't work. I've searched tons of webpages online about this problem.whatever I do, this problem still exists. I almost despair! please help me.

Here are configuration files

1. hive-site.xml

<property>  
  <name>hive.metastore.local</name> 
  <value>false</value>  
</property>  

<property>
  <name>hive.metastore.uris</name>
  <value>thrift://hadoop102:9083</value>
</property>


<property>
    <name>javax.jdo.option.ConnectionURL</name>  
    <value>jdbc:mysql://hadoop102:3306/metastore?useSSL=false</value>
</property>

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

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

<property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>000000</value>
</property>


<property>
   <name>hive.metastore.schema.verification</name>
   <value>false</value>
</property>


<property>
   <name>hive.server2.thrift.port</name>
   <value>10000</value>
</property>

<property>
   <name>hive.server2.thrift.bind.host</name>
   <value>hadoop102</value>
</property>

<property>
    <name>hive.metastore.event.db.notification.api.auth</name>
    <value>false</value>
</property>


<property>
  <name>hive.server2.thrift.http.port</name>
  <value>10001</value>
</property>


<property>
  <name>metastore.catalog.default</name>
  <value>hive</value>
</property>

<property>
  <name>hive.server2.authentication</name>
  <value>NONE</value>
</property>

<property>
  <name>hive.metastore.warehouse.dir</name>
  <value>/user/hive/warehouse</value>
</property>


<property>
    <name>hive.cli.print.header</name>
    <value>true</value>
</property>

<property>
    <name>hive.cli.print.current.db</name>
    <value>true</value>
</property>

2.spark-env.sh

export JAVA_HOME=/opt/module/jdk1.8.0_212
export SPARK_DIST_CLASSPATH=$(/opt/module/hadoop-3.1.3/bin/hadoop classpath)

export HADOOP_CONF_DIR=/opt/module/hadoop-3.1.3/etc/hadoop
export YARN_CONF_DIR=/opt/module/hadoop-3.1.3/etc/hadoop
export HADOOP_HOME=/opt/module/hadoop-3.1.3

export SPARK_HISTORY_OPTS=" 
 -Dspark.history.ui.port=18080
 -Dspark.history.fs.logDirectory=hdfs://hadoop102:8020/spark-history
 -Dspark.history.retainedApplications=30"

export LD_LIBRARY_PATH=/opt/module/hadoop-3.1.3/lib/native

3.spark-default.conf

spark.master                     yarn
spark.eventLog.enabled           true
spark.eventLog.dir               hdfs://hadoop102:8020/spark-history
spark.serializer                 org.apache.spark.serializer.KryoSerializer
spark.driver.memory              1g
spark.executor.memory            1g

spark.yarn.historyServer.address= hadoop102:18080
spark.history.ui.port=18080

spark.yarn.jars=/opt/module/spark-2.4.5-no-hadoop/jars/*.jar

spark.executor.extraClassPath /opt/module/spark-2.4.5-no-hadoop/jars/mysql-connector-java-5.1.48.jar
spark.driver.extraClassPath   /opt/module/spark-2.4.5-no-hadoop/jars/mysql-connector-java-5.1.48.jar
  • Have you started hive server and metastore service? – Mohana B C Oct 05 '21 at 10:40
  • What are you expecting to see in the result of `show tables` invocation? Have you got any registered tables in your Hive Metastore? Also maybe you've got inconsistency in thrift port settings in your configuration. – saver Oct 07 '21 at 21:47

0 Answers0