如果是从pysparkshell里面进去,此时已经有了pyspark环境了,所以要加一个:sc.stop()
from pyspark import SparkContext, SparkConf
sc.stop()
conf = SparkConf()
conf.setAppName(‘zhangb‘)
#conf.set("spark.kryoserializer.buffer.mb", "128")
conf.set("spark.kryoserializer.buffer", "128k")
conf.set("spark.kryoserializer.buffer.max", "256m")
sc = SparkContext(conf=conf)
如果提交脚本上去,此时还没有pyspark环境,所以不用sc.stop(),直接创建环境参数。但是可能需要在程序结束后加上sc.stop()
from pyspark import SparkContext, SparkConf
conf = SparkConf()
conf.setAppName(‘zhangb‘)
#conf.set("spark.kryoserializer.buffer.mb", "128")
conf.set("spark.kryoserializer.buffer", "128k")
conf.set("spark.kryoserializer.buffer.max", "256m")
sc = SparkContext(conf=conf)
#===代码
#......
#=====代码
sc.stop()
时间: 2024-10-26 22:52:32