您好,登錄后才能下訂單哦!
這篇文章主要介紹sparksql與hive如何整合,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
編輯 $HIVE_HOME/conf/hive-site.xml,增加如下內容:
<property> <name>hive.metastore.uris</name> <value>thrift://master:9083</value> <description>Thrift uri for the remote metastore. Used by metastore client to connect to remote metastore.</description></property>12345
啟動 metastore: $hive --service metastore & 查看 metastore: $jobs[1]+ Running hive --service metastore & 關閉 metastore:$kill %1kill %jobid,1代表job id1234567891011
將 $HIVE_HOME/conf/hive-site.xml copy或者軟鏈 到 $SPARK_HOME/conf/將 $HIVE_HOME/lib/mysql-connector-java-5.1.12.jar copy或者軟鏈到$SPARK_HOME/lib/copy或者軟鏈$SPARK_HOME/lib/ 是方便spark standalone模式使用123
standalone模式
./bin/spark-sql --master spark:master:7077 --jars /home/stark_summer/spark/spark-1.4/spark-1.4.1/lib/mysql-connector-java-5.1.12.jar
1
yarn-client模式
$./bin/spark-sql --master yarn-client --jars /home/stark_summer/spark/spark-1.4/spark-1.4.1/lib/mysql-connector-java-5.1.12.jar執行 sql: select count(*) from o2o_app;結果:302Time taken: 0.828 seconds, Fetched 1 row(s)2015-09-14 18:27:43,158 INFO [main] CliDriver (SessionState.java:printInfo(536)) - Time taken: 0.828 seconds, Fetched 1 row(s) spark-sql> 2015-09-14 18:27:43,160 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - Finished stage: org.apache.spark.scheduler.StageInfo@5939ed302015-09-14 18:27:43,161 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - task runtime:(count: 1, mean: 242.000000, stdev: 0.000000, max: 242.000000, min: 242.000000)2015-09-14 18:27:43,161 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - 0% 5% 10% 25% 50% 75% 90% 95% 100%2015-09-14 18:27:43,161 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - 242.0 ms 242.0 ms 242.0 ms 242.0 ms 242.0 ms 242.0 ms 242.0 ms 242.0 ms 242.0 ms2015-09-14 18:27:43,162 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - fetch wait time:(count: 1, mean: 0.000000, stdev: 0.000000, max: 0.000000, min: 0.000000)2015-09-14 18:27:43,162 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - 0% 5% 10% 25% 50% 75% 90% 95% 100%2015-09-14 18:27:43,162 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - 0.0 ms 0.0 ms 0.0 ms 0.0 ms 0.0 ms 0.0 ms 0.0 ms 0.0 ms 0.0 ms2015-09-14 18:27:43,163 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - remote bytes read:(count: 1, mean: 31.000000, stdev: 0.000000, max: 31.000000, min: 31.000000)2015-09-14 18:27:43,163 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - 0% 5% 10% 25% 50% 75% 90% 95% 100%2015-09-14 18:27:43,163 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - 31.0 B 31.0 B 31.0 B 31.0 B 31.0 B 31.0 B 31.0 B 31.0 B 31.0 B2015-09-14 18:27:43,163 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - task result size:(count: 1, mean: 1228.000000, stdev: 0.000000, max: 1228.000000, min: 1228.000000)2015-09-14 18:27:43,163 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - 0% 5% 10% 25% 50% 75% 90% 95% 100%2015-09-14 18:27:43,163 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - 1228.0 B 1228.0 B 1228.0 B 1228.0 B 1228.0 B 1228.0 B 1228.0 B 1228.0 B 1228.0 B2015-09-14 18:27:43,164 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - executor (non-fetch) time pct: (count: 1, mean: 69.834711, stdev: 0.000000, max: 69.834711, min: 69.834711)2015-09-14 18:27:43,164 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - 0% 5% 10% 25% 50% 75% 90% 95% 100%2015-09-14 18:27:43,164 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - 70 % 70 % 70 % 70 % 70 % 70 % 70 % 70 % 70 %2015-09-14 18:27:43,165 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - fetch wait time pct: (count: 1, mean: 0.000000, stdev: 0.000000, max: 0.000000, min: 0.000000)2015-09-14 18:27:43,165 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - 0% 5% 10% 25% 50% 75% 90% 95% 100%2015-09-14 18:27:43,165 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - 0 % 0 % 0 % 0 % 0 % 0 % 0 % 0 % 0 %2015-09-14 18:27:43,166 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - other time pct: (count: 1, mean: 30.165289, stdev: 0.000000, max: 30.165289, min: 30.165289)2015-09-14 18:27:43,166 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - 0% 5% 10% 25% 50% 75% 90% 95% 100%2015-09-14 18:27:43,166 INFO [SparkListenerBus] scheduler.StatsReportListener (Logging.scala:logInfo(59)) - 30 % 30 % 30 % 30 % 30 % 30 % 30 % 30 % 30 %12345678910111213141516171819202122232425262728293031
yarn-cluster模式
./bin/spark-sql --master yarn-cluster --jars /home/dp/spark/spark-1.4/spark-1.4.1/lib/mysql-connector-java-5.1.12.jarError: Cluster deploy mode is not applicable to Spark SQL shell. Run with --help for usage help or --verbose for debug output2015-09-14 18:28:28,291 INFO [Thread-0] util.Utils (Logging.scala:logInfo(59)) - Shutdown hook called Cluster deploy mode 不支持的123456
standalone模式
./bin/spark-shell --master spark:master:7077 --jars /home/stark_summer/spark/spark-1.4/spark-1.4.1/lib/mysql-connector-java-5.1.12.jar1
yarn-client模式
./bin/spark-shell --master yarn-client --jars /home/dp/spark/spark-1.4/spark-1.4.1/lib/mysql-connector-java-5.1.12.jarsqlContext.sql("from o2o_app SELECT count(appkey,name1,name2)").collect().foreach(println)1234
以上是“sparksql與hive如何整合”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。