dynalist 分配的定额

2018-8-29 dynalist 配额

磁盘配额quota,磁盘配额

磁盘配额

1 启用磁盘配额

首先创建新的分区 /dev/sd5,并创建文件系统。

[[email protected]
~]# mkfs.ext4 /dev/sda5

由于xfs 不磁盘配额能成功,这里使用ext4.

然后把/dev/sda5分区挂载到 /home

[[email protected]
~]# mount /dev/sda5 /home

[[email protected]
~]# blkid /dev/sda5

/dev/sda5: UUID=”8879cf63-99a5-43bb-9bfe-de303afb0799″ TYPE=”ext4″

修改 /etc/fstab 文件

[[email protected]
~]# vim /etc/fstab

UUID=dddd23d1-1012-4bac-9717-56b9b469e0c2 / ext4 defaults 1 1

UUID=316d8677-25b8-49af-b4eb-54daa20b6595 /boot ext4 defaults 1 2

UUID=dacd6ddd-d765-4646-b98c-0579f2732749 swap swap defaults 0 0

UUID=8879cf63-99a5-43bb-9bfe-de303afb0799 /home ext4
defaults,usrquota,grpquota 0 0

usrquota为启用磁盘的用户磁盘配额功能,grpquota为启用磁盘的组磁盘配额功能。

[[email protected]
~]# mount –a /home/

查看挂载是否成功

[[email protected]
~]# mount

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)

proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)

[……]

/dev/sda5 on /home type ext4
(rw,relatime,seclabel,quota,usrquota,grpquota,data=ordered)

可以看到/dev/sda5已经正确挂载

2创建配额数据库

[[email protected]
~]# quotacheck -cug /home

由于/etc/fstab 文件设置了usrquota,grpquota,所以这里必须是
–cug,u对应usrquota,g对应grpquota。

现在查看/home目录,会多出两个文件,说明磁盘配额数据库创建成功。

[[email protected]
~]# ll /home/

total 36

-rw——-. 1 root root 7168 Apr 25 11:03 aquota.group

-rw——-. 1 root root 7168 Apr 25 11:03 aquota.user

drwx——. 3 centos centos 4096 Apr 16 10:20 centos

drwx——. 2 root root 16384 Apr 25 10:55 lost+found

3 启用数据库

[[email protected]
~]# quotaon /home/

[[email protected]
~]#

下来查看一下,可以看到以及启用成功。

[[email protected]
~]# quotaon -p /home/

group quota on /home (/dev/sda5) is on

user quota on /home (/dev/sda5) is on

4 磁盘配额设置

设置user1 磁盘配额为100M,80M时发出警告

[[email protected]
~]# edquota user1

Disk quotas for user user1 (uid 1001):

Filesystem blocks soft hard inodes soft hard

/dev/sda5 52 80000 100000 13 0 0

这里的默认单位为block ,1个block为1K。soft为警告值,hard为最大值,

现在来确认一下配置是否成功

[[email protected] ~]# quota user1    #查看用户user 的磁盘配额
Disk quotas for user user1 (uid 1001):
Filesystem blocks quota limit grace files quota limit grace
/dev/sda5 52 80000 100000 13 0 0

5 测试

(1)创建测试的用户 user1

[[email protected] ~]# useradd uesr1

切换到user1用户

[[email protected] ~]# su - user1

Last login: Tue Apr 25 11:08:41 CST 2017 on pts/1

(2)创建文件测试

首先创建一个50M 的文件testquota。

[[email protected] ~]$ dd if=/dev/zero of=testquota bs=1M count=50
50+0 records in
50+0 records out
52428800 bytes (52 MB) copied, 0.562963 s, 93.1 MB/s

可以看到一切正常

    再来创建一个35M 的文件testquota2。

[[email protected] ~]$ dd if=/dev/zero of=testquota2 bs=1M count=35

sda5: warning, user block quota exceeded.
35+0 records in
35+0 records out
36700160 bytes (37 MB) copied, 0.348267 s, 105 MB/s

由于50M+35M=85M 大于80M

所有看到这次发出警告了,但是操作还是成功了

    下来再创建一个20M的文件testquota3。

[[email protected] ~]$ dd if=/dev/zero of=testquota3 bs=1M count=20

sda5: write failed, user block limit reached.
dd: error writing 'testquota3': Disk quota exceeded
13+0 records in
12+0 records out
13217792 bytes (13 MB) copied, 0.165029 s, 80.1 MB/s

由于已经超过最大值100M,所以创建失败了!

测试完成,实验结束!

磁盘配额 1 启用磁盘配额
首先创建新的分区 /dev/sd5,并创建文件系统。
[[email protected]
~]# mkfs.ext4 /dev/sda5 由于xfs 不磁盘…

ZooKeeper可以在znode上设置配额限制。如果超出了配置限制,ZooKeeper将会在log日志中打印WARN日志。如果超出配额限制,并不会停止行为操作。

这部分操作是较为简单的

提示有一个G的配额 就是使用的流量用光了.仅有1个G 

ZooKeeper的配额是存储在/zookeeper/quota路径下的。可以通过ZooKeeper
client APIs或者ZooKeeper Java Shell来进行set,list,delete配额。


下面举一个例子说明:

打开“此电脑”,找到想设置磁盘配额的磁盘(多数为C盘),右键菜单,单击“属性”

图片 1

磁盘配额

按照如图所示操作即可

[zk: localhost:2181(CONNECTED) 3] setquota -n 2 /yandufeng_quota
Comment: the parts are option -n val 2 path /yandufeng_quota
[zk: localhost:2181(CONNECTED) 4] 
[zk: localhost:2181(CONNECTED) 4] 
[zk: localhost:2181(CONNECTED) 4] listquota /yandufeng_

yandufeng_quota   yandufeng_test
[zk: localhost:2181(CONNECTED) 4] listquota /yandufeng_quota
absolute path is /zookeeper/quota/yandufeng_quota/zookeeper_limits
Output quota for /yandufeng_quota count=2,bytes=-1
Output stat for /yandufeng_quota count=1,bytes=2
[zk: localhost:2181(CONNECTED) 5] 
[zk: localhost:2181(CONNECTED) 5] 
[zk: localhost:2181(CONNECTED) 5] 
[zk: localhost:2181(CONNECTED) 5] 
[zk: localhost:2181(CONNECTED) 5] 
[zk: localhost:2181(CONNECTED) 5] create /yandufeng_

yandufeng_quota   yandufeng_test
[zk: localhost:2181(CONNECTED) 5] create /yandufeng_quota/child1 ""
Created /yandufeng_quota/child1
[zk: localhost:2181(CONNECTED) 6] create /yandufeng_

yandufeng_quota   yandufeng_test
[zk: localhost:2181(CONNECTED) 6] create /yandufeng_quota/child2 ""
Created /yandufeng_quota/child2
[zk: localhost:2181(CONNECTED) 7] create /yandufeng_

yandufeng_quota   yandufeng_test
[zk: localhost:2181(CONNECTED) 7] create /yandufeng_quota/child

child2   child1
[zk: localhost:2181(CONNECTED) 7] create /yandufeng_quota/child3 ""
Created /yandufeng_quota/child3

返回上一层**

当你创建/yandufeng_quota/child3时,会在ZooKeeper的log日志中打印

2017-02-08 10:38:43,738 - WARN  [CommitProcessor:10:DataTree@388] - Quota exceeded: /yandufeng_quota count=5 limit=2

 

你也可以执行

[zk: localhost:2181(CONNECTED) 18] delquota /yandufeng_quota

 来删除这个配额

相关文章