仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 634|回复: 7
打印 上一主题 下一主题

[CentOS(社区)] 带来一篇CentOS 配额(Quota)申明

[复制链接]
精灵巫婆 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-14 20:21:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!在Linux体系中,因为是多人多义务的情况,以是会有多人配合利用一个硬盘空间的情形产生,为了公道利用这些空间,***必要把持用户对磁盘空间的利用,这个就是Linux下的配额办理。
配额办理是对某个磁盘分区举行限定。这里的限定包含2个方面:
1.单个用户对某个目次下空间巨细的限定。
2.单个用户对某个目次下文件个数的限定。

1.1Quota经常使用在以下几种情形

1)针对WWWserver,比方:每一个人的网页空间的容量限定。
2)针对mailserver,比方:每一个人的邮件空间限定。
3)针对fileserver,比方:每一个人最年夜的可用收集硬盘空间。

1.2Quota的2个注重事项

(1)仅针对全部partition:
quota针对『全部partition』举行限定,比方:假如/dev/hda5是挂载在/dave目次下,那末在/dave目次下的一切目次城市遭到限定。

(2)只对一样平常身份利用者无效:
不是一切在Linux下面的账号都能够设定quota,比方root就不克不及设定quota。


1.3Quota的三种限定范例

(1)softlimit:
这是最低限定容量的意义,用户在脱期时代以内,他的容量能够凌驾soft,但必须要脱期工夫以内将磁盘容量下降到soft的容量限定之下。

(2)hardlimit:
这是『相对不克不及凌驾』的容量。一般hardlimit会比softlimit为高,比方收集驱动器空间为30MB,那末hardlimit就设定为30MB,可是为了让利用者有必定的戒备心,以是当利用空间凌驾25MB时,比方利用者利用了27MB的空间时,那末体系就会告诫用户,让利用者能够在『脱期工夫内』将他的档案量下降至25MB(亦便是softlimit)以内。也就是说,soft到hard之间的容量实在就是脱期的容量,能够到达针对利用者的『警示』感化。

(3)脱期工夫:
脱期工夫就是当利用者利用的空间凌驾了softlimit,却还没有抵达hardlimit时,那末在这个『脱期工夫』以内,就必须要请用户将利用的磁盘容量下降到softlimit之下。而当用户将磁盘容量利用情形凌驾softlimit时,『脱期工夫』就会主动被启动,而在用户将容量下降到softlimit之下,那末脱期工夫就会主动的作废。

1.4Quota的装置包

Quota也必要装置,装置包以下:

[root@rhce/]#rpm-qquota
quota-3.17-16.el6.x86_64
[root@rhce/]#

1.5Quota相干的下令


与Quota相干的几个下令以下。

1.5.1启用quota:quotaon

[root@rhce/]#quotaon
Badnumberofarguments.
quotaon:Usage:
quotaon[-guvp][-Fquotaformat][-xstate]-a
quotaon[-guvp][-Fquotaformat][-xstate]filesys...

-a,--allturnquotasonforallfilesystems
-f,--offturnquotasoff
-u,--useroperateonuserquotas
-g,--groupoperateongroupquotas
-p,--print-stateprintwhetherquotasareonoroff
-x,--xfs-command=cmdperformXFSquotacommand
-F,--format=formatnameoperateonspecificquotaformat
-v,--verboseprintmoremessages
-h,--helpdisplaythishelptextandexit
-V,--versiondisplayversioninformationandexit
[root@rhce/]#


1.5.2封闭quota:quotaoff

[root@rhce/]#quotaoff
Badnumberofarguments.
quotaoff:Usage:
quotaoff[-guvp][-Fquotaformat][-xstate]-a
quotaoff[-guvp][-Fquotaformat][-xstate]filesys...

-a,--allturnquotasoffforallfilesystems
-f,--offturnquotasoff
-u,--useroperateonuserquotas
-g,--groupoperateongroupquotas
-p,--print-stateprintwhetherquotasareonoroff
-x,--xfs-command=cmdperformXFSquotacommand
-F,--format=formatnameoperateonspecificquotaformat
-v,--verboseprintmoremessages
-h,--helpdisplaythishelptextandexit
-V,--versiondisplayversioninformationandexit

1.5.3配额发送告诫:warnquota

