基于文件的proftpd磁盘配额quota

  使用Ports安装proftpd,并把mod_quota选上,不过装完后没有找到ftpquota命令。只好又./configure –with-modules=mod_quotatab:mod_quotatab_file&&make,把ftpquota拷出来。

  首先编辑proftpd.conf
QuotaLimitTable file:/usr/local/etc/ftpquota.limittab #Limit文件
QuotaTallyTable file:/usr/local/etc/ftpquota.tallytab #Tally文件
QuotaDirectoryTally on #是否记录目录操作
QuotaDisplayUnits Mb #客户端显示的容量单位
QuotaEngine on #是否启用quota
QuotaLog /var/log/ftpquota.log #日志文件地址
QuotaShowQuotas on #是否响应SITE QUOTA
QuotaOptions ScanOnLogin #登录时扫描用户home目录更新文件大小和数量

  Limit文件记录配额,Tally文件记录已经使用的配额。ScanOnLogin则会在用户登录时扫描用户home目录,更新uploaded文件大小和数目,因为mod_quota只会记录该用户通过ftp的操作,使用ScanOnLogin可以保证Tally的uploaded文件大小和数量和用户home目录的一致。不过我把QuotaOptions ScanOnLogin注释了,因为我要限制的是上传量,但是不想把那些提供下载的文件也包含进去。不过这样就要手动修正已使用配额,当然也可以写脚本定时将/uploads的文件大小和数量自动写入tally文件。

  再来建立配置文件:
先把limit和tally两个文件建立了
/home/yaoge123# cd /usr/local/etc/
/usr/local/etc# ftpquota --create-table --type=limit
/usr/local/etc# ftpquota --create-table --type=tally

下面添加一个限制,硬性限制ftp这个用户最多上传1000个文件,总大小最多1G
/usr/local/etc# ftpquota --add-record --type=limit --quota-type=user --name=ftp --files-upload=1000 --bytes-upload=1024 --limit-type="hard" --units="Mb"
–add-record –type=limit 增加一个limit限制信息
–quota-type=user –name=ftp 限制对象是用户名是ftp
–files-upload=1000 –bytes-upload=1024 限制上传1000个文件,总大小1024Mb
–units=”Mb” 说明上面的那个1024的单位是Mb
–limit-type=”hard” 硬性限制,到达限制容量就强制中断上传

使用ftpquota –show-record –type=limit可以查看已有的配额
/usr/local/etc# ftpquota --show-record --type=limit ftpquota.limittab
-------------------------------------------
Name: ftp
Quota Type: User
Per Session: False
Limit Type: Hard
Uploaded bytes: 1073741824.00
Downloaded bytes: unlimited
Transferred bytes: unlimited
Uploaded files: 1000
Downloaded files: unlimited
Transferred files: unlimited

使用ftpquota –show-record –type=tally可以查看已经使用的配额
/usr/local/etc# ftpquota --show-record --type=tally
-------------------------------------------
Name: ftp
Quota Type: User
Uploaded bytes: 0.00
Downloaded bytes: 0.00
Transferred bytes: 0.00
Uploaded files: 0
Downloaded files: 0
Transferred files: 0

使用ftpquota –update-record可以修改limit和tally。下面是一个修改和清零tally的例子:
/usr/local/etc# ftpquota --update-record --type=tally --quota-type=user -name=ftp --files-upload=100 --bytes-upload=100 --units="Mb"
/usr/local/etc# ftpquota --show-record --type=tally
-------------------------------------------
Name: ftp
Quota Type: User
Uploaded bytes: 104857600.00
Downloaded bytes: 0.00
Transferred bytes: 0.00
Uploaded files: 100
Downloaded files: 0
Transferred files: 0
/usr/local/etc# ftpquota --update-record --type=tally --quota-type=user -name=ftp
/usr/local/etc# ftpquota --show-record --type=tally
-------------------------------------------
Name: ftp
Quota Type: User
Uploaded bytes: 0.00
Downloaded bytes: 0.00
Transferred bytes: 0.00
Uploaded files: 0
Downloaded files: 0
Transferred files: 0

本文共有 2 条评论基于文件的proftpd磁盘配额quota


  1. 1 fallish

    lz的文章让我很受益。但不知道你是通过怎样的渠道学习proftpd,感觉网上这方面的资料不多,而且讲的比较浅。我自己除了上网查资料,就是看源代码里面附带的文档。

  2. 2 yaoge123

请留下您的评论:

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word