在调用collect()之后,我正在尝试保存一个RDD。我调用星星之火-提交主机-1(我假设驱动程序是我调用火花提交脚本的主机,所以在本例中主机-1是驱动程序),从HBase获取一些数据,运行一些操作,然后在RDD上调用get (),然后遍历收集的列表并将其保存到本地文件系统文件中。实质上:
if __name__ == "__main__":
sc = SparkContext(appName="HBaseInputFormat")
# read the data from hbase
# ...
# ...
output = new_rdd.collect()
with open("/var/tmp/tmpfile.csv", 'w') as tmpf:
for o in output:
print (o)
tmpf.write("%s\n"%str(o))
tmpf.close()这实际上对保存在/var/tmp/tmpfile.csv中的数据很好,除非数据保存在与驱动程序不同的主机上,比如Host-3。我的印象是,collect总是收集驱动程序主机上的分布式数据集,因此也应该在驱动程序上创建文件。我哪里错了?
发布于 2015-08-28 21:44:39
我假设驱动程序是我调用星火提交脚本的主机,所以在本例中,主机-1是驱动程序。
它不正确!请参阅关于在纱线上运行火花的文档。
In yarn-cluster mode, the Spark driver runs inside an application master process which is managed by YARN on the cluster, and the client can go away after initiating the application. In yarn-client mode, the driver runs in the client process, and the application master is only used for requesting resources from YARN.
您可能是在纱线集群模式下运行spark,并且选择驱动程序在集群中的一个节点上。
将其更改为纱线-客户端,驱动程序将在提交作业的节点上运行。
https://stackoverflow.com/questions/32279715
复制相似问题