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()
  }
}

 




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM