【发布时间】:2015-08-19 10:50:44
【问题描述】:
我想在集群上运行我的代码: 我的代码:
import java.util.Properties
import edu.stanford.nlp.ling.CoreAnnotations._
import edu.stanford.nlp.pipeline._
import org.apache.spark.{SparkConf, SparkContext}
import scala.collection.JavaConversions._
import scala.collection.mutable.ArrayBuffer
object Pre2 {
def plainTextToLemmas(text: String, pipeline: StanfordCoreNLP): Seq[String] = {
val doc = new Annotation(text)
pipeline.annotate(doc)
val lemmas = new ArrayBuffer[String]()
val sentences = doc.get(classOf[SentencesAnnotation])
for (sentence <- sentences; token <- sentence.get(classOf[TokensAnnotation])) {
val lemma = token.get(classOf[LemmaAnnotation])
if (lemma.length > 0 ) {
lemmas += lemma.toLowerCase
}
}
lemmas
}
def main(args: Array[String]): Unit = {
val conf = new SparkConf()
.setMaster("local")
.setAppName("pre2")
val sc = new SparkContext(conf)
val plainText = sc.textFile("data/in.txt")
val lemmatized = plainText.mapPartitions(p => {
val props = new Properties()
props.put("annotators", "tokenize, ssplit, pos, lemma")
val pipeline = new StanfordCoreNLP(props)
p.map(q => plainTextToLemmas(q, pipeline))
})
val lemmatized1 = lemmatized.map(l => l.head + l.tail.mkString(" "))
val lemmatized2 = lemmatized1.filter(_.nonEmpty)
lemmatized2.coalesce(1).saveAsTextFile("data/out.txt)
}
}
和集群功能:
2 个节点
每个节点有:60g RAM
每个节点有:48 个核心
共享磁盘
我在这个集群上安装了 Spark,其中一个节点作为 master 和 worker,另一个节点是 worker。
当我在终端中使用此命令运行我的代码时:
./bin/spark-submit --master spark://192.168.1.20:7077 --class Main --deploy-mode 集群代码/Pre2.jar
它显示:
15/08/19 15:27:21 WARN RestSubmissionClient:无法连接到 服务器火花://192.168.1.20:7077。警告:主端点 spark://192.168.1.20:7077 不是 REST 服务器。回落到 旧版提交网关。 15/08/19 15:27:22 警告 NativeCodeLoader:无法为您的本地 Hadoop 库加载 平台......在适用的情况下使用内置java类驱动程序 成功提交为 driver-20150819152724-0002 ... 等待 在轮询主机以获取驱动程序状态之前...轮询主机以获取驱动程序 state driver-20150819152724-0002 的状态为 RUNNING 驱动程序正在运行 1192.168.1.19:33485(工人-20150819115013-192.168.1.19-33485)
如何在 Spark 独立集群上运行上述代码?
【问题讨论】:
-
您的消息显示
RUNNING,它似乎运行正常。 -
它不返回任何东西。在ui模式状态下失败
-
... UI 是否提供有关失败原因的更多详细信息?
-
不,没有更多细节。
-
您说的是
--class Main,但您似乎没有一个名为Main的类,而且您将master硬编码为local
标签: apache-spark cluster-computing