[root@rhce/]#warnquota-h
warnquota:Usage:
warnquota[-ugsid][-Fquotaformat][-cconfigfile][-qquotatabfile][-aadminsfile]

-u,--userwarnusers
-g,--groupwarngroups
-s,--human-readablesendinformationinmorehumanfriendlyunits
-i,--no-autofsavoidautofsmountpoints
-d,--no-detailsdonotsendquotainformationitself
-F,--format=formatnameusequotafilesofspecificformat
-c,--config=config-filenon-defaultconfigfile
-q,--quota-tab=quotatab-filenon-defaultquotatab
-a,--admins-file=admins-filenon-defaultadminsfile
-h,--helpdisplaythishelpmessageandexit
-v,--versiondisplayversioninformationandexit

Bugstojack@suse.cz
[root@rhce/]#

1.5.4编纂配额属性:edquota

[root@rhce/]#edquota
edquota:Usage:
edquota[-rm][-u][-Fformatname][-pusername][-ffilesystem]username...
edquota[-rm]-g[-Fformatname][-pgroupname][-ffilesystem]groupname...
edquota[-rm][-u|g][-Fformatname][-ffilesystem]-t
edquota[-rm][-u|g][-Fformatname][-ffilesystem]-Tusername|groupname...

-u,--useredituserdata
-g,--groupeditgroupdata
-r,--remoteeditremotequota(viaRPC)
-m,--no-mixed-pathnamestrimleadingslashesfromNFSv4mountpoints
-F,--format=formatnameeditquotasofaspecificformat
-p,--prototype=namecopydatafromaprototypeuser/group
--always-resolvealwaystrytoresolvename,evenifitis
composedonlyofdigits
-f,--filesystem=filesystemeditdataonlyonaspecificfilesystem
-t,--edit-periodeditgraceperiod
-T,--edit-timeseditgracetimeofauser/group
-h,--helpdisplaythishelptextandexit
-V,--versiondisplayversioninformationandexit

Bugsto:jack@suse.cz
[root@rhce/]#

1.5.5显现配额信息:repquota

[root@rhce/]#repquota-h
repquota:Utilityforreportingquotas.
Usage:
repquota[-vugsi][-c|C][-t|n][-Fquotaformat](-a|mntpoint)

-v,--verbosedisplayalsousers/groupswithoutanyusage
-u,--userdisplayinformationaboutusers
-g,--groupdisplayinformationaboutgroups
-s,--human-readableshownumbersinhumanfriendlyunits(MB,GB,...)
-t,--truncate-namestruncatenamesto8characters
-p,--raw-graceprintgracetimeinsecondssinceepoch
-n,--no-namesdonottranslateuid/gidtoname
-i,--no-autofsavoidautofsmountpoints
-c,--batch-translationtranslatebignumberofidsatonce
-C,--no-batch-translationtranslateidsonebyone
-F,--format=formatnamereportinformationforspecificformat
-h,--helpdisplaythishelpmessageandexit
-V,--versiondisplayversioninformationandexit

Bugstojack@suse.cz
[root@rhce/]#

1.5.6反省并修复quota设置文件:quotacheck

#quotacheck–cvug/tmp

[root@rhce~]#quotacheck-h
Utilityforcheckingandrepairingquotafiles.
quotacheck[-gucbfinvdmMR][-F<quota-format>]filesystem|-a

-u,--usercheckuserfiles
-g,--groupcheckgroupfiles
-c,--create-filescreatenewquotafiles
-b,--backupcreatebackupsofoldquotafiles
-f,--forceforcecheckevenifquotasareenabled
-i,--interactiveinteractivemode
-n,--use-first-dquotusethefirstcopyofduplicatedstructure
-v,--verboseprintmoreinformation
-d,--debugprintevenmoremessages
-m,--no-remountdonotremountfilesystemread-only
-M,--try-remounttryremountingfilesystemread-only,
continueevenifitfails
-R,--exclude-rootexcluderootwhencheckingallfilesystems
-F,--format=formatnamecheckquotafilesofspecificformat
-a,--allcheckallfilesystems
-h,--helpdisplaythismessageandexit
-V,--versiondisplayversioninformationandexit

Bugstojack@suse.cz
[root@rhce~]#

