Spark standalone 与 GlusterFS 配合使用

Spark with glusterfs

测试设备架构

在这里插入图片描述

测试环境搭建过程

  1. 搭建GlusterFS,测试环境中用的是两个节点做GlusterFS,备份数是两份
  2. 搭建Spark Standalone环境,三台机器做Spark Standalone集群,其中每台GlusterFS上都要配置为Spark的Worker机
  3. 三台Spark机器上都要挂载glusterfs的文件到同一个目录
    mount -t glusterfs slave1:/test /data/mnt/glusterfs/
    

Spark WordCount 代码

代码:

	package spark.wordcount
	import org.apache.spark.{SparkConf, SparkContext}
	object SparkWordCount {
		def main(args: Array[String]):Unit = {
			val conf = new SparkConf().setAppName("Spark Word Count")
			val sc = new SparkContext(conf)
			val startTime:Long = sc.startTime
			println(startTime)
			val words = sc.textFile("/data/mnt/glusterfs/test/")
			words.map(c => (c, 1)).reduceByKey(_ + _).collect().foreach(println(_))
		}
	}

提交jar包命令脚本:

	$SPARK_HOME/bin/spark-submit \
		--master spark://Master:7077 \
		--num-executors 2 \
		--class spark.wordcount.SparkWordCount \
		--conf spark.dynamicAllocation.enabled=false \
		ScalaWordCount.jar

Tips:

  1. 注意挂载glusterfs目录到每一个Spark节点,Master也必须挂载
  2. 注意提交任务时,添加参数–conf spark.dynamicAllocation.enabled=false,目的是为了如下问题解决问题在这里插入图片描述
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值