我很好奇!据我所知,hdfs需要datanode进程来运行,这就是它只在服务器上工作的原因。spark可以在本地运行,但是需要winutils.exe,这是hadoop的一个组件。但它到底做什么呢?为什么我不能在windows上运行hadoop,但是我可以运行spark,它是在hadoop上构建的?
t2a7ltrp1#
我知道至少有一种用法,那就是在windows操作系统上运行shell命令。你可以在里面找到它 org.apache.hadoop.util.Shell ,其他模块依赖于这个类并使用它的方法,例如 getGetPermissionCommand() 方法:
org.apache.hadoop.util.Shell
getGetPermissionCommand()
static final String WINUTILS_EXE = "winutils.exe"; ... static { IOException ioe = null; String path = null; File file = null; // invariant: either there's a valid file and path, // or there is a cached IO exception. if (WINDOWS) { try { file = getQualifiedBin(WINUTILS_EXE); path = file.getCanonicalPath(); ioe = null; } catch (IOException e) { LOG.warn("Did not find {}: {}", WINUTILS_EXE, e); // stack trace comes at debug level LOG.debug("Failed to find " + WINUTILS_EXE, e); file = null; path = null; ioe = e; } } else { // on a non-windows system, the invariant is kept // by adding an explicit exception. ioe = new FileNotFoundException(E_NOT_A_WINDOWS_SYSTEM); } WINUTILS_PATH = path; WINUTILS_FILE = file; WINUTILS = path; WINUTILS_FAILURE = ioe; } ... public static String getWinUtilsPath() { if (WINUTILS_FAILURE == null) { return WINUTILS_PATH; } else { throw new RuntimeException(WINUTILS_FAILURE.toString(), WINUTILS_FAILURE); } } ... public static String[] getGetPermissionCommand() { return (WINDOWS) ? new String[] { getWinUtilsPath(), "ls", "-F" } : new String[] { "/bin/ls", "-ld" }; }
t3irkdon2#
虽然马克斯的答案涵盖了它被引用的实际位置。让我简单介绍一下为什么它需要在windows上使用它-从hadoop的合流页面本身来看-hadoop需要windows上的本机库才能正常工作,这包括访问file://文件系统,hadoop使用一些windows API来实现类似posix的文件访问权限。这是在hadoop.dll和winutils.exe中实现的。尤其是,%hadoop\u home%\bin\winutils.exe必须是可定位的而且,我认为您应该能够在windows上运行spark和hadoop。
2条答案
按热度按时间t2a7ltrp1#
我知道至少有一种用法,那就是在windows操作系统上运行shell命令。你可以在里面找到它
org.apache.hadoop.util.Shell
,其他模块依赖于这个类并使用它的方法,例如getGetPermissionCommand()
方法:t3irkdon2#
虽然马克斯的答案涵盖了它被引用的实际位置。让我简单介绍一下为什么它需要在windows上使用它-
从hadoop的合流页面本身来看-
hadoop需要windows上的本机库才能正常工作,这包括访问file://文件系统,hadoop使用一些windows API来实现类似posix的文件访问权限。
这是在hadoop.dll和winutils.exe中实现的。
尤其是,%hadoop\u home%\bin\winutils.exe必须是可定位的
而且,我认为您应该能够在windows上运行spark和hadoop。