spark集成hivecontext配置
spark版本:spark-1.6.0-bin-hadoop2.6
hive版本:hive 1.2.1
1.hive-site.xml
<property>
<name>hive.metastore.uris</name>
<value>thrift://master:9083</value>
</property>
2.配置
将hadoop中core-site.xml,hdfs-site.xml, 放在spark中conf下面
将hive中hive-site.xml,放在spark中conf下面
然后将上面三个文件分发到其它spark节点上面。
3.启动 hive metastore
nohup hive --service metastore > metastore.log 2>&1 &
4.yarn提交
spark-submit --master yarn-cluster \
--class com.jp.spark.sparksql.HiveContextSelect \
--files /usr/local/spark-1.6.0-bin-hadoop2.6/conf/hive-site.xml \
--jars datanucleus-api-jdo-3.2.6.jar,datanucleus-core-3.2.10.jar,datanucleus-rdbms-3.2.9.jar,mysql-connector-java-5.1.39.jar,guava-15.0.jar \
/home/jumper/jp_spark-1.0-SNAPSHOT.jar
guava-15.0.jar 有比较好,否则会报警告。
4.spark-shell启动
spark-shell guava-15.0.jar
5.HiveContextSelect内容
object HiveContextSelect{
def main(args: Array[String]) {
val conf = new SparkConf()
// conf.setMaster("local");
conf.setAppName("FirstSelect")
val sc = new SparkContext(conf)
val hiveContext = new HiveContext(sc)
import hiveContext.implicits._
import hiveContext.sql
sql("show databases").collect().foreach(println)
sc.stop()
}
}
posted on 2016-06-29 11:50 xunianchong 阅读(3243) 评论(0) 收藏 举报
浙公网安备 33010602011771号