[root@rhce~]#quotacheck-cvug/dave
quotacheck:Yourkernelprobablysupportsjournaledquotabutyouarenotusingit.Considerswitchingtojournaledquotatoavoidrunningquotacheckafteranuncleanshutdown.
quotacheck:Scanning/dev/sdc1[/dave]done
quotacheck:Cannotstatolduserquotafile:Nosuchfileordirectory
quotacheck:Cannotstatoldgroupquotafile:Nosuchfileordirectory
quotacheck:Cannotstatolduserquotafile:Nosuchfileordirectory
quotacheck:Cannotstatoldgroupquotafile:Nosuchfileordirectory
quotacheck:Checked3directoriesand2files
quotacheck:Oldfilenotfound.

1.5.7间接设置配额:setquota

[root@rhce~]#setquota-h
setquota:Usage:
setquota[-u|-g][-rm][-Fquotaformat]<user|group>
<block-softlimit><block-hardlimit><inode-softlimit><inode-hardlimit>-a|<filesystem>...
setquota[-u|-g][-rm][-Fquotaformat]<-pprotouser|protogroup><user|group>-a|<filesystem>...
setquota[-u|-g][-rm][-Fquotaformat]-b[-c]-a|<filesystem>...
setquota[-u|-g][-Fquotaformat]-t<blockgrace><inodegrace>-a|<filesystem>...
setquota[-u|-g][-Fquotaformat]<user|group>-T<blockgrace><inodegrace>-a|<filesystem>...

-u,--usersetlimitsforuser
-g,--groupsetlimitsforgroup
-a,--allsetlimitsforallfilesystems
--always-resolvealwaystrytoresolvename,evenifis
composedonlyofdigits
-F,--format=formatnameoperateonspecificquotaformat
-p,--prototype=protonamecopylimitsfromuser/group
-b,--batchreadlimitsfromstandardinput
-c,--continue-batchcontinueininputprocessingincaseofanerror
-r,--remotesetremotequota(viaRPC)
-m,--no-mixed-pathnamestrimleadingslashesfromNFSv4mountpoints
-t,--edit-periodeditgraceperiod
-T,--edit-timeseditgracetimesforuser/group
-h,--helpdisplaythishelptextandexit
-V,--versiondisplayversioninformationandexit

Bugsto:jack@suse.cz
[root@rhce~]#

二.配额利用示例


2.1创立分区并mount到目次


[root@rhce/]#fdisk/dev/sdc
DevicecontainsneitheravalidDOSpartitiontable,norSun,SGIorOSFdisklabel
BuildinganewDOSdisklabelwithdiskidentifier0x1e051117.
Changeswillremaininmemoryonly,untilyoudecidetowritethem.
Afterthat,ofcourse,thepreviouscontentwontberecoverable.

Warning:invalidflag0x0000ofpartitiontable4willbecorrectedbyw(rite)

WARNING:DOS-compatiblemodeisdeprecated.Itsstronglyrecommendedto
switchoffthemode(commandc)andchangedisplayunitsto
sectors(commandu).

Command(mforhelp):n
Commandaction
eextended
pprimarypartition(1-4)
p
Partitionnumber(1-4):1
Firstcylinder(1-652,default1):
Usingdefaultvalue1
Lastcylinder,+cylindersor+size{K,M,G}(1-652,default652):
Usingdefaultvalue652

Command(mforhelp):w
Thepartitiontablehasbeenaltered!

Callingioctl()tore-readpartitiontable.
Syncingdisks.

[root@rhce/]#fdisk-l

Disk/dev/sdc:5368MB,5368709120bytes
255heads,63sectors/track,652cylinders
Units=cylindersof16065*512=8225280bytes
Sectorsize(logical/physical):512bytes/512bytes
I/Osize(minimum/optimal):512bytes/512bytes
Diskidentifier:0x1e051117

DeviceBootStartEndBlocksIdSystem
/dev/sdc116525237158+83Linux

[root@rhce/]#mkfs-text3/dev/sdc1
mke2fs1.41.12(17-May-2010)
Filesystemlabel=
OStype:Linux
Blocksize=4096(log=2)
Fragmentsize=4096(log=2)
Stride=0blocks,Stripewidth=0blocks
327680inodes,1309289blocks
65464blocks(5.00%)reservedforthesuperuser
Firstdatablock=0
Maximumfilesystemblocks=1342177280
40blockgroups
32768blockspergroup,32768fragmentspergroup
8192inodespergroup
Superblockbackupsstoredonblocks:
32768,98304,163840,229376,294912,819200,884736

