Windows10单节点Hadoop本地文件复制报错:No such file or directory
Hey there, let's work through this HDFS file copy issue together—I've dealt with similar quirks running Hadoop on Windows before, so here's a breakdown of the most likely fixes:
1. Verify Your Local File Path & Current Working Directory
First off, relative paths like ../my_models/*.model can be tricky in Windows' command line. Let's confirm the basics:
- Open your cmd/PowerShell and run
cd(cmd) orGet-Location(PowerShell) to check your current working directory. Calculate if../my_modelsactually points to the right folder. For example, if you're inC:\hadoop\bin,../my_modelswould beC:\hadoop\my_models—double-check this folder exists and contains your.modelfiles. - Test if the wildcard works locally first: run
dir ../my_models/*.model(cmd) orGet-ChildItem ../my_models/*.model(PowerShell). If this returns "file not found", either the path is wrong, or Windows isn't expanding the*wildcard correctly for Hadoop.
2. Switch to Absolute Paths
Relative paths are prone to confusion—replace them with full absolute paths to eliminate ambiguity. For example:
hadoop fs -copyFromLocal C:\full\path\to\my_models\*.model hdfs://localhost/tmp
If that still fails, test with a single file first to rule out wildcard issues:
hadoop fs -copyFromLocal C:\full\path\to\my_models\aaa.model hdfs://localhost/tmp
3. Check HDFS Target Path Exists
While your error points to local files, it's worth confirming the HDFS target isn't the problem. Run this to check if /tmp exists:
hadoop fs -ls hdfs://localhost/tmp
If it doesn't exist, create it first:
hadoop fs -mkdir -p hdfs://localhost/tmp
4. Fix Windows Permissions
Windows' user permissions can block Hadoop from accessing local files. Try these steps:
- Right-click your command prompt/PowerShell and select Run as administrator, then re-execute the copy command.
- Ensure your current user has read permissions for the
my_modelsfolder and all.modelfiles inside it.
5. Work Around Windows Wildcard Limitations
Windows CMD doesn't expand wildcards like Linux shells do, which can cause Hadoop to receive the literal *.model string instead of the actual file list. Try these alternatives:
- Use PowerShell instead of CMD—it handles wildcards properly and will expand
*.modelto the actual file names before passing them to Hadoop. - Manually list all files in the command:
hadoop fs -copyFromLocal ../my_models/aaa.model ../my_models/bbb.model hdfs://localhost/tmp
内容的提问来源于stack exchange,提问作者Dims

