Run Spark with build-in Hive and Configuring a remote PostgreSQL database for the Hive Metastore

你。 提交于 2019-12-05 19:26:14

I find the solution for my problem. I need to add CLASSPATH for SPARK so that build-in Hive could use postgresql-jdbc4.jar

I add 3 environment variables:

export CLASSPATH="$CLASSPATH:/usr/share/java/postgresql-jdbc4.jar"
export SPARK_CLASSPATH=$CLASSPATH
export SPARK_SUBMIT_CLASSPATH=$CLASSPATH

SPARK_CLASSPATH is used for spark-shell

SPARK_SUBMIT_CLASSPATH is used for spark-submit (I am not sure)

Now I could use spark-shell with build-in Hive which config to use Metastore in Postgres

javadba

You have two options:

  1. You can continue to use your own hive installation. You need to put a copy of hive-site.xml (or make a symlink) under $SPARK_HOME/conf/hive-site.xml
  2. If you want to use the built-in hive: you need to modify the $SPARK_HOME/hive-<version>/conf/hive-site.xml .
    Inside the hive-site.xml you need to modify the javax.jdo.option.* values. Along the lines of the following:

    <property>
     <name>hive.metastore.local</name>
     <value>true</value>
       </property>
       <property>
     <name>javax.jdo.option.ConnectionURL</name>
     <value>jdbc:postgresql://localhost:5432/hivedb</value>
    </property>
    <property>
       <name>javax.jdo.option.ConnectionDriverName</name>
       <value>org.postgresql.Driver</value>
     </property>
     <property>
       <name>javax.jdo.option.ConnectionUserName</name>
       <value>******</value>
     </property>
     <property>
       <name>javax.jdo.option.ConnectionPassword</name>
       <value>******</value>
     </property>
    
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!