spark有四种运行模式,standalone,yarn,mesos,local。
yarn又分为client,cluster两种。系统默认使用client。这两者区别是
- client模式中,driver分给一个节点,如果这个节点宕机,则运行失败。
- cluster模式,driver分给每个节点,如果一个节点宕机,没有关机,其他节点会顶替上来。所以cluster比client性能好。
测试代码时候经常使用spark-submit提交代码,然后配好各种参数,参数有哪些呢?看一下源码:
override def toString: String = {
s"""Parsed arguments:
| master $master
| deployMode $deployMode
| executorMemory $executorMemory
| executorCores $executorCores
| totalExecutorCores $totalExecutorCores
| propertiesFile $propertiesFile
| driverMemory $driverMemory
| driverCores $driverCores
| driverExtraClassPath $driverExtraClassPath
| driverExtraLibraryPath $driverExtraLibraryPath
| driverExtraJavaOptions $driverExtraJavaOptions
| supervise $supervise
| queue $queue
| numExecutors $numExecutors
| files $files
| pyFiles $pyFiles
| archives $archives
| mainClass $mainClass
| primaryResource $primaryResource
| name $name
| childArgs [${childArgs.mkString(" ")}]
| jars $jars
| packages $packages
| packagesExclusions $packagesExclusions
| repositories $repositories
| verbose $verbose
|
|Spark properties used, including those specified through
| --conf and those from the properties file $propertiesFile:
|${Utils.redact(sparkProperties).mkString(" ", "\n ", "\n")}
""".stripMargin
}
- master:你的提交模式。
- deployMode:你得细分提交模式,类似于yarn下的client/cluster。
- executorMemory :executor的内存,这个参数根据你节点内存来分配,不能大于单台节点最大内存数。
- executorCores :executor分配的核数。
- totalExecutorCores:executor分配的总共核数。
- propertiesFile:你的配置参数文件,用在–conf后面。
- driverMemory:driver的内存数,driver内存和executor内存加起来不能超过单节点的最大内存数。
- driverCores:driver的核数。
- driverExtraClassPath:额外的classpath,将插入到到驱动器的classpath开头。
- driverExtraLibraryPath:driver额外的依赖库。
- driverExtraJavaOptions:driver额外的java参数。
- supervise:程序在非0退出时候重启程序。
- queue: 执行程序jar包的队列,适用于多个程序依次运行。
- numExecutors:executor的个数。
- files:配置文件。
- pyFiles:python写的文件。
- archives:要提取到每个执行器的工作目录中的以逗号分隔的存档列表。
- mainClass:你执行程序的主类。
- childArgs :子参数。
- jars:你程序的依赖jar。
- packages:你程序的依赖包。可以把依赖jar放到一个包中,这个包称为依赖包。
- verbose:打印其他调试输出。
- name:你程序的appname。
- repositories:打印其他调试输出。以逗号分隔的其他远程存储库列表。
看着参数挺多,其实真正用到的也就不到10个。
坚持就是胜利。
每天进步一点点,积少成多。