IRedMail/FAQ/Store.Realtime.Quota.In.MySQL
From iRedMail
(Difference between revisions)
(→Steps) |
(→Steps) |
||
| Line 43: | Line 43: | ||
</pre>}} | </pre>}} | ||
| - | * Create file '''/etc/dovecot-used-quota.conf''' (''' | + | * Create file '''/etc/dovecot-used-quota.conf'''. Note: |
| + | ** If you're using iRedAdmin (either Open Source Edition or iRedAdmin-Pro), you can find database user and password in its config file '''settings.ini''', under iRedAdmin installation root directory, in section '''[iredadmin]'''. | ||
| + | ** Change '''dbname''', '''table''' if you're using MySQL backend. | ||
| + | |||
{{cfg|/etc/dovecot-used-quota.conf|<pre> | {{cfg|/etc/dovecot-used-quota.conf|<pre> | ||
| - | connect = host=localhost dbname=iredadmin user= | + | connect = host=localhost dbname=iredadmin user=iredadmin password=passwd |
map { | map { | ||
pattern = priv/quota/storage | pattern = priv/quota/storage | ||
| Line 59: | Line 62: | ||
} | } | ||
</pre>}} | </pre>}} | ||
| + | |||
| + | Note: You can find | ||
* Restart dovecot and it should work as expected now. | * Restart dovecot and it should work as expected now. | ||
Revision as of 11:52, 14 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-used-quota.conf # <- Add this line.
# ... SKIP OTHER CONFIG HERE ...
}
|
- [For OpenLDAP backend] Create MySQL tables used_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 `used_quota` (
`username` VARCHAR(255) NOT NULL,
`bytes` BIGINT(20) NOT NULL DEFAULT 0,
`messages` BIGINT(20) NOT NULL DEFAULT 0,
PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
- [For MySQL backend] If you're using iRedMail-0.6.1 or order version, you can simply add two columns in table vmail.mailbox:
| Terminal: |
$ mysql -uroot -p vmail mysql> ALTER TABLE mailbox ADD COLUMN `bytes` BIGINT(20) NOT NULL DEFAULT 0; mysql> ALTER TABLE mailbox ADD COLUMN `messages` BIGINT(20) NOT NULL DEFAULT 0; |
- Create file /etc/dovecot-used-quota.conf. Note:
- If you're using iRedAdmin (either Open Source Edition or iRedAdmin-Pro), you can find database user and password in its config file settings.ini, under iRedAdmin installation root directory, in section [iredadmin].
- Change dbname, table if you're using MySQL backend.
| File: /etc/dovecot-used-quota.conf |
connect = host=localhost dbname=iredadmin user=iredadmin password=passwd
map {
pattern = priv/quota/storage
table = used_quota
username_field = username
value_field = bytes
}
map {
pattern = priv/quota/messages
table = used_quota
username_field = username
value_field = messages
}
|
Note: You can find
- Restart dovecot and it should work as expected now.
References
- Dovecot dictionary quota: http://wiki.dovecot.org/Quota/Dict
- Article contributed by @maxie_ro, works with Dovecot-1.1.x
