8

【Azure 存储服务】Hadoop集群中使用ADLS(Azure Data Lake Storage)过程中遇见执行PUT...

 2 years ago
source link: https://www.cnblogs.com/lulight/p/16475226.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

【Azure 存储服务】Hadoop集群中使用ADLS(Azure Data Lake Storage)过程中遇见执行PUT操作报错

在Hadoop集中中,使用ADLS 作为数据源,在执行PUT操作(上传文件到ADLS中),遇见 400错误【put: Operation failed: "An HTTP header that's mandatory for this request is not specified.", 400】

启用Debug输出详细日志:

2127802-20220713190501679-790918360.png

错误消息文本内容:

ContractedBlock.gifExpandedBlockStart.gif

View Code

虽然在Hadoop 中执行的 PUT指令如下:

./hadoop fs -put a.txt abfs://[email protected]/test.txt

但实质上,也时发送的REST API来操作ADLS资源。 所以参考PUT Blob的接口文档:https://docs.microsoft.com/en-us/rest/api/storageservices/put-blob#request-headers-all-blob-types

它必须的Header参数有:x-ms-version,x-ms-blob-type,x-ms-lease-id,Authorization,x-ms-date,Content-Length等。但是在Hadoop的日志中,我们只发现了 x-ms-version为 2018-11-09,缺少了x-ms-blob-type。

基于这一发现,我们通过Postman复现了同样的错误:

2127802-20220713191817917-861398269.png

虽然找到了发生问题的根源,但是在Hadoop中,如何来解决呢? 为什么使用 -put , -ls 等指令都会出现 HTTP Header miss 的问题呢?  按照Hadoop + ADLS 组合设计分析,不可能出现这样的严重错误而不进行修复。

回想 ADLS Gen 2专为大数据操作而设计。并且还特别启用了新的终结点(常规Blob操作终结点为:youradlsname.blob.core.chinacloudapi.cn , ADLS操作的终结点为:youradlsname.dfs.core.chinacloudapi.cn)

是否时我们在指令中使用了错误的终结点呢?

对比REST API 文档中,常规Blob的PUT操作和ADLS Create File的PUT操作,发现 ADLS PUT操作根本就不需要 x-ms-version,x-ms-blob-type 这两个Header 为必须。

2127802-20220713192938546-963089889.png

根据以上发现,在Hadoop put指令中修改 blob 为 dfs 测试。 问题完美解决!

2127802-20220713193146987-1152238501.png

以此次的错误,得出一个深刻的教训:当使用ADLS进行大数据相关操作时(如hadoop,databricks)一定一定要使用ADLS专用终结点:

xxxxxxx.dfs.core.chinacloudapi.cn

Filesystem - Create:https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/filesystem/create

Put Blob: https://docs.microsoft.com/en-us/rest/api/storageservices/put-blob#request-headers-all-blob-types

[END]


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK