spark大數(shù)據(jù)分析平臺(tái)Spark快速計(jì)算講師_第1頁(yè)
spark大數(shù)據(jù)分析平臺(tái)Spark快速計(jì)算講師_第2頁(yè)
spark大數(shù)據(jù)分析平臺(tái)Spark快速計(jì)算講師_第3頁(yè)
spark大數(shù)據(jù)分析平臺(tái)Spark快速計(jì)算講師_第4頁(yè)
spark大數(shù)據(jù)分析平臺(tái)Spark快速計(jì)算講師_第5頁(yè)
已閱讀5頁(yè),還剩27頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

Spark13DATAGURU專業(yè)數(shù)據(jù)分析Spark大數(shù)據(jù)快速計(jì)算平風(fēng) 課程詳 Spark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析RDD的編SparkSpark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析SparkSpark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析Driver

Ajarcontainingtheuser'sSparkapplication.Insomecasesuserswillwanttocreatean"uberjar"containingtheirapplicationalongwithitsdependencies.Theuser'sjarshouldneverincludeHadooporSparklibraries,however,thesewillbeaddedatTheprocessrunningthemain()functionoftheapplicationandcreatingtheCluster Anexternalserviceforacquiringresourcesonthecluster(e.g.standalonemanager,Mesos,Deploy Distinguisheswherethedriverprocessruns.In"cluster"mode,theframeworklaunchesthedriverinsideofthecluster."client"mode,thesubmitterlaunchesthedriveroutsideoftheWorker Anynodethatcanrunapplicationcodeinthe Aprocesslaunchedforanapplicationonaworkernode,thatrunstasksandkeepsdatainmemoryordiskstoragethem.Eachapplicationhasitsown Aunitofworkthatwillbesenttoone AparallelcomputationconsistingofmultipletasksthatgetsspawnedinresponsetoaSparkaction(e.g.save,collect);you'llseethistermusedinthedriver'slogs.EachjobgetsdividedintosmallerEachjobgetsdividedintosmallersetsoftaskscalledstagesthatdependoneachother(similartothemapandreducestagesinMapReduce);you'llseethistermusedinthedriver'slogs.DATAGURU專業(yè)數(shù)據(jù)分析SparkRDDSpark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析Spark編程模Spark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析RDDSpark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析描述scala>valmap1=rdd.map(_*3)res0:Array[Int]=Array(3,6,9,12,scala>valrddscala>valfiltered=res2:Array[String]=Array(jifeng,scala>valrdd=sc.parallelize(List("aaaddfdc","dcisfun"))scala>valfm=rdd.flatMap(str=>str.split(""))res3:Array[String]=Array(aa,ad,df,dc,dc,is,Spark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析描述reduceByKey(func,scala>valwd=fm.map(word=>(word,1))scala>wdnum.collect()Array[(String,Int)]=Array((aa,1),(is,1),(df,1),(dc,2),(ad,1),Array[(String,Int)]=Array((aa,1),(ad,1),(dc,2),(df,1),(fun,1),scala>valcntWrd=wdnum.map{case(word,count)=>(count,word)}scala>cntWrd.groupByKey().collect()Array[(Int,Iterable[String])]=Array(( pactBuffer(dc)),( pactBuffer(aa,is,df,ad,scala>fm.distinct().collect()Array[String]=Array(aa,is,df,dc,ad,Spark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析描述 scala>rdd.reduce(_+_)Int=scala>valrdd=rdd:Array[String]=Array(A,B,C,scala>rdd.count()Long=scala>rdd.take(3)Array[String]=Array(A,B,Spark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析描述scala>rdd.first()String=AScala>valrdd=scala>$ls//查看part-00000part-00001Spark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析描述Spark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析haRDhaRDRDaquet文件、Jh查詢he注意Spark1.1使用registerTempTable代替1.0版本的Spark1.1在hiveContext中,hql()將被棄用,sql()將代替hql()來(lái)提交查詢語(yǔ)句,統(tǒng)一了接口使用 表是一個(gè)臨時(shí)表,生命周期只在所定義的sqlContext或hiveContext實(shí)例之中spark1.1提供了語(yǔ)法解析器選項(xiàng)spark.sql.dialect,目前有兩種語(yǔ)法解析器,sql語(yǔ)法解析器和hiveql語(yǔ)法解析器sqlContext現(xiàn)在只支持sql語(yǔ)法解析器(SQL-92語(yǔ)法)hiveContext現(xiàn)在支持sql語(yǔ)法解析器和hivesql語(yǔ)法解析器,默認(rèn)為hivesql語(yǔ)法解析器,用戶可以通過(guò)配置切換成sql語(yǔ)法解析器Spark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析 [jifeng@feng03~]$mkdirhive[jifeng@feng03~]$cdhive/[jifeng@feng02hive]$tarzxfapache-hive-0.13.1-bin.tar.gz[jifeng@feng02hive]$lsSpark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析Hive[jifeng@feng03hive]$viexport2修改 下的文[jifeng@feng03conf]$perties.template[jifeng@feng02conf]$mvhive-env.sh.templatehive-env.sh[jifeng@feng02conf]$cphive-default.xml.templatehive-Spark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析Hive修改 下的文export[jifeng@feng02conf]$cd[jifeng@feng02bin]$vihive-#Defaulttouseexport"hive-config.sh"73L,2023CSpark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析Hive配置[jifeng@feng03conf]$vihive-<property><description>JDBCconnectstringforaJDBC <description>DriverclassnameforaJDBCSpark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析Hive<description>usernametouseagainstmetastore<description>passwordtouseagainstmetastoreSpark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析Hive啟動(dòng)[jifeng@feng02hadoop-2.6.0]$./sbin/start-啟動(dòng)[jifeng@feng03hive]$15/09/0516:31:10WARNconf.HiveConf:DEPRECATED:hive.metastore.ds.retry.*nolongerhasanyeffect.Usehive.hmshandler.retry.*insteadLogginginitializedusingconfigurationinjar:file:/home/jifeng/hive/apache-hive-0.13. hive>createdatabasesale;Timetaken:1.188Spark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析hive>createtableshop(locationid namestring)rowformatdelimitedfieldsterminatedbyexceptionwasthrownwhileadding/validatingclass(es):Specifiedkeywastoolong;maxkeylengthis767atatjava.lang.reflect.Constructor.newInstance(Constructor.java:526)atcom.mysql.jdbc.Util.getInstance(Util.java:360)mysql>alterdatabasehivecharactersetlatin1;QueryOK,1rowaffected(0.00sec)Spark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析hive>createtableshop(locationidint,name namestring)rowformatdelimitedfieldsterminatedby',';Timetaken:0.884hive>createtablesell(locationidint,fyearint,amountdouble,numdouble)rowformatdelimitedfieldsterminatedbyTimetaken:0.158hive>showtables;Timetaken:0.105seconds,Fetched:2row(s)Spark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析上傳文件到j(luò)ifeng@feng03hive]$hadoopfsputhome/jifeng/code/db/shop.txtuser/jifeng/fire/hive>loaddatainpath'/user/jifeng/fire/shop.txt'intotableshop;Loadingdatatotabledefault.shopTimetaken:0.657hive>loaddatainpath'/user/jifeng/fire/sell.txt'intotablesell;Loadingdatatotabledefault.sellTimetaken:0.38Spark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析Hivesupportisenabledbyaddingthe-Phiveand-Phive-thriftserverflagstoSpark’sConfigurationofHiveisdonebyplacingyourhive-site.xmlfileinspark-sql>select*fromshopwhere15/09/0516:54:52INFOscheduler.TaskSchedulerImpl:Addingtaskset2.0with2tasks15/09/0516:54:52INFOstorage.BlockManagerInfo:Addedbroadcast_3_piece0inmemoryon10:58340(size:35.2KB,free:267.2MB)15/09/0516:54:52INFOscheduler.TaskSetManager:Finishedtask0.0instage2.0(TID3)in574mson10(1/2)15/09/0516:54:53INFOscheduler.DAGScheduler:ResultStage2(processCmdatCliDriver.java:423)finishedin0.617s15/09/0516:54:53INFOscheduler.DAGScheduler:Job2finished:processCmdatCliDriver.java:423,took0.680182s Spark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析 importimportorg.apache.spark.sql.hive.HiveContextimportorg.apache.spark.mllib.linalg.VectorsvalsqlContext=newvalsqldata=sqlContext.sql("selectlocationid,sum(num)allnum,sum(amount)allamountfromsellgroupbylocationid")Spark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析valparsedData=sqldata.mapcaseRow(_,allnum,allamount)} valnumClusters=3valnumIterations=valmodel=KMeans.train(parsedData,numClusters,Spark大數(shù)據(jù)快速計(jì)算平風(fēng)

DATAGURU專業(yè)數(shù)據(jù)分析valresult1=sqldata.map{caseRow(locationid,allnum,allamount)vallinevectore=Vectors.dense(features)valprediction=locationid+""+allnum+""+allamoun

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論