{"id":2733,"date":"2020-10-28T15:23:11","date_gmt":"2020-10-28T07:23:11","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=2733"},"modified":"2020-10-28T15:23:11","modified_gmt":"2020-10-28T07:23:11","slug":"tdh4-x%e5%92%8ctdh5-x%e6%88%96tdh6-x%e4%b9%8b%e9%97%b4%e9%85%8d%e7%bd%ae%e5%8d%95%e5%90%91%e6%88%96%e5%8f%8c%e5%90%91%e4%ba%92%e4%bf%a1","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=2733","title":{"rendered":"TDH4.X\u548cTDH5.X\u6216TDH6.X\u4e4b\u95f4\u914d\u7f6e\u5355\u5411\u6216\u53cc\u5411\u4e92\u4fe1"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<hr \/>\n<p><strong>\u5bf9\u4e8e\u5355\u4e2aTDH\u96c6\u7fa4\uff0c\u6240\u6709\u7528\u6237\u548c\u670d\u52a1\u90fd\u5305\u542b\u5728\u4e00\u4e2aKerberos realm\u4e2d\u3002\u867d\u7136\u8fd9\u5bf9\u4e8e\u7b80\u5355\u4f7f\u7528\u5f88\u6709\u6548\uff0c\u4f46\u662f\u8003\u8651\u5230\u5927\u578b\u4f01\u4e1a\u7684\u5de5\u4f5c\u65b9\u5f0f\uff0c\u8fd9\u901a\u5e38\u662f\u4e0d\u73b0\u5b9e\u7684\u3002\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\uff0c\u5927\u578b\u4f01\u4e1a\u6700\u7ec8\u4f1a\u4f7f\u7528\u591a\u4e2aKerberos\u57df\uff0c\u6bd4\u5982\u5408\u5e76\u3001\u6536\u8d2d\uff0c\u6216\u8005\u53ea\u662f\u60f3\u9694\u79bb\u4f01\u4e1a\u7684\u4e0d\u540c\u90e8\u5206\u3002<br \/>\n\u4f46\u662f\uff0c\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cKDC\u53ea\u77e5\u9053\u81ea\u5df1\u7684realm\u548c\u81ea\u5df1kdc database\u4e2d\u7684principal\u3002\u5982\u679c\u6765\u81ea\u4e00\u4e2a\u57df\u7684\u7528\u6237\u5e0c\u671b\u4f7f\u7528\u7531\u53e6\u4e00\u4e2a\u57df\u63a7\u5236\u7684\u670d\u52a1\uff0c\u8be5\u600e\u4e48\u529e? \u4e3a\u4e86\u5b9e\u73b0\u8fd9\u4e00\u70b9\uff0c\u9700\u8981\u5728\u4e24\u4e2a\u57df\u4e4b\u95f4\u5efa\u7acbKerberos\u4fe1\u4efb\u3002<\/strong><\/p>\n<p><strong>\u4f8b\u5982\uff0c\u5047\u8bbe\u4e00\u4e2a\u975e\u5e38\u5927\u7684\u516c\u53f8\uff0c\u5b83\u51b3\u5b9a\u521b\u5efa\u591a\u4e2a\u57df\u6765\u8bc6\u522b\u4e0d\u540c\u7684\u4e1a\u52a1\u7ebf\uff0c\u5305\u62ecHR\u548cMARKETING\u3002\u56e0\u4e3a\u4e24\u4e2a\u57df\u4e2d\u7684\u7528\u6237\u53ef\u80fd\u90fd\u9700\u8981\u4ece\u4e24\u4e2a\u57df\u8bbf\u95ee\u670d\u52a1\uff0c\u4f8b\u5982HR\u7684KDC\u9700\u8981\u76f8\u4fe1\u6765\u81eaMARKETING\u7684\u4fe1\u606f\u3002\u53cd\u4e4b\u4ea6\u7136\u3002\u4ece\u8868\u9762\u4e0a\u770b\uff0c\u8fd9\u4f3c\u4e4e\u5f88\u7b80\u5355\uff0c\u4f46\u5b9e\u9645\u4e0a\u5b58\u5728\u4e24\u79cd\u4e0d\u540c\u7c7b\u578b\u7684\u4fe1\u4efb: \u5355\u5411\u4fe1\u4efb\u548c\u53cc\u5411\u4fe1\u4efb(\u6216\u5b8c\u5168\u4fe1\u4efb)\u3002\u4e0a\u8ff0\u4f8b\u5b50\u4ee3\u8868\u4e86\u4e00\u79cd\u53cc\u5411\u4fe1\u4efb\u3002<\/strong><\/p>\n<p><strong>\u5982\u679c\u6709\u53e6\u5916\u4e00\u4e2aDEV\u57df\uff0c\u5176\u4e2d\u7684\u7814\u53d1\u90e8\u95e8\u6709\u9700\u8981\u53bb\u8bbf\u95eeDEV\u57df\u548cMARKETING\u57df\u3002\u4f46\u662f\u5e02\u573a\u90e8\u7528\u6237\u4e0d\u5e94\u8be5\u8bbf\u95eeDEV\u57df\uff0c\u6b64\u573a\u666f\u9700\u8981\u5355\u5411\u4fe1\u4efb<\/strong><\/p>\n<p><strong>\u90a3\u4e48\u5982\u4f55\u5efa\u7acbKerberos\u4fe1\u4efb\u5462? AS\u548cTGS\u5185\u90e8\u4f7f\u7528\u4e86\u4e00\u4e2a\u7279\u6b8a\u7684principal\uff0c\u5b83\u7684\u5f62\u5f0f\u662fkrbtgt\/{REALM}@{REALM}\uff0c\u8fd9\u4e00\u539f\u5219\u5bf9\u4e8e\u5efa\u7acb\u4fe1\u4efb\u975e\u5e38\u91cd\u8981\u3002\u5bf9\u4e8e\u4fe1\u4efb\uff0cprincipal\u91c7\u7528krbtgt\/{TRUSTING_REALM}@{TRUSTED_REALM}\u7684\u5f62\u5f0f\u3002\u8fd9\u4e2a\u539f\u5219\u7684\u4e00\u4e2a\u5173\u952e\u662f\u5b83\u5728\u4e24\u4e2arealm\u90fd\u5b58\u5728\uff0c\u5e76\u4e14\u548cprincipal\u7684\u5bc6\u7801\u548c\u4f7f\u7528\u7684\u52a0\u5bc6\u7c7b\u578b\u5fc5\u987b\u662f\u76f8\u540c\u7684<\/strong><\/p>\n<p><strong>\u672c\u6587\u5c06\u4e3e\u4f8b\u5982\u4f55\u5efa\u7acbHDT\u5230KTDH\u96c6\u7fa4\u7684\u5355\u5411\u4fe1\u4efb\uff08KTDH\u96c6\u7fa4\u9700\u8981\u8bbf\u95eeHDT\u96c6\u7fa4\u7684\u8d44\u6e90\uff09<\/strong><\/p>\n<ul>\n<li>HDT outgoing KTDH<\/li>\n<li>\u4fe1\u4efb\u7684\u4e00\u65b9\u662fHDT\uff0c\u88ab\u4fe1\u4efb\u7684\u4e00\u65b9\u662fKTDH<\/li>\n<\/ul>\n<h3>\u73af\u5883\u51c6\u5907<\/h3>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/03\/image-1585621079910.png\" alt=\"file\" \/><\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/03\/image-1585621108025.png\" alt=\"file\" \/><\/p>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<hr \/>\n<h4>Step1: HDT\u96c6\u7fa4\u901a\u8fc7TDH4.x\u96c6\u6210\u7684kadmin.local\u7ba1\u7406\u547d\u4ee4\u57284.X\u96c6\u7fa4\u4e2d\u65b0\u589ekrbtgt\/HDT@KTDH<\/h4>\n<ul>\n<li>\u6ce8\u610f\uff1a\u5bc6\u7801\u5fc5\u987b\u4fdd\u6301\u4e00\u81f4\uff0c\u5e76\u4e14\u5efa\u8bae\u4f7f\u7528\u5f3a\u5bc6\u7801\uff0cMIT\u63a8\u8350\u5bc6\u7801\u81f3\u5c11\u753126\u4f4d\u968f\u673a\u7684ASCII\u7801\u7ec4\u6210 \u53ef\u901a\u8fc7\u83b7\u53d6\u65f6\u95f4\u6233\u83b7\u53d626\u4f4d\u5f3a\u5bc6\u7801<\/li>\n<\/ul>\n<pre><code class=\"language-shell\">[root@tdh48401 conf]# date +%s|sha256sum|base64|head -c 26;echo\nNWY3M2ZhOGYyMjFlNGVmM2I2Nz<\/code><\/pre>\n<ul>\n<li>\u4e0b\u9762\u8fd9\u6b65\u5b8c\u6210\u4e4b\u540e\uff0c\u4f1a\u5728\u53cc\u65b9realm\u4e0b\u751f\u6210     DN: uid=krbtgt\/HDT@KTDH,ou=System,ou=People,dc=tdh   \uff08krbtgt\/TDH-TRUSTING@TDH-TRUSTED\uff09<\/li>\n<\/ul>\n<pre><code class=\"language-shell\">[root@tdh48401 conf]# sudo kadmin.local\nAuthenticating as principal hdfs\/admin@HDT with password.\nkadmin.local:  addprinc -requires_preauth krbtgt\/HDT@KTDH\nNOTICE: no policy specified for krbtgt\/HDT@KTDH; assigning \"default\"\n#\u6ce8\u610f\uff0c\u8fd9\u91cc\u8f93\u5165\u4e0a\u8ff0\u768426\u4f4d\u5bc6\u7801\nEnter password for principal \"krbtgt\/HDT@KTDH\":\nRe-enter password for principal \"krbtgt\/HDT@KTDH\":\nPrincipal \"krbtgt\/HDT@KTDH\" created.<\/code><\/pre>\n<p><strong>\u68c0\u67e5\u662f\u5426\u65b0\u589e\u6210\u529f\uff1a<\/strong><\/p>\n<pre><code class=\"language-shell\">[root@tdh48401 hdfs1]# sudo kadmin.local \nAuthenticating as principal root\/admin@HDT with password.\nkadmin.local:  listprincs krbtgt*\nkrbtgt\/HDT@HDT\nkrbtgt\/HDT@KTDH<\/code><\/pre>\n<h4>Step2: KTDH\u96c6\u7fa4\u901a\u8fc7\u5728guardian-server\u5bb9\u5668\u4e2d\u4f7f\u7528kadmin.guardian\u65b0\u589ekrbtgt\/HDT@KTDH<\/h4>\n<pre><code class=\"language-shell\">#\u6ce8\u610f\u8fd9\u91cc\u4f7f\u7528\u4e0a\u8ff0\u768426\u4f4d\u5bc6\u7801\uff0c\u548cTDH\u96c6\u7fa4\u7684\u5bc6\u7801\u4fdd\u6301\u4e00\u81f4\n[root@tdh62101 ~]# \/var\/log\/guardian\/kadmin.guardian -b admin -w 123456 -r KTDH -q \"addprinc -pw NWY3M2ZhOGYyMjFlNGVmM2I2Nz krbtgt\/HDT\"<\/code><\/pre>\n<p><strong>\u68c0\u67e5\u662f\u5426\u65b0\u589e\u6210\u529f\uff1a<\/strong><\/p>\n<pre><code class=\"language-shell\">[root@tdh62101 ~]# \/var\/log\/guardian\/kadmin.guardian -b admin -w 123456 -r KTDH -q \"listprincs\" |grep krbtgt\nkrbtgt\/KTDH@KTDH\nkrbtgt\/HDT@KTDH<\/code><\/pre>\n<h4>Step3: \u68c0\u67e5\u4e24\u4e2a\u96c6\u7fa4\u4e0a\u7684\u65f6\u95f4\u662f\u5426\u540c\u6b65\uff0c\u4e0d\u540c\u6b65\u53ef\u4ee5\u901a\u8fc7ntpdate\u547d\u4ee4\u6216\u8005\u7f51\u7edc\u65f6\u95f4\u534f\u8bae\u540c\u6b65<\/h4>\n<h4>Step4: \u88ab\u4fe1\u4efb\u7684\u4e00\u65b9\uff0c\u4e5f\u5c31\u662fKTDH\u96c6\u7fa4\uff0c\u6bcf\u4e2a\u8282\u70b9\u4fee\u6539\/etc\/hosts\uff0c\u52a0\u5165\u5bf9\u65b9\u96c6\u7fa4\u4e5f\u5c31\u662fHDT\u96c6\u7fa4\u7684hostname\u548cip\u4fe1\u606f<\/h4>\n<pre><code class=\"language-shell\">[root@tdh62101~]$ cat \/etc\/hosts\n127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4\n::1         localhost localhost.localdomain localhost6 localhost6.localdomain6\n172.22.23.6 tdh62101\n172.22.23.7 tdh62102\n172.22.23.8 tdh62103\n#\u4ee5\u4e0b\u4e3a\u65b0\u589e\u90e8\u5206\n172.22.23.51 tdh48401\n172.22.23.52 tdh48402\n172.22.23.53 tdh48403\n<\/code><\/pre>\n<h4>Step5: \u88ab\u4fe1\u4efb\u7684\u4e00\u65b9\uff0c\u4e5f\u5c31\u662fKTDH\u96c6\u7fa4\uff0c\u4fee\u6539\/etc\/krb5.conf<\/h4>\n<ul>\n<li>4.x\u7684kdc\u7aef\u53e3\u4e3a88,\u65e0\u9700\u663e\u5f0f\u914d\u7f6e\uff0c5.x\u7684kdc\u7684\u7aef\u53e3\u4e3a1088\uff0c\u9700\u8981\u663e\u5f0f\u914d\u7f6e<\/li>\n<\/ul>\n<pre><code class=\"language-shell\">[realms]\nKTDH = {\nkdc = tdh62101:1088\nkdc = tdh62102:1088\n}\n\n#\u4ee5\u4e0b\u4e3a\u65b0\u589e\u90e8\u5206\nHDT = {\n    kdc = tdh48401:88\n    kdc = tdh48402:88\n    admin_server = tdh48402\n    admin_server = tdh48401\n}\n\n[domain_realm]\ntdh48401 = HDT\ntdh48402 = HDT\ntdh62101 = KTDH\ntdh62102 = KTDH<\/code><\/pre>\n<h4>Step6: \u4fe1\u4efb\u7684\u4e00\u65b9\uff0c\u4e5f\u5c31\u662fHDT\u96c6\u7fa4\uff0c\u5141\u8bb8\u8bc6\u522b\u5bf9\u65b9\u7684principal\uff0c\u5728\u6bcf\u4e2a\u8282\u70b9hdfs-site.xml\u6587\u4ef6\u65b0\u589e\u53c2\u6570\uff0c\u7136\u540e\u91cd\u542fhdfs<\/h4>\n<pre><code class=\"language-perl\">    <property>\n        <name>hadoop.security.auth_to_local<\/name>\n        <value>RULE:[1:$1@$0](^.*@.*$)s\/^(.*)@.*$\/$1\/g RULE:[2:$1@$0](^.*@.*$)s\/^(.*)@.*$\/$1\/g DEFAULT<\/value>\n    <\/property><\/code><\/pre>\n<p><strong>\u4e0a\u8ff0\u8868\u8fbe\u5f0f\u51e0\u4e4e\u901a\u914d\uff0c\u56e0\u4e3a\u8fd9\u91cc\u662f\u5355\u5411\u4e92\u4fe1\uff0c\u51fa\u4e8e\u5b89\u5168\u6027\u8003\u8651\u53ef\u4ee5\u66f4\u72ed\u4e49\u4e00\u70b9\uff0c\u5728acceptance filter\u548csubstitution \u9636\u6bb5\u53ea\u80fd\u591f\u8bc6\u522b\u57df\u4e3aKTDH\u7684principal\uff0c\u914d\u7f6e\u4e3a<\/strong><\/p>\n<pre><code class=\"language-perl\">    <property>\n        <name>hadoop.security.auth_to_local<\/name>\n        <value>RULE:[1:$1@$0](^.*@KTDH$)s\/^(.*)@KTDH$\/$1\/g RULE:[2:$1@$0](^.*@KTDH$)s\/^(.*)@KTDH$\/$1\/g DEFAULT<\/value>\n    <\/property><\/code><\/pre>\n<h4>\u6d4b\u8bd5: \u5728\u88ab\u4fe1\u4efb\u7684\u4e00\u65b9\uff0c\u4e5f\u5c31\u662fKTDH\u96c6\u7fa4\u4e0a\u6d4b\u8bd5\uff0c\u770b\u80fd\u5426\u8bbf\u95eeHDT\u96c6\u7fa4\u7684\u670d\u52a1<\/h4>\n<pre><code class=\"language-shell\">#\u8fd9\u91cckinit\u4efb\u610frealm\u7684principal\u90fd\u53ef\u4ee5\uff0c\u5e76\u65e0\u5f3a\u5236\u8981\u6c42\n[root@tdh62101~]$ kinit hdfs\/tdh48401@HDT -kt hdfs-23.51.keytab\n[root@tdh62101~]$ hadoop fs -ls  hdfs:\/\/172.22.23.51:8020\/\n2020-03-31 10:17:27,190 INFO util.KerberosUtil: Using principal pattern: HTTP\/_HOST\n2020-03-31 10:17:27,366 INFO util.KerberosName: No auth_to_local rules applied to hdfs\/tdh48401@HDT\nFound 5 items\ndrwxr-xr-x   - hdfs hbase           0 2020-01-09 11:47 hdfs:\/\/172.22.23.51:8020\/inceptorsql1\ndrwxrwxrwx   - hdfs hadoop          0 2020-01-09 11:44 hdfs:\/\/172.22.23.51:8020\/tmp\ndrwxr-xr-x   - hdfs hbase           0 2020-03-31 10:13 hdfs:\/\/172.22.23.51:8020\/transwarp-health-check-dir\ndrwxrwxrwx   - hdfs hadoop          0 2020-01-09 11:48 hdfs:\/\/172.22.23.51:8020\/user\ndrwxr-xr-x   - hdfs hbase           0 2020-01-09 11:44 hdfs:\/\/172.22.23.51:8020\/yarn1<\/code><\/pre>\n<p><strong><font color=red>\u6ce8\uff1a\u914d\u7f6e\u53cc\u5411\u4e92\u4fe1\u7684\u65b9\u6cd5\u53ea\u9700\u8981\u5728\u53cc\u65b9\u96c6\u7fa4\u90fd\u505a\u914d\u7f6e\u6587\u4ef6\u7684\u4fee\u6539\u3001\u7136\u540e\u53cc\u65b9\u7684kdc database\u4e2d\u90fd\u65b0\u589ekrbtgt\/TDH-TRUSED@TDH-TRUSTING\u5373\u53ef\uff0c\u53e6\u5916hadoop.security.auth_to_local\u53c2\u6570\u6b63\u5219\u5339\u914d2\u4e2arealm\u6216\u9009\u62e9\u901a\u914d<\/font><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 \u5bf9\u4e8e\u5355\u4e2aTDH\u96c6\u7fa4\uff0c\u6240\u6709\u7528\u6237\u548c\u670d\u52a1\u90fd\u5305\u542b\u5728\u4e00\u4e2aKerberos realm\u4e2d\u3002\u867d\u7136\u8fd9\u5bf9\u4e8e\u7b80\u5355\u4f7f\u7528\u5f88\u6709 ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=2733\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38],"tags":[],"class_list":["post-2733","post","type-post","status-publish","format-standard","hentry","category-configuration"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/2733","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\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2733"}],"version-history":[{"count":3,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/2733\/revisions"}],"predecessor-version":[{"id":3582,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/2733\/revisions\/3582"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2733"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2733"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}