{"id":3766,"date":"2020-08-28T15:30:00","date_gmt":"2020-08-28T07:30:00","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=3766"},"modified":"2020-08-28T15:30:00","modified_gmt":"2020-08-28T07:30:00","slug":"tdh%e5%bc%80%e5%ae%89%e5%85%a8%e6%83%85%e5%86%b5%e4%b8%8b%ef%bc%8c%e6%89%a7%e8%a1%8ccurl-api%e6%97%b6%e8%bf%94%e5%9b%9e302-found","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=3766","title":{"rendered":"TDH621\u5f00web\u5b89\u5168\u60c5\u51b5\u4e0b\uff0c\u6267\u884ccurl  API\u65f6\u8fd4\u56de302 Found"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<p>TDH 621 \u96c6\u7fa4\uff0c\u5bf9\u4e8e\u670d\u52a1\u7684 web UI \u6dfb\u52a0\u4e86\u65b0\u7684\u8ba4\u8bc1\u65b9\u5f0f\uff0c\u76f4\u63a5\u53bb curl \u67d0\u4e9b API \u4f1a\u91cd\u5b9a\u5411\u5230\u5b89\u5168\u8ba4\u8bc1\u9875\u9762\uff0c\u4ece\u800c\u8fd4\u56de302\u7684\u9519\u8bef\u3002<\/p>\n<hr \/>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<p>\u6bd4\u5982curl\u4e00\u4e2ayarn\u7684 API<\/p>\n<p><strong><code>curl   -v  http:\/\/172.22.22.161:8088\/ws\/v1\/cluster\/metrics <\/code><\/strong><\/p>\n<p>\u8fd4\u56de\u7ed3\u679c\u662f 302 Found<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/08\/image-1597129257371.png\" alt=\"file\" \/><\/p>\n<hr \/>\n<h3>\u95ee\u9898\u539f\u56e0<\/h3>\n<p>\u4ece\u7ed3\u679c\u4e2d\u7684 Location \u90e8\u5206\u6765\u770b\uff0c\u53ef\u77e5\u662f\u8ddf\u5b89\u5168\u76f8\u5173\u7684\u95ee\u9898\uff0c\u51c6\u786e\u6765\u8bf4\u662f TDH 621 \u5f00\u59cb HDFS \u8ddf yarn \u7684 web \u9875\u9762\u6dfb\u52a0\u4e86\u8ba4\u8bc1\u53c2\u6570\uff0c\u53c2\u8003\uff1a <a href=\"http:\/\/172.16.1.168:8090\/pages\/viewpage.action?pageId=23483892\">http:\/\/172.16.1.168:8090\/pages\/viewpage.action?pageId=23483892<\/a><\/p>\n<p>\u4ee5\u4e0b\u4e24\u4e2a\u53c2\u6570\u51b3\u5b9a\u4e86\u662f\u5426\u8981\u5f00\u542fweb\u5b89\u5168\u8ba4\u8bc1<\/p>\n<ul>\n<li><code>hadoop.security.authentication.web.oauth2.enabled<\/code> <\/li>\n<li><code>hadoop.security.authentication.web.cas.enabled<\/code> <\/li>\n<\/ul>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0chadoop.security.authentication.web.oauth2.enabled\u4e3atrue\uff0c\u8bf4\u660e\u4f1a\u5f00\u542foauth2\u8ba4\u8bc1\uff0c\u8fd9\u5bfc\u81f4\u4e86curl\u7684\u65f6\u5019\u91cd\u5b9a\u5411\u95ee\u9898<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2020\/08\/image-1597128852097.png\" alt=\"file\" \/><\/p>\n<hr \/>\n<h3>\u89e3\u51b3\u65b9\u6848\u4e00\uff1a\u5173\u95edweb\u5b89\u5168<\/h3>\n<p>\u53c2\u6570hadoop.security.authentication.web.oauth2.enabled\u8ddfhadoop.security.authentication.web.cas.enabled\u90fd\u6539\u6210false\uff0c\u5373\u53ef\u5173\u95edweb\u5b89\u5168\uff0ccurl\u547d\u4ee4\u4e5f\u80fd\u591f\u62ff\u5230\u6b63\u786e\u7684\u7ed3\u679c<br \/>\ncurl   -v  <a href=\"http:\/\/172.22.22.161:8088\/ws\/v1\/cluster\/metrics\">http:\/\/172.22.22.161:8088\/ws\/v1\/cluster\/metrics<\/a>  <\/p>\n<p>\uff08\u6539\u6210false\u7684\u5f71\u54cd\u662f\u5b89\u5168\u626b\u63cf\u65f6\u5019\u4f1a\u7206\u51fa\u6f0f\u6d1e\uff09<\/p>\n<p>\u56e0\u4e3ahdfs\u8ddfyarn\u90fd\u662f\u4f7f\u7528\u7684\u8fd9\u4e24\u4e2a\u53c2\u6570\uff0c\u6240\u4ee5\u6539\u5b8c\u4e4b\u540e\u914d\u7f6ehdfs\uff0c\u5982\u679c\u53ea\u5e0c\u671b\u5173\u95edyarn\u7684web\u5b89\u5168\uff0c\u90a3\u4e48\u76f4\u63a5\u53bb\u91cd\u542fyarn\u5373\u53ef\uff0c\u4e0d\u9700\u8981\u91cd\u542fhdfs<\/p>\n<hr \/>\n<h3>\u89e3\u51b3\u65b9\u6848\u4e8c\uff1a\u5728curl\u547d\u4ee4\u4e2d\u6dfb\u52a0\u8ba4\u8bc1\u65b9\u5f0f<\/h3>\n<p>\u9996\u5148\uff0c\u754c\u9762\u767b\u5f55guardian fedration\uff0c\u7136\u540e\u7533\u8bf7\u4e00\u4e2aoauth token\uff0c\u5e76\u4e14\u8ba9federation server\u81ea\u52a8\u5237\u65b0\u8fd9\u4e2atoken<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2020\/08\/image-1597129443504.png\" alt=\"file\" \/><\/p>\n<p>\u5237\u65b0\u65f6\u95f4\u53ef\u4ee5\u81ea\u5df1\u5b9a\u4e49\uff1a<br \/>\n<img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2020\/08\/image-1597129490586.png\" alt=\"file\" \/><\/p>\n<p>\u7ed3\u679c\u4e2d\u67e5\u770bAccess Token\uff0c\u590d\u5236\u51fa\u6765<br \/>\n<img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2020\/08\/image-1597129512822.png\" alt=\"file\" \/><\/p>\n<p>\u7136\u540ecurl\u7684\u65f6\u5019\u5e26\u4e0a   Authorization: Bearer token\u7684\u503c  \u8fd9\u4e2ahttp header<\/p>\n<p>\u6bd4\u5982\uff1a<br \/>\ncurl -H &#8216;Authorization: Bearer IMcj9UBwE4XS2B7fsKFw-FEDERATION&#8217;   -v  <a href=\"http:\/\/172.22.22.161:8088\/ws\/v1\/cluster\/metrics\">http:\/\/172.22.22.161:8088\/ws\/v1\/cluster\/metrics<\/a> <\/p>\n<p>\u5373\u53ef\u83b7\u5f97\u6b63\u786e\u7684\u7ed3\u679c\uff1a <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2020\/08\/image-1597129631353.png\" alt=\"file\" \/><\/p>\n<pre><code>### \u6269\u5c55\u77e5\u8bc6\n\nHTTP\u8ba4\u8bc1\n\u5e38\u7528\u7684HTTP\u8ba4\u8bc1\u65b9\u5f0f\u6709\uff1aBasic\u8ba4\u8bc1\u3001Digest\u8ba4\u8bc1\u3001OAuth2\u8ba4\u8bc1\u3002\nBasic\u8ba4\u8bc1\ncurl --basic  -u user:password http:\/\/www.example.com\/posts\/1\nDigest\u8ba4\u8bc1\ncurl --digest -u user:password http:\/\/www.example.com\/posts\/1\nOAuth2\u8ba4\u8bc1\ncurl -u clientId:clientSecret -X POST -d \"username=test&password=test&grant_type=password&scope=read\" http:\/\/www.example.com\/oauth\/token\ncurl -H \"Authorization: Bearer [bearer]\" http:\/\/www.example.com\/posts\/1\n### \u8be6\u7ec6\u8bf4\u660e\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 TDH 621 \u96c6\u7fa4\uff0c\u5bf9\u4e8e\u670d\u52a1\u7684 web UI \u6dfb\u52a0\u4e86\u65b0\u7684\u8ba4\u8bc1\u65b9\u5f0f\uff0c\u76f4\u63a5\u53bb curl \u67d0\u4e9b API  ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=3766\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":70,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[],"class_list":["post-3766","post","type-post","status-publish","format-standard","hentry","category-api"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/3766","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/70"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3766"}],"version-history":[{"count":1,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/3766\/revisions"}],"predecessor-version":[{"id":3784,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/3766\/revisions\/3784"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}