Store attachment outside of the database

From Zarafa wiki

Revision as of 13:05, 23 February 2011 by Admin (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

From Zarafa version 6 you will have the possibility to store all attachments outside of the MySQL database. The architecture change is made to get a more efficient MySQL caching system and get a smaller database.

Configuring storage method

The attachment storage can be configured in the server.cfg file via the option attachment_storage. When using the install script the default value is set to database, so the attachments are stored in the database. To store the attachment outside of the database, set this option to files and configure the attachment_path. Make sure that there is enough space on this partition.

Migrating database storage to files

Existing installations that already have the attachments in the database have the possibility to migrated to the file storage. In the /usr/share/doc/zarafa directory there is a script available called db-convert-attachments-to-files. This perl script will directly login to MySQL and dump the attachments to the specified directory. You have the run the script with the following options:

perl db-convert-attachments-to-files mysqluser mysqlpassword mysqldatabase path_to_filesystem [delete]

The last delete option is optional. This option will delete the attachments from the database. The script can ran multiple times after each other, without having the attachments duplicated.

To enable this settings you have to restart your Zarafa-server one time with the option --ignore-attachment-storage-conflict.

zarafa-server --ignore-attachment-storage-conflict

Storage layout

The attachments are not all stored in a single directory, but spread over 200 directories. Below the specified attachment_path there are 10 directories (0 - 9). Each directory has 20 subdirectories (0 - 19). Through the attachment id in the database, the exact location can be calculated via a fast algorithm. The attachment is in one of the directories with the id as filename. The stored attachment is the same as the attachment you will see in your email. With the file command you can see the probable type of the attachment.

Personal tools