sendmail 튜닝
===============================================================================================
1. 기본 설정값 조정
===============================================================================================
- Load Average가 100 이 넘으면 Queue 에 메일을 넣는다.
O QueueLA=100
- Load Average가 128 이 넘으면 메일 수신 접속을 거부 한다.
O RefuseLA=128
- 자식 프로세스 생성 최대 값, 이 수치 이상으로 프로세스가 생성 되면 접속을 거부한다.
O MaxDaemonChildren=64
===============================================================================================
2. sendmail 수신 / 발신 전용 프로세스 분리
===============================================================================================
- /etc/mail 에 sendmail_recv.cf, sendmail_queue.cf 설정
- sendmail_recv.cf ( Defer Mode )
#d defer delvery attempts (don't deliver)
O DeliveryMode=d
# location of pid file
O PidFile=/var/run/sendmail_recv.pid
-----------------------------------------------------------------------------------------------
Delivery Mode
-----------------------------------------------------------------------------------------------
There are a number of delivery modes that sendmail can operate in, set by the DeliveryMode ( d) configuration option. These modes specify how quickly mail will be delivered. Legal modes are:
i deliver interactively (synchronously)
b deliver in background (asynchronously)
q queue only (don't deliver)
d defer delvery attempts (don't deliver)
There are tradeoffs. Mode i gives the sender the quickest feedback, but may slow down some mailers and is hardly ever necessary. Mode b delivers promptly but can cause large numbers of processes if you have a mailer that takes a long time to deliver a message. Mode q minimizes the load on your machine, but means that delivery may be delayed for up to the queue interval. Mode d is identical to mode q except that it also prevents all the early map lookups from working; it is intended for ``dial on demand'' sites where DNS lookups might cost real money. Some simple error messages (e.g., host unknown during the SMTP protocol) will be delayed using this mode. Mode b is the usual default.
If you run in mode q (queue only), d (defer), or b (deliver in background) sendmail will not expand aliases and follow .forward files upon initial receipt of the mail. This speeds up the response to RCPT commands. Mode i cannot be used by the SMTP server.
-----------------------------------------------------------------------------------------------
- sendmail_queue.cf ( Background Mode )
# location of pid file
O PidFile=/var/run/sendmail_queue.pid
# default delivery mode
O DeliveryMode=b
- /etc/init.d/sendmail
start() {
# Start daemons.
###########################################################################
# receiving daemon ( defer mode )
###########################################################################
echo -n $"Starting $prog: sendmail_recv "
if test -x /usr/bin/make -a -f /etc/mail/Makefile ; then
make all -C /etc/mail -s > /dev/null
else
for i in virtusertable access domaintable mailertable ; do
if [ -f /etc/mail/$i ] ; then
makemap hash /etc/mail/$i < /etc/mail/$i
fi
done
fi
/usr/bin/newaliases > /dev/null 2>&1
daemon --check sendmail_recv /usr/sbin/sendmail -L sendmail_recv -bd -C/etc/mail/sendmail_recv.cf
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/sendmail
###########################################################################
# process queue daemon
###########################################################################
if ! test -f /var/run/sendmail_queue.pid ; then
echo -n $"Starting $prog: sendmail_queue "
touch /var/run/sendmail_queue.pid
chown smmsp:smmsp /var/run/sendmail_queue.pid
if [ -x /usr/bin/selinuxenabled ] && /usr/bin/selinuxenabled; then
/sbin/restorecon /var/run/sendmail_queue.pid
fi
daemon --check sendmail_queue /usr/sbin/sendmail -L sendmail_queue -C/etc/mail/sendmail_queue.cf -q1m
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/sendmail_queue
fi
return $RETVAL
}
stop() {
# Stop daemons.
echo -n $"Shutting down $prog: "
killproc sendmail
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sendmail
[ $RETVAL -eq 0 ] && rm -f /var/run/sendmail_queue.pid
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sendmail_queue
return $RETVAL
}
===============================================================================================