OS X Server 10.3 Cyrus Mailserver Trouble?
The Cyrus mail server on some Mac OS X server machine acted up yesterday. It turned out the Cyrus DB file was damaged, something that happens sometimes it seems. I searched the web for the error message and after a while came up with something. This morning I rebuilt the database and service is back up. Read on for the description...
The error messages looked something like this:
Jul 27 10:02:34 localhost imap[2658]: DBERROR db4: fatal region error detected; run recovery Jul 27 10:02:34 localhost imap[2658]: DBERROR: dbenv->open '/var/imap/db' failed: DB_RUNRECOVERY: Fatal error, run database recovery Jul 27 10:02:34 localhost imap[2658]: DBERROR: init() on berkeley Jul 27 10:02:34 localhost imap[2658]: DBERROR db4: environment not yet opened Jul 27 10:02:34 localhost imap[2658]: DBERROR: opening /var/imap/mailboxes.db: Invalid argument Jul 27 10:02:34 localhost imap[2658]: DBERROR: opening /var/imap/mailboxes.db: cyrusdb error Jul 27 10:02:34 localhost imap[2658]: Fatal error: can't read mailboxes file Jul 27 10:02:34 localhost master[499]: service imap pid 2658 in READY state: terminated abnormally Jul 27 10:02:34 localhost imap[2666]: DBERROR db4: fatal region error detected; run recovery Jul 27 10:02:34 localhost imap[2666]: DBERROR: dbenv->open '/var/imap/db' failed: DB_RUNRECOVERY: Fatal error, run database recovery Jul 27 10:02:34 localhost imap[2666]: DBERROR: init() on berkeley Jul 27 10:02:34 localhost imap[2666]: DBERROR db4: environment not yet opened Jul 27 10:02:34 localhost imap[2666]: DBERROR: opening /var/imap/mailboxes.db: Invalid argument Jul 27 10:02:34 localhost imap[2666]: DBERROR: opening /var/imap/mailboxes.db: cyrusdb error Jul 27 10:02:34 localhost imap[2666]: Fatal error: can't read mailboxes file Jul 27 10:02:34 localhost master[499]: service imap pid 2666 in READY state: terminated abnormallyThe ugly thing was that since SMTP was still running, the server was accepting incoming mails, but returning them later. Not nice. Stopping the mail services all together is a better option in this situation.
Googling around found me some hints, and in the end the Apple Technote: Mac OS X Server 10.3: Reconstructing cyrus mailboxes. Apparently 10.4 Server has a nice and shiny button for this, but for 10.3 Server the procedure can be done in the shell (after stopping mail services):
$ su root # mv /var/imap /var/imap.old # mkdir /var/imap # /usr/bin/cyrus/tools/mkimap # chown -R cyrus:mail /var/imap # sudo -u cyrus /usr/bin/cyrus/bin/reconstruct -iRead all the technote! Don't blame me if you mess it up, etc. etc.