简体   繁体   English

在unix中查找目录的大小

[英]Find the size of directory in unix

Problem Statement:- 问题陈述:-

I am getting this below exception- 我得到以下异常 -

org.apache.hadoop.hdfs.protocol.DSQuotaExceededException:
org.apache.hadoop.hdfs.protocol.DSQuotaExceededException: The DiskSpace 
quota of /tmp is exceeded: quota=659706976665600 diskspace consumed=614400.1g

So I just wanted to know how much is the size of /tmp directory currently and because of that I am getting this exception. 所以我只是想知道目前/ tmp目录的大小是多少,因此我得到了这个例外。 How can I see the free space in /tmp? 如何查看/ tmp中的可用空间?

Update:- 更新: -

bash-3.00$ df -h /tmp
Filesystem             size   used  avail capacity  Mounted on
rpool/tmp               10G   2.2G   7.8G    22%    /tmp

I am puzzled right now why I am getting that exception then as it clearly states above that I have space available. 我现在很困惑为什么我得到那个例外,因为它清楚地说明我有空间可用。

You can do (For SunOS) 你可以做(​​对于SunOS)

# du -sh /tmp

To see how much it uses now, but that you already saw. 要了解它现在使用了多少,但你已经看到了。

To see how much total, free and used space is on the partition where /tmp resides you can use: 要查看/tmp所在的分区上有多少总空间,空闲空间和已用空间,您可以使用:

# df -h /tmp

Note that filling up space is not the only thing that can prevent writing to filesystem. 请注意,填充空间不是唯一可以阻止写入文件系统的东西。

Running out of inodes is another popular reason. 耗尽inode是另一个流行的原因。

You can check that with 你可以检查一下

# df -i /tmp

for a in ls ; 为了一个ls ; do du -ch ${a} | do du -ch $ {a} | grep total ; 总计; echo ${a}; echo $ {a}; done DONE

try this but it takes time if the size of dir is in GBs 尝试这个但是如果dir的大小是GB,则需要时间

Managing HDFS Space Quotas It's important to understand that in HDFS, there must be enough quota space to accommodate an entire block. 管理HDFS空间配额了解在HDFS中必须有足够的配额空间来容纳整个块,这一点很重要。 If the user has, let's say, 200MB free in their allocated quota, they can't create a new file, regardless of the file size, if the HDFS block size happens to be 256MB. 如果用户在分配的配额中有200MB空闲,如果HDFS块大小恰好为256MB,则无论文件大小如何,都无法创建新文件。 You can set the HDFS space quota for a user by executing the setSpace-Quota command. 您可以通过执行setSpace-Quota命令为用户设置HDFS空间配额。 Here's the syntax: 这是语法:

$ hdfs dfsadmin –setSpaceQuota <N> <dirname>...<dirname>

The space quota you set acts as the ceiling on the total size of all files in a directory. 您设置的空间配额充当目录中所有文件总大小的上限。 You can set the space quota in bytes (b), megabytes (m), gigabytes (g), terabytes (t) and even petabytes (by specifying p—yes, this is big data!). 您可以设置空间配额,以字节(b),兆字节(m),千兆字节(g),太字节(t)甚至PB为单位(通过指定p-yes,这是大数据!)。 And here's an example that shows how to set a user's space quota to 60GB: 这是一个示例,显示如何将用户的空间配额设置为60GB:

$ hdfs dfsadmin -setSpaceQuota 60G /user/alapati

You can set quotas on multiple directories at a time, as shown here: 您可以一次在多个目录上设置配额,如下所示:

$ hdfs dfsadmin -setSpaceQuota 10g /user/alapati /test/alapati

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM