Recipe 9.1 Creating Multiple Queues

Problem

You have been asked to create multiple mail queues spread over multiple physical devices in order to efficiently handle a large amount of mail.

Solution

Prepare the physical devices that will hold the mail queues. Each device must be formatted according to the requirements of your system and must contain a filesystem that is compatible with your operating system. Formatting devices and building Unix filesystems is beyond the scope of this book. See Essential System Administration , Third Edition, by leen Frisch (O'Reilly).

Create the directories needed for the various mail queues:

 #  cd /var/spool/mqueue  #  mkdir queue.1 queue.2 queue.3  #  chmod 700 queue.?  

Mount the physical devices on the newly created directories. This example uses Linux device names :

 #  mount /dev/hda1 /var/spool/mqueue/queue.1  #  mount /dev/hdb2 /var/spool/mqueue/queue.2  #  mount /dev/hdd1 /var/spool/mqueue/queue.3  

Edit the /etc/fstab or /etc/vfstab file to mount the devices during every boot. Here are the sample mounts defined in an /etc/fstab file on a Red Hat Linux system:

 /dev/hda1   /var/spool/mqueue/queue.1   ext3   defaults  1 2 /dev/hdb2   /var/spool/mqueue/queue.2   ext3   defaults  1 2 /dev/hdd1   /var/spool/mqueue/queue.3   ext3   defaults  1 2 

Note that the lines above are added to the current /etc/fstab file. Overwriting or deleting the existing entries in the fstab file could severely impact the system ”rendering it incapable of rebooting. Use care when adding lines to the fstab file.


Add the QUEUE_DIR define to the sendmail configuration to use the new queue directories. Here is an example of the define:

 dnl Declare the queue directory path define(`QUEUE_DIR', `/var/spool/mqueue/queue.*') 

Build sendmail.cf . Copy it to /etc/mail/sendmail.cf , and restart sendmail, as shown in Recipe 1.8.

Discussion

By default, sendmail uses a single queue directory, which is usually named /var/spool/mqueue in the sendmail.cf file. The queue directory pathname is defined by the QueueDirectory option. A grep of a basic sendmail configuration shows the default:

 $  grep QueueDirectory generic-linux.cf  O QueueDirectory=/var/spool/mqueue 

Use the m4 QUEUE_DIR define to set the value of the QueueDirectory option. After reconfiguring sendmail with the QUEUE_DIR define shown in Recipe 9.1.2, another grep shows the change:

 $  grep QueueDirectory sendmail.cf  O QueueDirectory=/var/spool/mqueue/queue.* 

This recipe uses a special pathname format. The asterisk at the end of the pathname indicates that there are multiple queue directories. Only an asterisk can be used to indicate multiple queues, and it must appear at the end of the pathname. Given the QueueDirectory option shown above, sendmail looks for queues with names that begin with /var/spool/mqueue.queue . followed by any other string of characters .

This recipe mounts a separate physical device on each queue directory. While this is not absolutely necessary, it illustrates a common use of multiple directories. Placing multiple directories on a single device provides performance gains, but using multiple devices can provide even larger performance gains. sendmail Performance Tuning , by Nick Christenson (Addison Wesley), provides insight into these performance gains.

Multiple queues, as implemented in this recipe, speed the processing of large queues. If your server sometimes has more than 10,000 messages waiting in the queue, Recipe 9.1 may help improve your server performance and reliability.

Note that it is not necessary to use QUEUE_DIR to create multiple queues simply to organize mail into specific queues. qf , df , and xf subdirectories organize the queue by queue file types, as described in Recipe 9.2. Queue groups , which are discussed in Recipe Recipe 9.3, organize mail in separate queues. The separate queues used for queue groups can be subdirectories of a single default queue. Although qf , df , and xf subdirectories and queue groups can be used with multiple queues defined by a QUEUE_DIR command, they do not require that command.

See Also

Recipe 9.2 describes another technique for creating multiple queues that can be combined with this recipe. The sendmail book covers multiple queues in Section 11.3. The QueueDirectory option is explained in the Sendmail Installation and Operations Guide found in the doc/op directory of the sendmail distribution.



Sendmail Cookbook
sendmail Cookbook
ISBN: 0596004710
EAN: 2147483647
Year: 2005
Pages: 178
Authors: Craig Hunt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net