quota是一个可以限制用户对磁盘使用量的工具,它可以查看磁盘分配情况和配置用户使用磁盘的限额。
quota的一般作用对象
(1)针对WWW server
(2)针对mail server
(3)针对file server
quota需要的支持和限制
(1)仅能针对整个文件系统
(2)需要kernel的支持
(3)只对一般用户有效
quota的设置内容(centos7中的xfs)
分别针对用户、群组、个别目录(user,group,project)进行磁盘配额。它通过限制inode和block的用量管理文件系统。
有两个限制:soft/hard,表示具体限制的数值大小,当磁盘容量达到soft时,系统会发出警告,要求降低至soft值以下,当达到hard时,系统会禁止继续增加新的文件。
宽限时间(一般为7天),当某一用户使用磁盘容量达到soft时,系统会给出一个grace time,若超过这个天数,soft值会变成hard值并禁止该用户对磁盘增加新的文件。
以下实例分别对用户、群组、目录限制配额。(鸟哥的案例)
案例要求:五人为一组,五人账号分别为myquota1、myquota2、myquota3、myquota4、myquota5,密码都为password,初始组名myquotagrp。
五人每人的hard限额300MB,soft限额250MB。组限额和目录限额不可共存,两种方法宽限时间14天:1)组限额,本组hard限额1GB
2)共享目录限额。五人的项目目录在/home/myquota,该目录其他人没有任何权限,myquotagrp组有全部权限。目录hard限额500MB
账号、参数等其他环境设置

文件系统的支持和查看

可以看到/home是独立的file system,是xfs文件系统。可以进行之后的流程

编辑fstab文件中加这一行,标红的参数表示对用户和群组的quota支持。然后重新挂载/home目录

观察quota报告资料





限额设置

对用户:

对群组:

设置grace time

测试

对目录:

需要规范目录、项目名称和项目id


测试

其他指令






网友评论