hadoop distcp使用子流程.Popen

2024-10-03 00:24:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用运行hadoop distcp命令子流程.Popen并获取错误-无效输入。如果我以Hadoop命令运行,同样的命令可以正常运行。在

Hadoop命令:

hadoop distcp -log /user/name/distcp_log -skipcrccheck -update hdfs://xxxxx:8020/sourceDir hdfs://xxxxx:8020/destDir

在python中:

^{pr2}$

日志消息:

INFO tools.OptionsParser: parseChunkSize: blocksperchunk false
INFO tools.DistCp: Input Options: DistCpOptions{atomicCommit=false, syncFolder=false, deleteMissing=false, ignoreFailures=false, overwrite=false, append=false, useDiff=false, useRdiff=false, fromSnapshot=null, toSnapshot=null, skipCRC=false, blocking=true, numListstatusThreads=0, maxMaps=20, mapBandwidth=100, sslConfigurationFile='null', copyStrategy='uniformsize', preserveStatus=[], preserveRawXattrs=false, atomicWorkPath=null, logPath=null, sourceFileListing=null, sourcePaths=[-log /user/name/distcp_log -skipcrccheck -update, hdfs://xxxxx:8020/sourceDir], targetPath=hdfs://xxxxx:8020/destDir, targetPathExists=true, filtersFile='null', blocksPerChunk=0, copyBufferSize=8192}
ERROR tools.DistCp: Invalid input:
org.apache.hadoop.tools.CopyListing$InvalidInputException: -log /user/name/distcp_log -skipcrccheck -update doesn't exist

它将选项视为源目录。 如何告诉子进程这些是选项,不应被视为源(sourcePaths=[-log/user/name/distcp_log-skipcrcheck-update,hdfs://xxxxx源目录:8020)?在

我使用的是Python2.7,无法访问pip install及其Kerberos集群。 想在集群内传输时运行这个命令,但在此之前,想在集群内尝试这个简单的命令。在

谢谢


Tags: name命令hadooplogfalse集群updatehdfs
1条回答
网友
1楼 · 发布于 2024-10-03 00:24:20

将命令行的所有参数拆分为Popen first argument list的单独元素:

from subprocess import Popen, PIPE
proc1 = Popen(['hadoop','distcp','-log', '/user/name/distcp_log', '-skipcrccheck', '-update', 'hdfs://xxxxx:8020/sourceDir', 'hdfs://xxxxx:8020/destDir'], stdout=subprocess.PIPE)

Here您可以找到Popen文档,其中说args应该是一个由' '拆分所有参数而创建的列表。在

相关问题 更多 >