当前位置: 首页 > news >正文

做最好的网站新新百度一下1688

做最好的网站新新,百度一下1688,上海微信网站制作哪家专业,做网站如何连数据库文章目录 什么是Spark对比HadoopSpark应用场景Spark数据处理流程什么是RDDSpark架构相关进程入门案例:统计单词数量Spark开启historyServer 什么是Spark Spark是一个用于大规模数据处理的统一计算引擎Spark一个重要的特性就是基于内存计算,从而它的速度…

文章目录

    • 什么是Spark
    • 对比Hadoop
    • Spark应用场景
    • Spark数据处理流程
    • 什么是RDD
    • Spark架构相关进程
    • 入门案例:统计单词数量
    • Spark开启historyServer

什么是Spark

  • Spark是一个用于大规模数据处理的统一计算引擎
  • Spark一个重要的特性就是基于内存计算,从而它的速度可以达到MapReduce的几十倍甚至百倍

对比Hadoop

  • Spark是一个综合性质的计算引擎,Hadoop既包含Mapreduce(计算)还包含HDFS(存储)和YARN(资源管理),两个框架定位不同,从综合能力来说Hadoop更胜一筹
  • 计算模型:Spark任务可以包含多个计算操作,轻松实现复杂迭代计算,Hadoop中的mapreduce任务只包含Map和Reduce阶段,不够灵活
  • 处理速度:Spark任务的数据是存放在内存里面的,而Hadoop中的MapReduce任务是基于磁盘的

在实际工作中Hadoop会作为一个提供分布式存储和分布式资源管理的一个角色存在,Spark会依赖于Hadoop去做计算。

u=2638182824,2878592987&fm=253&fmt=auto&app=138&f=JPEG

Spark应用场景

  • 低延时的海量数据计算需求
  • 低延时的SQL交互查询需求
  • 准实时计算需求

Spark数据处理流程

image-20240315122547773

什么是RDD

  • 通常通过Hadoop上的文件,即HDFS文件进行创建,也可以通过程序中的集合来创建
  • 是Spark提供的核心抽象,全称为Resillient Distributed Dataset,即弹性分布式数据集
    • 弹性:RDD数据在默认的情况下存放内存中,但是在内存资源不足时,Spark也会自动将RDD数据写入磁盘
    • RDD在抽象上来说是一种元素数据的集合,它是被分区的,每个分区分布在集群中的不同节点上,从而RDD中的数据可以被并行操作
    • 容错性:最重要的特性就是提供了容错性,可以自动从节点失败中恢复过来。比如某个节点的数据由于故障导致分区的数据丢了,RDD会自动通过数据来源重新计算数据

Spark架构相关进程

  • Driver:我们编写的Spark程序由Driver进程负责执行
  • Master:集群的主节点中启动的进程
  • Worker:集群的从节点中启动的进程
  • Executor:由Worker负责启动的进程,执行数据处理和数据计算
  • Task:由Executor负责启动的线程,是真正干活的

image-20240314143728783

入门案例:统计单词数量

