Spark 动态上架下架worker

本文介绍了如何使用命令行工具动态管理Spark集群中的worker,包括启动、停止和查看worker状态。通过指定配置文件、操作类型、worker类路径、worker编号以及启动参数,可以灵活地对worker进行操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

关闭 $SPARK_HOME/sbin/spark-daemon.sh --config conf/ stop org.apache.spark.deploy.worker.Worker 1 --webui-port 8081 spark://llc1:7077

开启 $SPARK_HOME/sbin/spark-daemon.sh --config conf/ start org.apache.spark.deploy.worker.Worker 1 --webui-port 8081 -c 24 -m 60G spark://llc1:7077

使用命令

$SPARK_HOME/sbin/spark-daemon.sh [--config <conf-dir>] (start|stop|status) <spark-command> <spark-instance-number> <args...>

第一个参数 : –config $SPARK_HOME/conf
第二个参数 : start|stop|status
第三个参数 : org.apache.spark.deploy.worker.Worker(worker类的路径)
第四个参数 : 这个worker的号码,根据机器上已有的worker数来看
第五个参数 : 启动时的参数,下面是源码解析参数类 WorkerArguments.scala 中截取,都很清楚,传自己需要的参数即可

private def parse(args: List[String]): Unit = args match {
  case ("--ip" | "-i") :: value :: tail =>
    Utils.checkHost(value, "ip no longer supported, please use hostname " + value)
    host = value
    parse(tail)

  case ("--host" | "-h") :: value :: tail =>
    Utils.checkHost(value, "Please use hostname " + value)
    host = value
    parse(tail)

  case ("--port" | "-p") :: IntParam(value) :: tail =>
    port = value
    parse(tail)

  case ("--cores" | "-c") :: IntParam(value) :: tail =>
    cores = value
    parse(tail)

  case ("--memory" | "-m") :: MemoryParam(value) :: tail =>
    memory = value
    parse(tail)

  case ("--work-dir" | "-d") :: value :: tail =>
    workDir = value
    parse(tail)

  case "--webui-port" :: IntParam(value) :: tail =>
    webUiPort = value
    parse(tail)

  case ("--properties-file") :: value :: tail =>
    propertiesFile = value
    parse(tail)

  case ("--help") :: tail =>
    printUsageAndExit(0)

  case value :: tail =>
    if (masters != null) {  // Two positional arguments were given
      printUsageAndExit(1)
    }
    masters = Utils.parseStandaloneMasterUrls(value)
    parse(tail)

  case Nil =>
    if (masters == null) {  // No positional argument was given
      printUsageAndExit(1)
    }

  case _ =>
    printUsageAndExit(1)
}

一个例子

$SPARK_HOME/sbin/spark-daemon.sh --config conf/ start org.apache.spark.deploy.worker.Worker 1 --webui-port 8082 -c 4 -m 9G spark://llc1:7077
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值