Writinginodetables:done
Creatingjournal(32768blocks):done
Writingsuperblocksandfilesystemaccountinginformation:done

Thisfilesystemwillbeautomaticallycheckedevery30mountsor
180days,whichevercomesfirst.Usetune2fs-cor-itooverride.
[root@rhce/]#
[root@rhce/]#mount/dev/sdc1/dave
[root@rhce/]#vim/etc/fstab
/dev/sdc1/daveext3defaults00

我们这里将/dev/sdc1映照到了目次/dave.

2.2创立2个测试用户


[root@rhce/]#groupaddgrp01
[root@rhce/]#groupaddgrp02
[root@rhce/]#cat/etc/group|grepgrp0*
grp01:x:503:
grp02:x:504:
[root@rhce/]#

[root@rhce/]#useradddave01-ggrp01
[root@rhce/]#useradddave02-ggrp02

[root@rhce/]#passwddave01
Changingpasswordforuserdave01.
Newpassword:
BADPASSWORD:itistooshort
BADPASSWORD:istoo***
Retypenewpassword:
passwd:allauthenticationtokensupdatedsuccessfully.
[root@rhce/]#passwddave02
Changingpasswordforuserdave02.
Newpassword:
BADPASSWORD:itistooshort
BADPASSWORD:istoo***
Retypenewpassword:
passwd:allauthenticationtokensupdatedsuccessfully.
[root@rhce/]#

2.3修正分区表启用配额限定


[root@rhce~]#cat/etc/fstab

tmpfs/dev/shmtmpfsdefaults00
devpts/dev/ptsdevptsgid=5,mode=62000
sysfs/syssysfsdefaults00
proc/procprocdefaults00
/dev/sdc1/daveext3defaults,usrquota,grpquot00
[root@rhce~]#


/etc/fstab文件的第四个字段是装载文件体系是利用的选项:
(1)完成基于用户的磁盘配额,就到场usrquota关头字,
(2)完成基于组的磁盘配额,就到场grpqouta关头字,假如二者都必要,就全写进,两头能够用逗号分开。

注重:请出格注重这里的拼写,是usrquota和grpquota,不要写成userquota和groupquota。


2.4从头Remount分区


[root@rhce~]#mount
/dev/sda3on/typeext4(rw)
procon/proctypeproc(rw)
sysfson/systypesysfs(rw)
蒙在股里 该用户已被删除
沙发
发表于 2015-1-16 13:37:28 | 只看该作者

带来一篇CentOS 配额(Quota)申明

linux鸟哥的私房菜,第三版,基础篇,网上有pdf下的,看它的目录和每章的介绍就行了,这个绝对原创!
蒙在股里 该用户已被删除
板凳
发表于 2015-1-24 09:56:07 | 只看该作者
我想即使Linux高手也很难快速准确精练的回答你。
愤怒的大鸟 该用户已被删除
地板
发表于 2015-2-1 10:29:51 | 只看该作者
一定要养成在命令行下工作的习惯,要知道X-window只是运行在命令行模式下的一个应用程序。在命令行下学习虽然一开始进度较慢。
爱飞 该用户已被删除
5#
发表于 2015-2-7 07:51:37 | 只看该作者
查阅经典工具书和Howto,特别是Howto是全球数以万计的Linux、Unix的经验总结非常有参考价值通常40%的问题同样可以解决。
不帅 该用户已被删除
6#
发表于 2015-2-21 19:51:11 | 只看该作者
熟读Linux系统有关知识,如系统目录树,有关内容可购书阅读或搜索论坛。
简单生活 该用户已被删除
7#
发表于 2015-3-6 23:43:32 | 只看该作者
对于英语不是很好的读者红旗 Linux、中标Linux这些中文版本比较适合。现在一些Linux网站有一些Linux版本的免费下载,这里要说的是并不适合Linux初学者。
变相怪杰 该用户已被删除
8#
发表于 2015-3-14 01:58:51 | 只看该作者
尽我能力帮助他人,在帮助他人的同时你会深刻巩固知识。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-3 23:50

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表