您好,登錄后才能下訂單哦!
ssh-keygen
cd .ssh
touch authorized_keys
cat id_rsa.pub > authorized_keys
chmod 600 authorized_keys
系統 urbuntu jdk 1.7.0_79
scala 2.10.4
hadoop 2.6.0
spark 1.6.2
IDEA + sbt1.2打包工具
需要預先安裝scala插件,點擊File ->Setting ->Plugins ->輸入框輸入scala->install
安裝完成需要重啟IDE
File -> New Project ->Scala -> SBT 選擇相應版本 ->finish
build.sbt 添加spark相關依賴
name := "demoPro"
version := "1.0"
scalaVersion := "2.10.4"
libraryDependencies += "org.apache.spark" % "spark-core_2.10" % "1.6.2"
創建WordCount.scala,編寫如下代碼
import org.apache.spark.{SparkContext, SparkConf}
/**
* Created by Administrator on 2018/2/20.
*/
object WordCount {
def main(args: Array[String]) {
val conf = new SparkConf().setAppName("wordcount")
val sc = new SparkContext(conf)
val input = sc.textFile("/home/dell/helloSpark.txt")
val lines = input.flatMap(line => (line.split(" ")))
val count = lines.map(word => (word, 1)).reduceByKey { case (x, y) => x + y }
val output=count.saveAsTextFile("/home/dell/helloSparkRes")
}
}
File -> Project Structure -> Aritifacts -> 點擊+號 ->jar -> 第二個 -> 指定Module和 MainClass -> JAR files from libraries 選擇第二個 ->點擊ok
主題欄點擊Build -> Build Aritifacts - Build
在工程目下out目錄中生成相應jar包即打包成功
#進入sbin目錄
cd $Hadoop_HOME/sbin
#啟動hadoop集群
start-all.sh
hadoop fs -put test.txt /test/test.txt
是同filelize 或者sftp 或者 rz -y命令上傳程序jar
sudo ./start-master.sh
訪問localhost:8080 獲取spark://xxx:7077
sudo ./bin/spark-class org.apache.spark.deploy.worker.Worker spark://dell:7077
sudo ./bin/spark-submit --master spark://dell:7077 --class WordCount /home/dell/demopro.jar
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。