{"id":16485,"date":"2025-05-18T21:20:40","date_gmt":"2025-05-18T13:20:40","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=16485"},"modified":"2026-04-23T17:56:47","modified_gmt":"2026-04-23T09:56:47","slug":"tdh9-x%e4%b9%8b%e5%90%8ehadoop%e6%89%a7%e8%a1%8c%e7%a3%81%e7%9b%98%e5%9d%87%e8%a1%a1disk-balancer","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=16485","title":{"rendered":"TDH9.x\u4e4b\u540ehadoop\u6267\u884c\u78c1\u76d8\u5747\u8861disk balancer"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<p>\u672c\u6587\u63cf\u8ff0\u5728TDH9.x\u4e2d\uff0c\u5982\u4f55\u4f7f\u7528disk balancer\u5de5\u5177\uff0c\u8fdb\u884cdatanode disk\u4e4b\u95f4\u7684\u78c1\u76d8\u5747\u8861<\/p>\n<h3>\u8be6\u7ec6\u63cf\u8ff0<\/h3>\n<p>HDFS disk balancer\u4e0eHDFS Balancer\u662f\u4e0d\u540c\u7684\uff1a HDFS disk balancer\u9488\u5bf9\u7ed9\u5b9a\u7684DataNode\u8fdb\u884c\u64cd\u4f5c\uff0c\u5e76\u5c06\u5757\u4ece\u4e00\u4e2a\u78c1\u76d8\u79fb\u52a8\u5230\u53e6\u4e00\u4e2a\u78c1\u76d8\uff0c\u662fDataNode\u5185\u90e8\u6570\u636e\u5728\u4e0d\u540c\u78c1\u76d8\u95f4\u5e73\u8861\uff1bHDFS Balancer\u5e73\u8861\u4e86DataNode\u8282\u70b9\u4e4b\u95f4\u7684\u5206\u5e03\u3002<\/p>\n<p>\u4f7f\u7528disk balancer\u786e\u8ba4<strong>dfs.disk.balancer.enabled<\/strong>\u662f\u5426\u4e3atrue\uff0c\u4e0d\u914d\u7f6e\u7684\u60c5\u51b5\u4e0b\u4e5f\u9ed8\u8ba4\u4e3atrue<\/p>\n<h4>1 \u786e\u8ba4\u78c1\u76d8\u4e0d\u5747\u8861\u7684\u8282\u70b9\uff0c \u5bf9\u8be5\u8282\u70b9\u751f\u6210\u8ba1\u5212<\/h4>\n<pre><code class=\"language-shell\">hdfs diskbalancer -plan node1.mycluster.com\n-out \/\/\u63a7\u5236\u8ba1\u5212\u6587\u4ef6\u7684\u8f93\u51fa\u4f4d\u7f6e\n-bandwidth \/\/\u8bbe\u7f6e\u7528\u4e8e\u8fd0\u884cDisk Balancer\u7684\u6700\u5927\u5e26\u5bbd\u3002\u9ed8\u8ba4\u5e26\u5bbd10 MB\/s\u3002\n\u2013thresholdPercentage \/\/\u5b9a\u4e49\u78c1\u76d8\u5f00\u59cb\u53c2\u4e0e\u6570\u636e\u91cd\u65b0\u5206\u914d\u6216\u5e73\u8861\u64cd\u4f5c\u7684\u503c\u3002\u9ed8\u8ba4\u7684thresholdPercentage\u503c\u4e3a10\uff05\uff0c\u8fd9\u610f\u5473\u7740\u4ec5\u5f53\u78c1\u76d8\u5305\u542b\u7684\u6570\u636e\u6bd4\u7406\u60f3\u5b58\u50a8\u503c\u591a10\uff05\u6216\u66f4\u5c11\u65f6\uff0c\u78c1\u76d8\u624d\u7528\u4e8e\u5e73\u8861\u64cd\u4f5c\u3002<\/code><\/pre>\n<p>\u672c\u6848\u4f8b\u4ee5\u8be5\u8282\u70b9\u4e3a\u4f8b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2025\/05\/image-1746696469984.png\" alt=\"file\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2025\/05\/image-1746696402436.png\" alt=\"file\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2025\/05\/image-1746696447100.png\" alt=\"file\" \/><\/p>\n<p>\u751f\u6210\u6267\u884c\u8ba1\u5212<\/p>\n<pre><code class=\"language-shell\">hdfs diskbalancer -plan <hostname>\n-out \/\/\u63a7\u5236\u8ba1\u5212\u6587\u4ef6\u7684\u8f93\u51fa\u4f4d\u7f6e\n-bandwidth \/\/\u8bbe\u7f6e\u7528\u4e8e\u8fd0\u884cDisk Balancer\u7684\u6700\u5927\u5e26\u5bbd\u3002\u9ed8\u8ba4\u5e26\u5bbd10 MB\/s\u3002\n\u2013thresholdPercentage \/\/\u5b9a\u4e49\u78c1\u76d8\u5f00\u59cb\u53c2\u4e0e\u6570\u636e\u91cd\u65b0\u5206\u914d\u6216\u5e73\u8861\u64cd\u4f5c\u7684\u503c\u3002\u9ed8\u8ba4\u7684thresholdPercentage\u503c\u4e3a10\uff05\uff0c\u8fd9\u610f\u5473\u7740\u4ec5\u5f53\u78c1\u76d8\u5305\u542b\u7684\u6570\u636e\u6bd4\u7406\u60f3\u5b58\u50a8\u503c\u591a10\uff05\u6216\u66f4\u5c11\u65f6\uff0c\u78c1\u76d8\u624d\u7528\u4e8e\u5e73\u8861\u64cd\u4f5c\u3002\n-maxerror \/\/\u5b83\u5141\u8bb8\u7528\u6237\u5728\u4e2d\u6b62\u79fb\u52a8\u6b65\u9aa4\u4e4b\u524d\u4e3a\u4e24\u4e2a\u78c1\u76d8\u4e4b\u95f4\u7684\u79fb\u52a8\u64cd\u4f5c\u6307\u5b9a\u8981\u5ffd\u7565\u7684\u9519\u8bef\u6570\u3002\n-v \/\/\u8be6\u7ec6\u6a21\u5f0f\uff0c\u6307\u5b9a\u6b64\u9009\u9879\u5c06\u5f3a\u5236plan\u547d\u4ee4\u5728stdout\u4e0a\u663e\u793a\u8ba1\u5212\u7684\u6458\u8981\u3002\n-fs \/\/\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4f7f\u7528\u7684NameNode\u3002\u5982\u679c\u672a\u6307\u5b9a\uff0c\u5219Disk Balancer\u5c06\u4f7f\u7528\u914d\u7f6e\u4e2d\u7684\u9ed8\u8ba4NameNode\u3002<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2025\/05\/image-1746696706028.png\" alt=\"file\" \/><\/p>\n<p>\u53ef\u4ee5\u770b\u5230\u6267\u884c\u8ba1\u5212\u751f\u6210\u5728\u7ea2\u6846\u90e8\u5206<br \/>\n<img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2025\/05\/image-1746696737778.png\" alt=\"file\" \/><\/p>\n<p>\u8fd9\u4e2a\u8ba1\u5212\u662f\u751f\u6210\u5728hdfs\u4e0a\u7684<\/p>\n<h4>2 \u6267\u884c\u8ba1\u5212<\/h4>\n<pre><code class=\"language-shell\">hdfs diskbalancer -execute \/system\/diskbalancer\/2025-May-08-17-31-35\/sw-hbs-25.inesa.com.plan.json<\/code><\/pre>\n<h4>3 \u67e5\u8be2\u8ba1\u5212\u6267\u884c\u60c5\u51b5<\/h4>\n<pre><code class=\"language-shell\">hdfs diskbalancer -query <hostname><\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2025\/05\/image-1746697085880.png\" alt=\"file\" \/><\/p>\n<h4>4 \u53d6\u6d88\u8ba1\u5212<\/h4>\n<pre><code class=\"language-shell\">hdfs diskbalancer -cancel \/system\/diskbalancer\/2025-May-08-17-31-35\/sw-hbs-25.inesa.com.plan.json<\/code><\/pre>\n<h4>5 \u6839\u636e\u6b65\u9aa43\u67e5\u770b\u5230PLAN_UNDER_PROGRESS<\/h4>\n<p>\u9ed8\u8ba4\u79fb\u52a8\u7684\u5e26\u5bbd\u662f10M\uff0c\u53ef\u4ee5\u89c2\u5bdf\u4e00\u4e0b\u78c1\u76d8\u4f7f\u7528\u7387\u662f\u5426\u6709\u4e0b\u964d<br \/>\n<img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2025\/05\/image-1746697713979.png\" alt=\"file\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2025\/05\/image-1746697738649.png\" alt=\"file\" \/><\/p>\n<h4>\u5e38\u89c1\u62a5\u9519<\/h4>\n<h5>1.\u6267\u884c hdfs diskbalancer  \u76f8\u5173\u547d\u4ee4 \u62a5\u9519 <strong>Permission denied<\/strong><\/h5>\n<pre><code>ERROR [main] tools.DiskBalancerCLI (DiskBalancerCLI.java:main(177)) - Exception thrown while running DiskBalancerCLI.\norg.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.AccessControlException): Permission denied.<\/code><\/pre>\n<p><strong>\u89e3\u51b3\u65b9\u6cd5<\/strong>\uff1a \u9700\u8981\u4f7f\u7528\u5bf9\u5e94\u8282\u70b9\u7684\/etc\/hdfs1\/conf\/hdfs.keytab \u6587\u4ef6\u8fdb\u884c\u8ba4\u8bc1<br \/>\n\u4f8b\u5982\u9700\u8981diskbalancer \u8282\u70b9 kv1\u7684\u78c1\u76d8\uff1a<\/p>\n<pre><code># \u9500\u6bc1\u4e4b\u524d\u7684\u7968\u636e\nkdestroy\n# \u8ba4\u8bc1\u5bf9\u5e94\u8282\u70b9\u7684\u7968\u636e\nkinit -kt \/etc\/hdfs1\/conf\/hdfs.keytab hdfs\/kv1@TDH\nhdfs diskbalancer -plan kv1<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 \u672c\u6587\u63cf\u8ff0\u5728TDH9.x\u4e2d\uff0c\u5982\u4f55\u4f7f\u7528disk balancer\u5de5\u5177\uff0c\u8fdb\u884cdatanode disk\u4e4b\u95f4 ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=16485\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-16485","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/16485","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\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=16485"}],"version-history":[{"count":3,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/16485\/revisions"}],"predecessor-version":[{"id":18314,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/16485\/revisions\/18314"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}