The configuration of running hive on spark
The following configuration files are configured in the Spark directory
1)/usr/local/spark/conf/hive-site.xml
Add a hive-site.xml configuration file to the/usr/local/spark/conf, primarily to indicate the location of the hive metadata. The specific content is:
<configuration>
<property>
<name>hive.metastore.uris</name>
<value> Thrift://vm000:9083</value>
<description>thrift URI for the remote Metastore. Used by Metastore Client to connect to remote metastore.</description>
</property>
</ Configuration>
2 Add the MySQL jar package to the/usr/loal/spark/lib. (This step seems to do not have to do)
Add Mysql-connector-java-5.1.37-bin.jar to/usr/local/spark/lib
3 start hive Meta data Service
Executive Hive--service Metastore &
Then you can start the./spark-shell, and you can perform the HQL in Spark-shell after startup.
4 when executing, create the Hivecontext object first:
Val hivecontext = new Org.apache.spark.sql.hive.HiveContext (SC)/Note that the full package name should be written before hivecontext, or it will be an error.
5) Then, you can execute the HQL query. The following are a few examples:
A. Hivecontext.sql ("Use Hive"); Using the Hive Database
B. Hivecontext.sql ("Show Tables")
C. hivecontext.sql ("SELECT * from people"). Collect.foreach (println)
D. Hivecontext.sql ("SELECT count (*) from Text"). Collect.foreach (println)
Two. Two errors in starting the Spark-shell times
1) The word "Reject connection" appears
Analysis:; should be the problem of IP address
Method: Modifies the IP address of master in spark-env.sh. (may be because the current IP has changed, and the original configuration is not the same)
can be resolved
2 after the error 1 is resolved, start Spark-shell again, and report the following error:
exception in thread "main" java.lang.RuntimeException:java.lang.RuntimeException:Unable to Instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient at Org.apache.hadoop.hive.ql.session.Se Ssionstate.start (sessionstate.java:444) at Org.apache.hadoop.hive.cli.CliDriver.run (clidriver.java:672) at Org.apache.hadoop.hive.cli.CliDriver.main (clidriver.java:616) at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Na tive to Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:39) at Sun.refle Ct. Delegatingmethodaccessorimpl.invoke (delegatingmethodaccessorimpl.java:25) at Java.lang.reflect.Method.invoke ( method.java:597) at Org.apache.hadoop.util.RunJar.run (runjar.java:221) at org.apache.hadoop.util.RunJar.ma In (runjar.java:136) caused By:java.lang.RuntimeException:Unable to instantiate Org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
Cause: The Metastore Server service process for hive is not started properly.
Workaround: Start the Hive Metastore Server service process and execute the following command: # hive--service Metastore &
Solve