Have you tried MySQLTuner yet? It's free and it makes optimizing your MySQL server easier than ever!

Archive for September, 2007

When you find yourself in a pinch, and you don’t know the limits of a certain Red Hat Enterprise Linux version, you can find this information in one place. Whether you want to know RHEL’s CPU or memory limitations, you can find them here:

http://www.redhat.com/rhel/compare/

Comments No Comments »

So, this is not really related to the normal system administration topics discussed here, but it’s Sunday, so I feel like something different.

I downloaded the new Growl 1.1 tonight and I wanted to install GrowlMail to get mail notifications from Apple Mail. I went through the package installer, started Mail, and nothing happened. The preference pane didn’t exist either. After doing a bit of forum digging, I found these two commands to run in the terminal:

defaults write com.apple.mail EnableBundles 1
defaults write com.apple.mail BundleCompatibilityVersion 2

It worked like a charm and I was all set. If you haven’t tried it out yet, download the new Growl 1.1 and install it. There’s a ton of new features, and it’s been worth the wait.

Comments No Comments »

We all enjoy having the GoogleBot and other search engine robots index our sites as it brings us higher on search engines, but it’s annoying when some user scrapes your site for their own benefit. This is especially bad on forum sites as they’re always a target, and it can severely impact server performance.

To hunt down these connections when the spidering is happening, simply run this command:

netstat -plan | grep :80 | awk '{print $5}' | sed 's/:.*$//' | sort | uniq -c | sort -rn

The IP’s that are making the most connections will appear at the top of the list, and from there, you can find out which unwelcome spider is scraping your site.

Comments No Comments »

If you’ve run MySQL in a replication environment, or if you’ve enabled binary logging for transactional integrity, you know that the binary logs can grow rather quickly. The only safe way to delete the logs is to use PURGE MASTER LOGS in MySQL, but if you want MySQL to automatically remove the logs after a certain period of time, add this in your my.cnf:

expire_log_days = 14

5.11.3. The Binary Log

Comments No Comments »

I rolled out a new MySQLTuner update tonight and made the following changes:

  • Added aborted connection checks
  • Added % reads/writes counts
  • Adjusted recommendations for slow query logging, max seeks per key, and joins without indexes
  • Added licensing data
  • Added props for Matthew Montgomery

Coming up soon is InnoDB support and additional per-thread buffer checks.

Comments No Comments »

I hear a lot of complaints about Plesk’s backup routines and how they can bring a server to its knees. You can reduce the load (except for mysqldumps) by renicing pleskbackup. If you want something really handy, use this Perl scriptlet that I wrote:

#!/usr/bin/perl
@domains = `ls /var/www/vhosts/ | egrep -v '^default\$|^chroot\$'`;
$today = `date +%m%d%y`;
foreach $domain (@domains) {
chomp($domain);
$cmd = "nice -n 19 /usr/local/psa/bin/pleskbackup -vv domains $domain --skip-logs - | ssh someuser\@somehost -i /home/username/.ssh/id_rsa \"dd of=/home/username/pleskbackups/$domain-$today.dump\"";
`$cmd`;
}

It will transmit your backups to another server via SSH, and it will reduce the priority to the lowest available. This combination will reduce CPU usage and disk I/O throughout the backup.

Comments 1 Comment »

In the spirit of Labor Day, there will be no new items today. Plus, I worked today, and I’m tired. :-)

Comments No Comments »

If an .frm file that corresponds to an InnoDB table gets deleted without using DROP TABLE, MySQL won’t let you create a new table with the same name. You’ll find this in the error log:

InnoDB: Error: table test/parent already exists in InnoDB internal
InnoDB: data dictionary. Have you deleted the .frm file
InnoDB: and not used DROP TABLE? Have you used DROP DATABASE
InnoDB: for InnoDB tables in MySQL version <= 3.23.43?
InnoDB: See the Restrictions section of the InnoDB manual.
InnoDB: You can drop the orphaned table inside InnoDB by
InnoDB: creating an InnoDB table with the same name in another
InnoDB: database and moving the .frm file to the current database.
InnoDB: Then MySQL thinks the table exists, and DROP TABLE will
InnoDB: succeed.

Luckily, the error tells you exactly how to fix the problem! Simply make a new database and create a table that matches your old .frm file. Stop MySQL, move the .frm file from the new database’s directory back to the old database’s directory. Start MySQL, and then run DROP TABLE like normal.

This will remove the table from the ibdata tablespace file and allow you to create a new table with the same name.

Further reading:
13.2.17.1. Troubleshooting InnoDB Data Dictionary Operations

Comments No Comments »