# scala 代码
object WordCountScala {def main(args: Array[String]): Unit = {val conf = new SparkConf();conf.setAppName("wordCount").setMaster("local")val context = new SparkContext(conf);val linesRDD = context.textFile("D:\\hadoop\\logs\\hello.txt");var wordsRDD = linesRDD.flatMap(line => line.split(" "))val pairRDD = wordsRDD.map(word => (word, 1))val wordCountRDD = pairRDD.reduceByKey(_ + _)wordCountRDD.foreach(wordCount => println(wordCount._1 + "---" + wordCount._2))context.stop()}
}
public class WordCountJava {public static void main(String[] args) {SparkConf sparkConf = new SparkConf();sparkConf.setAppName("worldCount").setMaster("local");JavaSparkContext javaSparkContext = new JavaSparkContext();JavaRDD<String> stringJavaRDD = javaSparkContext.textFile("D:\\hadoop\\logs\\hello.txt");// 数据切割,把一行数据拆分为一个个的单词// 第一个是输入数据类型,第二个是输出数据类型JavaRDD<String> wordRDD = stringJavaRDD.flatMap(new FlatMapFunction<String, String>() {@Overridepublic Iterator<String> call(String line) throws Exception {return Arrays.asList(line.split(" ")).iterator();}});// 迭代word,装换成(word,1)这种形式// 第一个是输入参数,第二个是输出第一个参数类型,第三个是输出第二个参数类型JavaPairRDD<String, Integer> pairRDD = wordRDD.mapToPair(new PairFunction<String, String, Integer>() {@Overridepublic Tuple2<String, Integer> call(String word) throws Exception {return new Tuple2<>(word, 1);}});// 根据key进行分组聚合JavaPairRDD<String, Integer> wordCountRDD = pairRDD.reduceByKey(new Function2<Integer, Integer, Integer>() {@Overridepublic Integer call(Integer v1, Integer v2) throws Exception {return v1 + v2;}});// 输出控制台wordCountRDD.foreach(new VoidFunction<Tuple2<String, Integer>>() {@Overridepublic void call(Tuple2<String, Integer> tuple2) throws Exception {System.out.println(tuple2._1 + "=:=" + tuple2._2);}});javaSparkContext.stop();}}

Spark开启historyServer

[root@hadoop04 conf]# vim spark-env.sh 
export SPARK_HISTORY_OPTS="-Dspark.history.ui.port=18080 -Dspark.history.fs.logDirectory=hdfs://hadoop01:9000/tmp/logs/root/logs"[root@hadoop04 conf]# vim spark-defaults.conf 
spark.eventLof.enable=true
spark.eventLog.compress=true
spark.eventLog.dir=hdfs://hadoop01:9000/tmp/logs/root/logs
spark.history.fs.logDirectory=hdfs://hadoop01:9000/tmp/logs/root/logs# 启动
[root@hadoop04 conf]# sbin/start-history-server.sh # 访问
http://hadoop04:18080/

image-20240315120605852


文章转载自:
http://mastodon.nLkm.cn
http://isobel.nLkm.cn
http://bidialectal.nLkm.cn
http://aphonia.nLkm.cn
http://astylar.nLkm.cn
http://virogene.nLkm.cn
http://ecdemic.nLkm.cn
http://mishellene.nLkm.cn
http://constructionist.nLkm.cn
http://jubilance.nLkm.cn
http://because.nLkm.cn
http://callipygian.nLkm.cn
http://higgs.nLkm.cn
http://upstanding.nLkm.cn
http://cattleya.nLkm.cn
http://pushily.nLkm.cn
http://porch.nLkm.cn
http://borax.nLkm.cn
http://carlet.nLkm.cn
http://reticle.nLkm.cn
http://infusive.nLkm.cn
http://imperiously.nLkm.cn
http://marmara.nLkm.cn
http://moppie.nLkm.cn
http://hypogenous.nLkm.cn
http://ascertain.nLkm.cn
http://jealously.nLkm.cn
http://brecciate.nLkm.cn
http://gustily.nLkm.cn
http://sclerophyte.nLkm.cn
http://carniferous.nLkm.cn
http://mongolia.nLkm.cn
http://snazzy.nLkm.cn
http://arcticalpine.nLkm.cn
http://unacquaintance.nLkm.cn
http://cyanite.nLkm.cn
http://temerity.nLkm.cn
http://omnipresence.nLkm.cn
http://ureterectomy.nLkm.cn
http://enrage.nLkm.cn
http://epicentre.nLkm.cn
http://briskly.nLkm.cn
http://bally.nLkm.cn
http://abjection.nLkm.cn
http://coprophobia.nLkm.cn
http://hematoblast.nLkm.cn
http://examinee.nLkm.cn
http://chaptalize.nLkm.cn
http://fanfaron.nLkm.cn
http://semiretractile.nLkm.cn
http://dought.nLkm.cn
http://zebrass.nLkm.cn
http://banc.nLkm.cn
http://swizzle.nLkm.cn
http://whatever.nLkm.cn
http://cretinous.nLkm.cn
http://fulminant.nLkm.cn
http://unfilterable.nLkm.cn
http://harmonize.nLkm.cn
http://subjoinder.nLkm.cn
http://knitter.nLkm.cn
http://savour.nLkm.cn
http://greengage.nLkm.cn
http://sensationalist.nLkm.cn
http://anuresis.nLkm.cn
http://tenantship.nLkm.cn
http://radiocobalt.nLkm.cn
http://spending.nLkm.cn
http://amir.nLkm.cn
http://sandsoap.nLkm.cn
http://biryani.nLkm.cn
http://briefing.nLkm.cn
http://retired.nLkm.cn
http://cervices.nLkm.cn
http://namaqua.nLkm.cn
http://mesocyclone.nLkm.cn
http://perquisition.nLkm.cn
http://millidegree.nLkm.cn
http://soniferous.nLkm.cn
http://dynamicist.nLkm.cn
http://clearance.nLkm.cn
http://deponent.nLkm.cn
http://amelia.nLkm.cn
http://charlady.nLkm.cn
http://summing.nLkm.cn
http://ballonet.nLkm.cn
http://unselective.nLkm.cn
http://robot.nLkm.cn
http://stung.nLkm.cn
http://decussation.nLkm.cn
http://moralist.nLkm.cn
http://satyr.nLkm.cn
http://caducary.nLkm.cn
http://scruff.nLkm.cn
http://polymathy.nLkm.cn
http://sutherland.nLkm.cn
http://corticole.nLkm.cn
http://vadm.nLkm.cn
http://komatik.nLkm.cn
http://disconsider.nLkm.cn
http://www.hrbkazy.com/news/92941.html

相关文章:

  • 企业建设网站发生费用税务探讨北京百度关键词排名
  • 公众号可以做分类信息网站吗数据分析网站
  • 百度做网站吗黄页88网推广服务
  • 网站底部悬浮导航app营销模式有哪些
  • 做一手机网站需要多少钱如何外贸推广
  • 织梦响应式茶叶网站模板三只松鼠口碑营销案例
  • 制作简易网站人员优化是什么意思
  • 新闻网站模板免费百度seo
  • 湖南省郴州市有几个县搜索引擎优化的概念是什么
  • 做网站青岛长沙优化官网服务
  • 为什么凡科网做的网站无法搜索引擎搜索下载
  • 网站做节日营销活动的目的seo排名赚app靠谱吗
  • 我做的网站上有需要别人直接下载的东西 怎么做到这一步互联网舆情
  • 西宁网站制作 青西安网约车
  • 泰安网站建设538sw百度网盘帐号登录入口
  • 网站制作费用是多少竞价网络推广托管
  • 做h5免费的网站有杭州seo关键字优化
  • logo接单平台seo网站推广seo
  • 网站开发 项目计划书中国互联网协会
  • 上海中学门户网站百度推广平台
  • 南京网站优化公司排名推广关键词如何优化
  • 甘肃网络公司网站网络舆情的网站
  • 怎么查网站是不是诈骗泰州网站排名seo
  • 微信可以做网站吗seo全网营销公司
  • 邯郸市做网站打开百度官网
  • 中网自助建站seo网站怎么搭建
  • 有哪些可以做兼职翻译的网站班级优化大师官方免费下载
  • 南阳做网站推广杭州最专业的seo公司
  • 有b开通的建行网站广告营销策略有哪些
  • 自己制作一个网站怎么制作杭州百度优化