In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you the "sample analysis of quota in CentOS", which is easy to understand and clear. I hope it can help you solve your doubts. Let the editor lead you to study and study the "sample analysis of quota in CentOS".
1 theoretical basis
1.1 the concept of Quota
Quota means quota, which is used to limit the amount of space used by users, groups, and folders.
1.2 example of use
-the web server controls the amount of free space available to the site
-mail server controls the amount of free space for users
-file server controls the amount of free space for users
1.3 restricted mode
-controls the amount of free space for each user based on the UID
-controls the amount of free space for each group according to the GID
-controls the amount of free space for each directory according to the directory (directory,project) (xfs available project mode)
1.4 conditions of use
-the EXT format can only restrict the file system, and xfs can restrict project.
-the kernel needs to pre-enable support for Quota
-Quota restriction is valid only for non-administrators
-only Quota for / home is enabled by default, and SELinux needs to be configured for others.
1.5 Configurable objects with restrictions
-by user (User), group (Group), specific directory (project)
-capacity limit or file count limit (block/inode)
-limit values soft (warning and grace time for exceeding space usage) and hard (depriving users of the right to use if they exceed space usage)
-grace time (grace time), the amount of space used exceeds the soft limit and does not reach the processing time limit given by the hard limit (beyond the time limit the soft value becomes the hardest value)
2 actual operation
2.1 preparation before configuration
2.1.1 establish a user group
Groupadd gp1
2.1.2 add group members
Useradd-g gp1 user1
Echo "pwd1" | passwd-- stdin user1
Useradd-g gp1 user2
Echo "pwd1" | passwd-- stdin user2
2.1.2 create user directories and change all groups
Mkdir / home/gp1
Chgrp gp1 / home/gp1
Chmod 2770 / home/gp1
2.1.2 check the file system type
Df-hT / home
The display is as follows:
Filesystem Type Size Used Avail Use% Mounted on
/ dev/mapper/centos-home xfs 5.0G 67M 5.0G 2% / home
2.2 enable the quota feature of the file system
2.2.1 Editing fstab
Vim / etc/fstab
The modifications are as follows:
/ dev/mapper/centos-home / home xfs defaults,usrquota,grpquota 0 0
Note, the types are as follows:
-based on user (uquota/usrquota/quota)
-by group (gquota/grpquota)
-according to directory (pquota/prjquota) (cannot be set at the same time as grpquota)
2.2.2 Uninstall and remount
Umount / home
Mount-a
2.2.3 check
Mount | grep home
The display is as follows:
/ dev/mapper/centos-home on / home type xfs (rw,relatime,seclabel,attr2,inode64,usrquota,grpquota)
2.3 check Quota information
2.3.1 Command format
Xfs_quota-x-c "subcommand" [mount point]
Options:
-x: expert mode, use-x to use-c
-c: subcommand option
Subcommand:
Print: list current system parameters, etc.
Df: similar to df, options include-b (block)-I (inode)-h (plus units), etc.
Report: lists quota projects, including-ugr (user/group/project) and-bi, etc.
State: lists the currently supported quota file system information and related startup items
2.3.2 query partitions that support Quota
Xfs_quota-x-c "print"
2.3.3 query the usage of Quota directory
Xfs_quota-x-c "df-h" / hom
2.3.4 display the limit information of the user's Quota
Xfs_quota-x-c "report-ubih" / home
Note: show item plus parameter "- u"
2.4 configuration restrictions
2.4.1 Command format:
Xfs_quota-x-c "limit [- ug] b [soft | hard] = Ni [soft | hard] = N name"
Xfs_quota-x-c "timer [- ug] [- bir] Ndays"
Options:
Limit: restricted objects, including user/group/project
Bsoft/bhard: soft/hard limit of block
Isoft/ihard: soft/hard limit of inode
Name: names of users and groups
Timer: grace time (grace time)
2.4.2 based on user and block size limit
Xfs_quota-x-c "limit-u bsoft=250M bhard=300M user1" / home
Xfs_quota-x-c "limit-u bsoft=250M bhard=300M user2" / home
Check the configuration:
Xfs_quota-x-c "report-ubih" / home
2.4.3 limits based on group and block size
Xfs_quota-x-c "limit-g bsoft=950M bhard=1G gp1" / home
Check the configuration:
Xfs_quota-x-c "report-gbih" / home
2.4.5 configure grace time
Xfs_quota-x-c "timer-ug-b 14days" / home
Verify the configuration:
Xfs_quota-x-c "state" / home
2.4.6 verify Quta
Su-user1
Dd if=/dev/zero of=123.img bs=1M count=310
Ll-h
Exit
Xfs_quota-x-c "report-ubh" / home
2.5 according to project restrictions
2.5.1 modify fstab
Vim / etc/fstab
2.5.2 Unmount and remount
Umount / home
Mount-a
2.5.3 check cancellation
Xfs_quota-x-c "state"
2.5.4 create a project storage location
Mkdir / home/proj01
2.5.5 specify the project identification number
Echo "01:/home/proj01" > > / etc/projects
2.5.6 specify the project name and associate the project identification number
Echo "proj01:01" > > / etc/projid
2.5.7 initialize the project name
Xfs_quota-x-c "project-s proj01"
Check the configuration:
Xfs_quota-x-c "print" / home
Xfs_quota-x-c "report-pbih" / home
2.5.8 configure limits based on block size
Xfs_quota-x-c "limit-p bsoft=450M bhard=500M proj01" / home
Check the configuration:
Xfs_quota-x-c "report-pbih" / home
2.5.9 verify the configuration
Dd if=/dev/zero of=/home/myquota/123.img bs=1M count=510
2.6Management of Quota
2.6.1 temporarily disable Quota restrictions
Xfs_quota-x-c "disable-up" / home
Check disabled:
Xfs_quota-x-c "state" / home
Authentication is disabled:
Dd if=/dev/zero of=/home/user1/123.img bs=1M count=520
Check the Quota status:
Xfs_quota-x-c "report-pbh" / home
Clean up the test files:
Rm-rf / home/user1/123.img
2.6.2 temporary launch Quota restrictions
Xfs_quota-x-c "enable-up" / home
Verify startup:
Dd if=/dev/zero of=/home/user1/123.img bs=1M count=520
2.6.3 completely close the Quota restriction
Xfs_quota-x-c "off-up" / home
Test off:
Xfs_quota-x-c "enable-up" / home
Restore shutdown:
Umount / home; mount-a
2.6.4 remove Quota restriction (unrecoverable)
Xfs_quota-x-c "off-up" / home
Xfs_quota-x-c "remove-p" / home
Verify deletion:
Xfs_quota-x-c "report-phb" / home
2.7 using soft connection to implement Quota
1) enable the Quota function of / home partition
Edit fstab
Vim / etc/fstab
The modifications are as follows:
/ dev/mapper/centos-home / home xfs defaults,usrquota,grpquota 0 0
2) create a soft connection to the Quota partition
Ln-s / home/mail / var/spool/mail
The above is all the content of the article "sample Analysis of quota in CentOS". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.