分享

sparkstreaming的提交就卡死

remarkzhao 发表于 2017-7-20 17:24:37 [显示全部楼层] 只看大图 回帖奖励 阅读模式 关闭右栏 24 14922
弱弱请教一下各位大神。。。这是什么情况。




运行spark官网上的一个streaming 程序 用spark-submit提交上去就卡死在那,没有任何反应    local模式


spark-submit --class "org.apache.spark.examples.streaming.DataSourceSocket"  /root/tools/spark/mycode/streaming/target/scala-2.11/simple-project_2.11-1.0.jar /root/tools/spark/mycode/streaming/word.txt 9999 1000  



已有(24)人评论

跳转到指定楼层
langke93 发表于 2017-7-20 18:38:26
按照下面格式
[mw_shl_code=bash,true]spark-submit \
--class  org.apache.spark.examples.streaming.DataSourceSocket  \
--master local[3] \
/root/tools/spark/mycode/streaming/target/scala-2.11/simple-project_2.11-1.0.jar \
10[/mw_shl_code]


/root/tools/spark/mycode/streaming/word.txt
这个文件是干什么的,建议你看看spark submit参数的含义



回复

使用道具 举报

remarkzhao 发表于 2017-7-21 08:15:35
langke93 发表于 2017-7-20 18:38
按照下面格式
[mw_shl_code=bash,true]spark-submit \
--class  org.apache.spark.examples.streaming.Da ...

这个是参数,这条命令有3个参数,word.txt是文件。9999是端口,1000是sleep time
回复

使用道具 举报

remarkzhao 发表于 2017-7-21 08:16:23
langke93 发表于 2017-7-20 18:38
按照下面格式
[mw_shl_code=bash,true]spark-submit \
--class  org.apache.spark.examples.streaming.Da ...

我用的是local模式的话不用 --master这个参数把?
回复

使用道具 举报

nextuser 发表于 2017-7-21 09:27:57
remarkzhao 发表于 2017-7-21 08:16
我用的是local模式的话不用 --master这个参数把?

应该需要的,可以参考下其它资料
回复

使用道具 举报

remarkzhao 发表于 2017-7-21 09:29:57
nextuser 发表于 2017-7-21 09:27
应该需要的,可以参考下其它资料

master应该是集群的情况下把?
回复

使用道具 举报

remarkzhao 发表于 2017-7-21 09:30:41
这是我的代码:

object DataSourceSocket {
  def index(length: Int) = {

    val rdm = new java.util.Random

    rdm.nextInt(length)
  }
  def main(args: Array[String]) {
    if (args.length != 3) {
      System.err.println("Usage: <filename> <port> <millisecond>")
      System.exit(1)
    }

    val fileName = args(0)
    val lines = Source.fromFile(fileName).getLines.toList
    val rowCount = lines.length

    val listener = new ServerSocket(args(1).toInt)
    while (true) {
      val socket = listener.accept()
      new Thread() {
                      override def run = {
          println("Got client connected from: " + socket.getInetAddress)
          val out = new PrintWriter(socket.getOutputStream(), true)
          while (true) {
            Thread.sleep(args(2).toLong)
            val content = lines(index(rowCount))
            println(content)
            out.write(content + '\n')
            out.flush()
          }
          socket.close()
        }
      }.start()
    }
  }
}

有点焦躁。
回复

使用道具 举报

nextuser 发表于 2017-7-21 09:39:10
remarkzhao 发表于 2017-7-21 09:30
这是我的代码:

object DataSourceSocket {

最好上图,你是怎么提交的,下面提交出现了什么问题[mw_shl_code=bash,true]spark-submit \
--class  org.apache.spark.examples.streaming.DataSourceSocket  \
--master local[3] \
/root/tools/spark/mycode/streaming/target/scala-2.11/simple-project_2.11-1.0.jar \
10[/mw_shl_code]

,都贴出来看下。

回复

使用道具 举报

remarkzhao 发表于 2017-7-21 09:45:37
spark-submit \
--class "org.apache.spark.examples.streaming.DataSourceSocket" \

/root/tools/spark/mycode/streaming/target/scala-2.11/simple-project_2.11-1.0.jar \

/root/tools/spark/mycode/word.txt 9999 1000


自定义数据源   /root/tools/spark/mycode/word.txt  这个是数据的源头

代码是随机产生word.txt的任意内容。
回复

使用道具 举报

sstutu 发表于 2017-7-21 09:49:36
本帖最后由 sstutu 于 2017-7-21 09:51 编辑
remarkzhao 发表于 2017-7-21 09:30
这是我的代码:

object DataSourceSocket {

def main(args: Array[String]) {
    if (args.length != 3) {
      System.err.println("Usage: <filename> <port> <millisecond>")
      System.exit(1)
    }
你这里直接堵死了。跳出了,并不是卡死。
还有这三个参数,你认为spark该如何识别,word.txt是文件。9999是端口,1000是sleep time.
这不是人工智能。如果提交的时候,他们的顺序发生变化该怎么办。并且spark提交参数是变化的。

回复

使用道具 举报

123下一页
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条