用hadoop进行python流无法正常工作(python streaming with hadoop is not working)
我正在尝试使用python运行hadoop流式map-reduce作业。 我一直收到此错误消息,不知道如何解决它。
这是我正在使用的命令。
hdfs -jar /usr/local/hadoop/share/hadoop/tools/lib/hadoop-streaming-2.2.0.jar -input /input/ -output /out22 -mapper "python /mapper.py" -file /mapper.py -file /reducer.py -reducer "python /reducer.py"
这是错误信息。
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/util/Tool at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2570) at java.lang.Class.getMethod0(Class.java:2813) at java.lang.Class.getMethod(Class.java:1663) at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486) Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.util.Tool at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 6 more
我正在做什么有什么不对吗? 请帮忙。
I'm trying to run hadoop streaming map-reduce job using python. i keep getting this error message with no idea how to fix it.
this is the command I'm using.
hdfs -jar /usr/local/hadoop/share/hadoop/tools/lib/hadoop-streaming-2.2.0.jar -input /input/ -output /out22 -mapper "python /mapper.py" -file /mapper.py -file /reducer.py -reducer "python /reducer.py"
and here is the error message.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/util/Tool at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2570) at java.lang.Class.getMethod0(Class.java:2813) at java.lang.Class.getMethod(Class.java:1663) at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486) Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.util.Tool at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 6 more
is there anything wrong with what I'm doing ? please help.
原文:https://stackoverflow.com/questions/26077154
最满意答案
我想你不能在浏览器中使用
fs
模块。 在浏览器中有一个名为fs-web
的单独的npm模块用于fs
。 使用npm install fs-web --save
,您可以通过在客户端文件中导入它来使用它,如下所示,import * as fs from 'fs-web';
I think you can't use
fs
module in the browser. There is a separate npm module forfs
in the browser calledfs-web
. After installing this usingnpm install fs-web --save
, you can use it by importing it in the client side files like this,import * as fs from 'fs-web';
相关问答
更多-
从fs.readFileSync()到fs.readFile()的Node.js(Node.js from fs.readFileSync() to fs.readFile())[2022-11-03]
var fs = require("fs"); var filename = "./index.html"; function start(resp) { resp.writeHead(200, { "Content-Type": "text/html" }); fs.readFile(filename, "utf8", function(err, data) { if (err) throw err; resp.write(data ... -
两个主要区别: require()缓存结果,因此在后续使用require()读取JSON时将看不到对.json文件的更改,除非从require缓存中显式删除了结果。 require()是同步的, fs.readFile()是异步的。 当然,如果你想要同步行为(但不确定原因),你可以使用fs.readFileSync() )。 除此之外,你可以随心所欲地做到这一点。 如果缓存是个问题(例如你不想缓存),那么我会使用fs.readFile() 。 如果缓存是一个好处,那么我将使用require() 。 如果我明 ...
-
Fs模块错误(Fs Module error)[2023-09-29]
fs是nodejs的核心模块:这里是fs文档 I found the answer it should be executed in node command line and var filename = process.argv[2]; must be filled up. -
我想你不能在浏览器中使用fs模块。 在浏览器中有一个名为fs-web的单独的npm模块用于fs 。 使用npm install fs-web --save ,您可以通过在客户端文件中导入它来使用它,如下所示, import * as fs from 'fs-web'; I think you can't use fs module in the browser. There is a separate npm module for fs in the browser called fs-web. Aft ...
-
根据'fs'模块的Node.js API文档 ,如果encoding选项没有被传递, read函数将返回一个缓冲区。 如果你传递一个值进行编码,它将返回一个带有该编码的字符串: fs.readFile('/etc/passwd', 'utf-8', callback) As per the Node.js API docs for 'fs' module, if the encoding option isn't passed, the read functions will return a buffer ...
-
我通过一些反复试验弄明白了。 感谢@quirk指出我正确的方向。 另外, console.log(fs.readdirSync('.')) meteor-up部署中“/ public”文件夹的路径是: // console.log(fs.readdirSync('.')) => '/opt/my-app/current/bundle/programs/server' public_folder = '../../programs/web.browser/app' filepath = '../../prog ...
-
尝试先检查文件是否存在: var fs = require("fs"); console.log("Starting"); fs.exists("./sample.txt", function(fileok){ if(fileok)fs.readFile("./sample.txt", function(error, data) { console.log("Contents: " + data); }); else console.log("file not found"); }); ...
-
在browserify之后,fs.existsSync不是一个函数(electron, after browserify, fs.existsSync is not a function)[2023-11-12]
好的命令 npm install browserify-fs 然后是 browserify -fs main.js >main.bundle.js 解决了“fs.existsSnc不是一个功能”,但问题并非如此。 可能只是从问题中删除fs。 (提出此问题的原因:该回复出现了关于fs和browserify的问题 ) The conceptual solution for this problem: in "electron", "{dialog}=require(electron)" (e.g.,) i ... -
readFileSync是唯一支持的功能。 整个模块只有一个功能: exports.readFileSync = function(address) { var output; var xhr = new XMLHttpRequest(); xhr.open('GET', address, false); xhr.onreadystatechange = function(e) { if (xhr.readyState == 4) { var status = xhr.s ...
-
它是readFile()而不是readfile() (大写F与小写f )。 It's readFile() not readfile() (uppercase F vs lowercase f).