首页 > 代码库 > spark连接hive

spark连接hive

1 环境

hadoop2.7.3

apache-hive-2.1.1-bin

spark-2.1.0-bin-hadoop2.6

jdk1.8

 

2 配置文件

在hive-site.xml中配置mysql数据库连接。

cp apache-hive-2.1.1-bin/conf/hive-site.xml  ./spark-2.1.0-bin-hadoop2.6/conf/

cp apache-hive-2.1.1-bin/lib/mysql-connector-java-5.1.40-bin.jar ./spark-2.1.0-bin-hadoop2.6/jars

 

3 启动

启动hadoop : ./hadoop-2.7.3/sbin/start-all.sh

启动mysql :  service mysql start

启动hive :  ./apache-hive-2.1.1-bin/bin/hive

启动spark : ./spark-2.1.0-bin-hadoop2.6/bin/spark-sql 验证是否正常连接hive,查询语法同hive一致。 (i.e. show tables;)

      或者 ./spark-2.1.0-bin-hadoop2.6/bin/spark-shell 运行scala程序

 

spark连接hive