小香 發表於 2025-6-26 19:13:00

HDFS目录配额(quota)不足导致写文件失败

<p>本文分享自天翼云开发者社区《HDFS目录配额(quota)不足导致写文件失败》,作者:5****m</p>
<div class="section">
<h4 class="sectiontitle">问题背景与现象</h4>
<p>给某目录设置quota后,往目录中写文件失败,出现如下问题“<strong>The DiskSpace quota of</strong>&nbsp;/tmp/tquota2 is&nbsp;<strong>exceeded</strong>”。</p>
<pre class="screen">$ hdfs dfs -put switchuser.py/tmp/tquota2
put: The DiskSpace quota of /tmp/tquota2 is exceeded: quota = 157286400 B = 150 MB but diskspace consumed = 402653184 B = 384 MB</pre>
</div>
<div class="section">
<h4 class="sectiontitle">可能原因</h4>
<p>目录配置的剩余的空间小于写文件实际需要的空间。</p>
</div>
<div class="section">
<h4 class="sectiontitle">原因分析</h4>
<ol>
<li>HDFS支持设置某目录的配额,即某限制某目录的下的文件最多占用空间大小,例如如下命令是设置/tmp/tquota 目录最多写入150MB的文件(文件大小*副本数)。
<p><strong>hadoop dfsadmin -setSpaceQuota 150M /tmp/tquota2</strong></p>
</li>
<li>使用如下命令可以查看目录设置的配额情况,SPACE_QUOTA是设置的空间配额,REM_SPACE_QUOTA是当前剩余的空间配额。
<p><strong>hdfs dfs -count -q -h -v /tmp/tquota2</strong></p>
</li>
<li>日志分析,如下日志说明写入文件需要消耗384M,但是当前的空间配额是150M,因此空间不足。写文件前,需要的剩余空间是:块大小*副本数,128M*3副本=384M。
<pre class="screen">$ hdfs dfs -put switchuser.py/tmp/tquota2
put: The DiskSpace quota of /tmp/tquota2 is exceeded: quota = 157286400 B = 150 MB but diskspace consumed = 402653184 B = 384 MB</pre>
</li>
</ol></div>
<div class="section">
<h4 class="sectiontitle">解决办法</h4>
<ol>
<li>增加配额大小,即重新设置目录的配额大小。
<p><strong>hadoop dfsadmin -setSpaceQuota 150G /目录名</strong></p>
</li>
<li>清空配额。
<p><strong>hdfs dfsadmin -clrSpaceQuota /目录名</strong></p>
</li>
</ol></div><br><br>
来源:https://www.cnblogs.com/developer-tianyiyun/p/18950792
頁: [1]
查看完整版本: HDFS目录配额(quota)不足导致写文件失败