如何在Apache Spark Cluster模式下运行更多的执行程序

问题描述:

我有50名工人,我想在我的所有工人上运行我的工作。
在主:8080,我可以看到有所有工人,
在主机:4040 /执行人,我可以看到50个执行人,
但是当我跑我的工作,信息显示是这样的:
如何在Apache Spark Cluster模式下运行更多的执行程序

14/10/19 14:57:07 INFO scheduler.TaskSchedulerImpl: Adding task set 0.0 with 1 tasks 
14/10/19 14:57:07 INFO scheduler.TaskSetManager: Starting task 0.0 in stage 0.0 (TID 0, slave11, NODE_LOCAL, 1302 bytes) 
14/10/19 14:57:07 INFO nio.ConnectionManager: Accepted connection from [slave11/10.10.10.21:42648] 
14/10/19 14:57:07 INFO nio.SendingConnection: Initiating connection to [slave11/10.10.10.21:54398] 
14/10/19 14:57:07 INFO nio.SendingConnection: Connected to [slave11/10.10.10.21:54398], 1 messages pending 
14/10/19 14:57:07 INFO storage.BlockManagerInfo: Added broadcast_1_piece0 in memory on slave11:54398 (size: 2.4 KB, free: 267.3 MB) 
14/10/19 14:57:08 INFO storage.BlockManagerInfo: Added broadcast_0_piece0 in memory on slave11:54398 (size: 18.4 KB, free: 267.2 MB) 
14/10/19 14:57:12 INFO storage.BlockManagerInfo: Added rdd_2_0 in memory on slave11:54398 (size: 87.4 MB, free: 179.8 MB) 
14/10/19 14:57:12 INFO scheduler.DAGScheduler: Stage 0 (first at GeneralizedLinearAlgorithm.scala:141) finished in 5.473 s 
14/10/19 14:57:12 INFO scheduler.TaskSetManager: Finished task 0.0 in stage 0.0 (TID 0) in 5463 ms on slave11 (1/1) 
14/10/19 14:57:12 INFO scheduler.TaskSchedulerImpl: Removed TaskSet 0.0, whose tasks have all completed, from pool 


而且我的工作像这样的代码:(命令行)

master: $ ./spark-shell --master spark://master:7077 


这个(Scala代码):

import org.apache.spark.SparkContext 
import org.apache.spark.mllib.classification.SVMWithSGD 
import org.apache.spark.mllib.evaluation.BinaryClassificationMetrics 
import org.apache.spark.mllib.regression.LabeledPoint 
import org.apache.spark.mllib.linalg.Vectors 
import org.apache.spark.mllib.util.MLUtils 

val fileName = "bc.txt" 
val data = sc.textFile(fileName) 

val splits = data.randomSplit(Array(0.9, 0.1), seed = 11L) 
val training = splits(0).cache() 
val test = splits(1) 

val training_1 = training.map { line => 
val parts = line.split(' ') 
LabeledPoint(parts(0).toDouble, Vectors.dense(parts(1).split(' ').map(x => x.toDouble).toArray)) 
} 

val test_1 = test.map { line => 
val parts = line.split(' ') 
LabeledPoint(parts(0).toDouble, Vectors.dense(parts(1).split(' ').map(x => x.toDouble).toArray)) 
} 
val numIterations = 200 

val model = SVMWithSGD.train(training_1, numIterations) 


我的问题是,为什么只有一个或我的群集在两个(有时)任务运行?
是否有任何方式来配置任务的数量,或者是由调度程序自动调度?
当我的工作在两个任务上运行时,它将与我在master上观察到的两个执行程序一起运行:4040,
它会给2倍加速,所以我想在所有执行程序上运行我的工作,我该怎么做?

谢谢大家。

可以使用minPartitions参数textFile设定最小数量的任务,如:

val data = sc.textFile(fileName, 10) 

然而,更多的分区通常意味着更多的网络流量,因为更多的分区,使星火很难调度任务的本地执行者运行。你需要自己找到一个余额号码minPartitions

+0

感谢您的回答,但我更改我的代码为“val data = sc.textFile(fileName,50)”就像您说的,在master:4040可以看到,RDD块现在总计50个(50个分区) ,但仍然只有两台机器运行所有任务,我想安排50个分区到我的所有机器,如何设置它?再次感谢! – 2014-10-20 09:29:36

+0

[link] https://www.dropbox.com/s/5qqv1t0fgudzllt/%E8%9E%A2%E5%B9%95%E5%BF%AB%E7%85%A7%202014-10-20%20 %E4%B8%8B%E5%8D%885.33.22.jpg?dl = 0 – 2014-10-20 09:35:13

+0

每个员工有多少个核心?如果它大于25,是的,它可能只派遣两台机器。 – zsxwing 2014-10-20 11:18:55