How to use Quota option in Glusterfs ?

Applying quota on directory is very common requirement. In case of gluterfs we are also having the provision of applying the quota on directories. In this article I am going to show how to use quota option in Glusterfs.

Step 1 : Before applying the quota on directory which is present in volume we need to enable the quota option at volume level.

[root@Node2 ~]# gluster vol quota RepVol2 enable
volume quota : success

Step 2 : I have mounted the volume on client at mountpoint (/mnt) and I have created one directory beneath  it.

[root@Node1 mnt]# mkdir /mnt/Dir1
[root@Node1 mnt]#

Step 3 : I have applied quota limit on the directory of 10 MB. This limit is hard limit and the soft limit by default is 80% of the hard limit.

[root@Node2 RepBrck2Node2]# gluster vol quota RepVol2 limit-usage /Dir1 10MB
volume quota : success

[root@Node2 RepBrck2Node2]# gluster vol quota RepVol2 list
Path                   Hard-limit Soft-limit   Used  Available  Soft-limit exceeded? Hard-limit exceeded?
—————————————————————————————————————————
/Dir1                                     10.0MB       80%      0Bytes  10.0MB              No                   No

Step 4 : We can change the value of soft limit using below method. I have changed it to 90% from 80%. We can defined this one command initially while defining the hard limit.

[root@Node2 RepBrck2Node2]# gluster vol quota RepVol2 limit-usage /Dir1 10MB 90%
volume quota : success

[root@Node2 RepBrck2Node2]# gluster vol quota RepVol2 list
Path                   Hard-limit Soft-limit   Used  Available  Soft-limit exceeded? Hard-limit exceeded?
—————————————————————————————————————————
/Dir1                                     10.0MB       90%      0Bytes  10.0MB              No                   No

Step 5 : Its time to check whether our quota is working fine or not.

I have went to client and created three file. During creating check3 quota limit has been reached but it allow the completion of that file and after that it will not allow the creation of new files.

[root@Node1 Dir1]# pwd
/mnt/Dir1

[root@Node1 Dir1]# du -sch *
9.0M    check1
10K     check2
9.0M    check3
19M     total

[root@Node1 Dir1]# dd if=/dev/zero of=/mnt/Dir1/check4 count=9 bs=1M
dd: opening `/mnt/Dir1/check4′: Disk quota exceeded

Step 6 : We can check the current status of quota.

[root@Node2 RepBrck2Node2]# gluster vol quota RepVol2 list
Path                   Hard-limit Soft-limit   Used  Available  Soft-limit exceeded? Hard-limit exceeded?
—————————————————————————————————————————
/Dir1                                     10.0MB       90%      18.0MB  0Bytes             Yes                  Yes

Quota has exceeded the limit we can see the message in log file as well.

[root@Node2 RepBrck2Node2]# tailf /var/log/glusterfs/bricks/Replicated2-RepBrck2Node2.log
[2014-12-27 14:54:32.789284] I [server-rpc-fops.c:1587:server_create_cbk] 0-RepVol2-server: 484: CREATE /Dir1//check4 (cdae350e-27cd-43f3-b130-99bb053bb503/check4) ==> (Disk quota exceeded)

Step 7 : We have the provision to lift the soft limit permanently from 80% to 90%.

[root@Node2 RepBrck2Node2]# gluster vol quota RepVol2 default-soft-limit 90%
volume quota : success

Step 8 : If we want to remove the existing quota on directory.

[root@Node2 RepBrck2Node2]# gluster vol quota RepVol2 remove /Dir1
volume quota : success

We can verify the above operation using below command.

[root@Node2 RepBrck2Node2]# gluster vol quota RepVol2 list
quota: No quota configured on volume RepVol2

Step 9 : Disabling quota on whole volume.

[root@Node2 RepBrck2Node2]# gluster vol quota RepVol2 disable
Disabling quota will delete all the quota configuration. Do you want to continue? (y/n) y
volume quota : success

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s