MySQL binary log rotation

Posted on January 18, 2007 on 1:56 pm by glen | In General, MySQL, RedHat | No Comments

We are running a MySQL replication setup, and find that the binary logs get very large, very quickly. Since MySQL didn’t come with a log rotation script, we rolled our own. Usage is simple:

At the top of the script are some definitions that you need to change for your setup:

  1. MYSQL_USER MYSQL_PASS - You will need to create a user in MySQL that has the RELOAD and SUPER privileges
  2. MYSQL_HOST - Where your MySQL server is located
  3. MYSQL_LOG_PATH MYSQL_LOG_NAME - where your binary logs are kept, and what they are called
  4. MYSQL_SLOW_LOG_NAME - the name of your slow log file
  5. MAX_LOG_DAYS - the number of days worth of old logs that you want to keep
  6. Once you’ve configured these values, whack the script into cron and run it daily.

    Download the script (1.6Kb)

Preventing Apache DOS attacks

Posted on January 2, 2007 on 1:32 pm by glen | In General, Apache, RedHat | No Comments

We’ve recently come under attack from denial-of-service (DOS) attacks. In order to alleviate this situation, we are currently testing out the mod_evasive Apache module.

mod_evasive v1.10.1

The install was simple. After downloading and unpacking the source code…

/usr/sbin/apxs -i -a -c mod_evasive20.c

This will compile the module, copy it to the correct directory and enable the module in your Apache config. In addition, we added the following options to our httpd.conf:


<IfModule mod_evasive20.c>
DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 10
DOSEmailNotify glen@designsolution.co.uk
</IfModule>

Now, if too many requests come in from an IP address, the server will respond with a HTTP 403 response. This helps to save on bandwidth and reduce CPU load. Ideally, we would like to hook this into our firewall… our investigations are on-going!

Optimizing MailScanner

Posted on December 18, 2006 on 2:05 pm by glen | In General, RedHat, Email, MailScanner | No Comments

Our MailScanner installation is pretty heavily utilised, scanning 20,000+ messages a day. I’m always looking for ways of improving it’s performance, so the following document has proved useful:

Optimization tips

  1. Use a ramdisk (tmpfs) for MailScanner’s working directory.
  2. Make sure you have enough ram
  3. Set the noatime flag on your spool and log partitions
  4. Use a local DNS caching nameserver
  5. No syncs on logs
  6. Use DCC as a daemon
  7. Tweak your # of max child processes
  8. Running your own copy of RBLs, and servers for DCC, Pyzor and Razor
  9. Consider dropping unknown recipient emails on the inbound MailScanner MTA

Feeds: Entries | Comments