使用 PySpark 使用 Kerberos 身份验证读取 HDFS 上的文件



我有一个带有 Kerberos 身份验证的 HDFS 集群。如何使用 PySpark 读取 HDFS 上的文件。

尽量

避免太多评论,这是你可以做的:

custom_conf={
                 "master":"local[*]",
                 "spark.executor.memory" : "44g",
                 "spark.executor.cores" : "60",
                 "spark.executor.instances":"60",
                 "spark.yarn.keytab" : <path to keytab>,
                 "spark.yarn.principal" : <principal name@domain>,
                 "appName" : <specify app name>
                    }
sc_conf = SparkConf()
sc = sc = SparkContext()
sc_conf.setAppName(custom_conf["appName"])
sc_conf.setMaster(custom_conf["master"])
sc_conf.set('spark.executor.memory', custom_conf["spark.executor.memory"])
sc_conf.set('spark.executor.cores', custom_conf["spark.executor.cores"])
sc_conf.set('spark.yarn.keytab', custom_conf["spark.yarn.keytab"])
sc_conf.set('spark.yarn.principal', custom_conf["spark.yarn.principal"])
sc_conf.set('spark.executor.instances', custom_conf["spark.executor.instances"])

try:
    sc.stop()
    sc = SparkContext(conf=sc_conf)
except:
    sc = SparkContext(conf=sc_conf)

然后,您可以使用新的 SC 进行处理。

最新更新