You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法通过WebHDFS向Hadoop传输文件,遇HTTP 307错误求助

Fixing 307 TEMPORARY_REDIRECT When Uploading Files to Hadoop via WebHDFS

Hey there, let's break down what's happening here and how to fix it. That 307 redirect isn't actually an error—it's WebHDFS doing its job! Here's why, and how to complete your file upload:

Why You're Seeing the 307 Redirect

WebHDFS operates in two distinct steps for file uploads:

  1. You send a CREATE request to the NameNode (your myip:50070 address) to initiate the upload process.
  2. The NameNode responds with a 307 redirect, pointing you to the DataNode where the actual file content should be sent. This is normal behavior—NameNodes only manage metadata, they don't store file content directly.

Step-by-Step Fix

Let's walk through the full process to get your file uploaded successfully:

  1. Re-run your initial CREATE request and capture the Location header
    Your original command is correct for the first step:

    curl -i -X PUT "http://myip:50070/webhdfs/v1/tmp/tempForTest.txt?user.name=hadoop&op=CREATE&overwrite=false&createparent=false&replication=1&permission=777"
    

    Look for a line in the response starting with Location:—this is the DataNode URL you need to send your file content to. It will look similar to this:

    Location: http://datanode-ip:50075/webhdfs/v1/tmp/tempForTest.txt?user.name=hadoop&op=CREATE&overwrite=false&replication=1&permission=777&namenoderpcaddress=myip:8020&createflag=&createparent=false

  2. Upload your file to the DataNode URL
    Use curl's -T flag to send your local file to the copied Location URL. Replace /path/to/your/local/tempForTest.txt with the actual path to your file on your machine:

    curl -i -X PUT -T /path/to/your/local/tempForTest.txt "http://datanode-ip:50075/webhdfs/v1/tmp/tempForTest.txt?user.name=hadoop&op=CREATE&overwrite=false&replication=1&permission=777&namenoderpcaddress=myip:8020&createflag=&createparent=false"
    

Quick Checks to Avoid Other Issues

  • If overwrite=false, make sure /tmp/tempForTest.txt doesn't already exist in HDFS—delete it first if it does.
  • createparent=false requires the /tmp directory to already exist in HDFS. Run hdfs dfs -ls /tmp to confirm it's present.
  • Verify the hadoop user has write permissions on the /tmp directory in HDFS. You can check this with hdfs dfs -ls /.

That should get your file uploaded without issues!

内容的提问来源于stack exchange,提问作者김태우

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:40:13