我面临着fabric2命令模块的奇怪行为。这些命令就像一个魅力:
connect = Connection(host=h, user=u ,connect_kwargs={"password":p})
connect.run('mkdir temp_streaming')
connect.put(m, "temp_streaming/mapper.py")
connect.put(r, "temp_streaming/reducer.py")
但是当涉及到这个时:
input_path = input("Please choose the input of your program (on your HDFS File System) ")
output_path = input("Please choose a name for your output folder ")
main_command = str('yarn jar '+ jar_path+' -files mapper.py,reducer.py -mapper temp_streaming/mapper.py -reducer temp_streaming/reducer.py -input '+ input_path + ' -output '+ output_path)
connect.run(main_command)
我得到这个错误,我无法弄清楚:
bash: yarn: command not found
Traceback (most recent call last):
File "__main.py__", line 77, in <module>
main()
File "__main.py__", line 65, in main
RunMapReduce(mapper, reducer, jar_path)
File "__main.py__", line 46, in RunMapReduce
connect.run(main_command)
File "<decorator-gen-3>", line 2, in run
File "/usr/local/lib/python3.5/dist-packages/fabric2/connection.py", line 30, in opens
return method(self, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/fabric2/connection.py", line 586, in run
return self._run(runner, command, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/invoke/context.py", line 100, in _run
return runner.run(command, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/invoke/runners.py", line 268, in run
return self._run_body(command, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/invoke/runners.py", line 401, in _run_body
raise UnexpectedExit(result)
invoke.exceptions.UnexpectedExit: Encountered a bad command exit code!
Command: 'yarn jar /home/hadoop/hadoop/share/hadoop/tools/lib/hadoop-streaming-2.8.4.jar -files mapper.py,reducer.py -mapper temp_streaming/mapper.py -reducer temp_streaming/reducer.py -input /books/kafka_metamorphosis.txt -output /test'
Exit code: 127
Stdout: already printed
Stderr: already printed
当我使用ssh直接登录服务器并运行它时,即使此bash命令正常工作,它就像远程服务器不知道 yarn 命令一样。在我看来,它与这个库有关,但我无法用文档解决我的问题。
答案 0 :(得分:3)
我也遇到了这个问题:结果是Fabric运行的SSH是非交互式shell 。包含$PATH
bin路径的yarn
变量在/etc/profile
或~/.bash_profile
或~/.bashrc
中设置,其中没有一个来源。
Here is the link,以及一些解决方案。
就个人而言,我不喜欢玩那些文件=&gt;我刚刚做了什么(在绊倒这个链接之前)是我使用二进制文件的完整路径:/usr/bin/yarn [the rest of your command]