11.3 Using Multiple Queue Directories
Beginning with V8.10,
sendmail allows the use of multiple queue
directories. These multiple queue directories take two forms:
More than one queue directory can be specified, possibly on separate
disks, into which all the qf,
df, and xf files are placed.
Any queue directory can have a subdirectory named
qf, and/or df, and/or
xf, in which sendmail
stores the corresponding qf,
df, and xf files.
11.3.1 Multiple Queue Directories
V8.10 sendmail offers the ability to distribute
queued messages across multiple directories. In general, this is a
good idea. If, for example, a high volume of email is stressing your
current disk, you can improve efficiency by using multiple queue
directories spread over multiple disks and controllers.
To illustrate, we will set up a machine that has three brand-new
disks to use as multiple queue directories. The disks have already
been formatted and a filesystem has been placed on each. We next
create directories on which to mount them:
# mkdir /var/queues /var/queues/q.1 /var/queues/q.2 /var/queues/q.3
# chmod 700 /var/queues /var/queues/q.?
Because of the way multiple queue directories are implemented inside
sendmail, the queue directory names must differ
only in their suffixes, hence the trailing 1, 2, and 3. First the
directories are created with mkdir(1) or a
symbolic link, then the permission on each is reduced to readable and
writable only by root for security reasons. Note
that these are the permissions after all queue disks are mounted.
Next, arrange for the disks to be mounted by placing the appropriate
entries in /etc/fstab or
/etc/vfstab. Here, we illustrate with the
partial contents of /etc/fstab for Linux:
/dev/hda2 /var/queues/q.1 ext2 defaults 1 1
/dev/hdb1 /var/queues/q.2 ext2 defaults 1 1
/dev/hdc1 /var/queues/q.3 ext2 defaults 1 1
Note that we are mounting a separate disk on each queue directory.
Your disk device names will doubtless differ, and you can use any
directory locations and names you wish. Note that after you mount the
disks, you might need to change the permissions again to 700 for each
mount point.
The idea is to prepare the directories for use as multiple queue
directories first, and after that, to modify the configuration file
so that sendmail can use those queue
directories:
define(`QUEUE_DIR',`/var/queues/q.*')
Here, the QUEUE_DIR mc configuration macro is
given the value /var/queues/q.*, which will become
the value for the QueueDirectory option. The
trailing * character is a literal asterisk (not a
wildcard character) and must appear as a suffix, in the last position
of the path specification. It tells sendmail to
use all the queue directories that begin with the path
/var/queues/q. and end with any other
characters. In our example, sendmail will match
/var/queues/q.1,
/var/queues/q.2, and
/var/queues/q.3.
It is not strictly necessary to mount a disk on each queue directory.
If the directory name is a symbolic link to another directory,
sendmail will use that other directory as a
queue directory. The only requirement is that the other directory
have as restrictive set of permissions as the original queue has.
In Section 6.5 of Chapter 6, we
show how to use multiple queue directories to improve overall
performance.
11.3.1.1 Printing multiple queue directories
After you have configured for multiple queue directories, you will
find there is a small difference in the way various versions of
sendmail print the queue contents. Prior to
V8.10 sendmail, the heading for a queue listing
printed like this:
Mail queue is empty when nothing is queued (pre-V8.10)
Mail queue (1 request) when one message is queued (pre-V8.10)
Starting with V8.10 sendmail, that heading now
looks like this:
/var/spool/mqueue is empty when nothing is queued (V8.10 and above)
/var/spool/mqueue (1 request) when one message is queued (V8.10 and above)
The full pathname of the queue is printed, regardless of whether you
are running multiple queue directories. This behavior is beneficial
when running multiple queue directories because it lets you know
which queue directory contains what mail:
/var/spool/mqueues/q.1 is empty
/var/spool/mqueues/q.2 (1 request)
----Q-ID---- --Size-- -----Q-Time----- ------------Sender/Recipient------------
dB9Fdaa06420 4567 Thu Dec 9 07:39 you@your.domain
<gw@us.gov>
Total Requests: 1
From this output, it is clear that q.1 is empty
and q.2 contains a single message.
Unfortunately, the two headings indent differently but this is easily
gotten used to.
In the previous output, also notice that when multiple queue
directories are printed, a trailing line is printed after all queue
directories are printed that shows the total of all messages in all
queue directories. If you run dozens or hundreds of queue
directories, you might find it useful to summarize the number of
queued messages like this:
% mailq -OMaxQueueRunSize=1 | tail -1
Total Requests: 41291
The expression -OMaxQueueRunSize=1 (MaxQueueRunSize) causes sendmail to
process each queue directory extremely fast, regardless of how many
messages are queued in each.
11.3.1.2 Processing multiple queue directories
When sendmail processes multiple queue
directories it processes them in parallel. That is, it forks and runs
a queue processing child of sendmail for each,
all of which run at the same time. The maximum number of
sendmail queue processors run is limited by the
MaxDaemonChildren option (MaxDaemonChildren). If that limit is reached before all the
queue directories can be parallel-processed,
sendmail will remember where it stopped and
perform the next run starting from where the prior run left off.
The only exception to this behavior occurs when queue processing with
the -v (verbose) command-line switch. When
-v is combined with -q,
processing is always sequential. That is, one queue directory is
processed at a time, and the next is not begun until the first
finishes. The -v allows you to watch the queue
being processed, so it makes sense that you would want to watch only
one queue directory at a time.
11.3.2 Using qf, df, and xf Subdirectories
Beginning with V8.10, sendmail allows the
qf,
df, and
xf files to reside in separate directories.
One advantage to this is that it produces directories that are
one-third smaller. Another advantage is that each part can reside on
a separate disk for further performance enhancements.
This feature is enabled by simply creating the appropriately named
subdirectories, or symbolic links, in each queue directory. The names
of those subdirectories or symbolic links are the literals
qf, df, and
xf. But be aware that you should not create
those directories or links when mail is already queued. If you do,
that queued mail will disappear from
sendmail's view and will never
be delivered. If you need to make the change while mail is queued,
first stop sendmail, then execute the following
commands and restart sendmail:
# mkdir df qf xf
# chmod 700 df qf xf
# mv df?* df/ if mail is already queued
# mv qf?* qf/ if mail is already queued
# mv xf?* xf/ if mail is already queued
Here, we first create the new subdirectories in the queue directory.
Then we reduce their permissions to the narrow ones that match the
queue directory. Finally, if queued mail already existed in the queue
directory, we move that mail into the new subdirectories where
sendmail will find it.
Because xf files are empty for all successfully
delivered mail, there is a penalty for creating and deleting those
files just because they might be needed. When performance is of
concern, you can either mount a memory filesystem on the
xf subdirectory, or replace the
xf subdirectory with a symbolic link to a
directory on a memory filesystem. In the following, we show a
/etc/fstab file for a SunOS machine that uses
the direct-mount approach:
/dev/sd0g /var/spool/mqueue/df 4.2 rw 1 4
/dev/sd2g /var/spool/mqueue/qf 4.2 rw 1 2
swap /var/spool/mqueue/xf tmp rw 0 0
See Section 6.5 for a description of how to use a
different type of disk for each part, and how performance is impacted
by such choices.
An artifact of using qf,
df, and xf subdirectories
is seen when printing the queue. The df
directory is always the one listed:
/var/spool/mqueue/df is empty
|