Ubuntu Server Topping CPU on Amazon Micro instance.
I have got a micro instance on Amazon. For some reason ones in a while it’s CPU is topping up and the only thing I can do about it at that moment is Hard Reboot.
I have been trying to catch that sucker for the past half a year, set up Nagios to monitor when it is failing but no avail.
On the same server I have got a Magento Store (Nes Jewellery) and I noticed that ones Baide spider was on the server it was running slow. I fixed the spider problem but have left an open terminal with TOP working on it and forgot about it.
Yesterday I am getting a notification from Nagios that my instance is down. I have checked my terminal and the TOP was stuck on the last information he got and the top CPU killer was “update-apt-xapi”. This is a partial string from “update-apt-xapian-index” a part of the “apt-xapian-index” package.
What it turned out, Ubuntu (starting from version 10.04 and up to 11.04 at least) has an error in the cron script for apt update. But on a single CPU with limited memory that was critical!
The fix for this is really simple (and it’s stated that it’s included in 11.10). You need to edit 2 cron files (dont forget to have root permissions for that)
First is /etc/cron.weekly/apt-xapian-index
# Rebuild the index
if [ -x $CMD ]
then
if [ -x $IONICE ]
then
nice -n 19 $IONICE -c 3 $CMD --update --quiet
else
nice -n 19 $CMD --update --quiet
fi
fi
The second file is /etc/cron.daily/apt
if [ -x /usr/sbin/update-apt-xapian-index ]; then
nice -n 19 ionice -c3 update-apt-xapian-index --update -q
fi
Now all is left is to see that there is no more calls like that.
nice to know
Miron
October 24, 2011 at 7:16 pm