IRedMail/FAQ/Store.Realtime.Quota.In.MySQL

From iRedMail

(Difference between revisions)
Jump to: navigation, search
(Created page with '__TOC__ = Requirements = * Dovecot 1.2.x = Steps = * Replace file based quota by quotadict in '''/etc/dovecot.conf''': {{cfg|/etc/dovecot.conf|<pre> plugin { #quota = mail…')
(Steps)
Line 38: Line 38:
* Create file '''/etc/dovecot-realtime-quota.conf''':
* Create file '''/etc/dovecot-realtime-quota.conf''':
{{cfg|/etc/dovecot-realtime-quota.conf|<pre>
{{cfg|/etc/dovecot-realtime-quota.conf|<pre>
-
 
connect = host=localhost dbname=iredadmin user=root password=passwd
connect = host=localhost dbname=iredadmin user=root password=passwd
map {
map {

Revision as of 15:04, 12 October 2010

Contents


Requirements

  • Dovecot 1.2.x

Steps

  • Replace file based quota by quotadict in /etc/dovecot.conf:
File: /etc/dovecot.conf
plugin {
    #quota = maildir                       # <- Comment this line.
    quota = dict:user::proxy::quotadict       # <- Add this line.

    # ... SKIP OTHER CONFIG HERE ...
}
  • Add quotadict in dict section in /etc/dovecot.conf:
File: /etc/dovecot.conf
dict {
    quotadict = mysql:/etc/dovecot-realtime-quota.conf

    # ... SKIP OTHER CONFIG HERE ...
}
  • Create MySQL tables realtime_quota in database iredadmin used to store realtime quota info. (Of course you can use other database instead of iredadmin.)
Terminal:
$ mysql -uroot -p iredadmin
mysql> CREATE TABLE IF NOT EXISTS realtime_quota (
    `username` VARCHAR(255) NOT NULL,
    `bytes` BIGINT NOT NULL DEFAULT 0,
    `messages` BIGINT NOT NULL DEFAULT 0,
    PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  • Create file /etc/dovecot-realtime-quota.conf:
File: /etc/dovecot-realtime-quota.conf
connect = host=localhost dbname=iredadmin user=root password=passwd
map {
    pattern = priv/quota/storage
    table = realtime_quota
    username_field = username
    value_field = bytes
}
map {
    pattern = priv/quota/messages
    table = realtime_quota
    username_field = username
    value_field = messages
}
  • Restart dovecot and it should work as expected now.
Personal tools