
05-18-2007, 03:37 PM
|
|
Newbie
|
|
Join Date: Jul 2006
Posts: 20
|
|
After running for a while mysql suddenly starts using 100% CPU and my site goes down due to apache waiting with 150 sleeping processes.
Here is the top stats
PHP Code:
top - 00:20:47 up 12:01, 2 users, load average: 1.11, 1.04, 0.95
Tasks: 200 total, 2 running, 198 sleeping, 0 stopped, 0 zombie
Cpu(s):100.0%us, 0.0%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 1004152k total, 618132k used, 386020k free, 118436k buffers
Swap: 2000084k total, 0k used, 2000084k free, 282372k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2011 mysql 18 0 177m 43m 5684 S 99.9 4.5 86:51.60 mysqld
14877 root 15 0 2360 1216 860 R 0.3 0.1 0:00.11 top
1 root 15 0 1948 648 556 S 0.0 0.1 0:00.97 init
ps ax | grep apache -c
152
On restarting mysql everything goes back to normal.
Can someone tell me how I could go about rectifying this?
I'm sure the server can take the load, coz before this the site was on a way slower machine and worked flawlessly.
|

05-18-2007, 03:38 PM
|
|
Newbie
|
|
Join Date: Jul 2006
Posts: 20
|
|
Oh btw the configuration directives and files are the default ones. I've installed everything using apt
|

05-18-2007, 03:51 PM
|
|
WHT Addict
|
|
Join Date: May 2007
Location: Ukraine
Posts: 161
|
|
at least you have to see what makes mysql to use all cpu resources,
use this command to see what mysql is doing:
# mysqladmin processlist
|

05-18-2007, 07:47 PM
|
|
WHT Addict
|
|
Join Date: Sep 2005
Posts: 138
|
|
remove mysql-server and install it again . Wierd as it is , had a same problem with my cient's server , no configuration would make it work normally , so i removed mysql and installed it again from source and it worked perfectly .
|

05-18-2007, 07:50 PM
|
|
Newbie
|
|
Join Date: Jul 2006
Posts: 20
|
|
So this time around, should I compile it myself from source?
|

05-18-2007, 07:53 PM
|
|
Web Hosting Evangelist
|
|
Join Date: Dec 2006
Posts: 477
|
|
What version of mysql are you using? I had this issue with 5.0.22 and 5.0.26 on an old server where CPU would jump to 100% approximately every 2-3 weeks despite no queries running against the database - show process list was empty and my admin session was the only connection. A restart was the only thing that would resolve it. I've not seen it happen since version 5.0.33 though.
|

05-18-2007, 10:00 PM
|
|
Newbie
|
|
Join Date: Jul 2006
Posts: 20
|
|
mysql -V
mysql Ver 14.12 Distrib 5.0.38, for pc-linux-gnu (i486) using readline 5.2
|

05-18-2007, 10:57 PM
|
|
Engineer
|
|
Join Date: Jan 2005
Location: Scotland, UK
Posts: 2,380
|
|
As you are using the default UNOPTIMIZED mySQL that is more than likely your problem.
cat /etc/my.cnf
free -m
cat /proc/cpuinfo
mysqladmin processlist
__________________
Server Management - AdminGeekZ.com
Infrastructure Management, Web Application Performance, mySQL DBA. Keep your servers online.
United Kingdom: *0800 8620073* // United States: *585 563 1729* // Australia: *02 9037 2448* // International: *+44.1412800134*
Scott Mcintyre
|

05-19-2007, 07:56 AM
|
|
Web Hosting Master
|
|
Join Date: Oct 2006
Posts: 898
|
|
mysqladmin processlist->check the open tables for account using the most.
sometimes ppl are running inefficient crons for posting stuff.
__________________
█ Imageleet.com - Premium Hosting Solutions Since 2006
█ Shared Hosting, FFmpeg Hosting, Linux VPS and Dedicated Solutions.
█ SSD, Litespeed powered, R1soft, cPanel | Softaculous | Rvsitebuilder + FFmpeg, Mencoder, Mplayer, Flvtool2, x264
█ http://www.imageleet.com
|

05-20-2007, 01:32 AM
|
|
cholesterol dependent
|
|
Join Date: Oct 2000
Location: Israel
Posts: 1,283
|
|
Check for cronjobs that are accessing mySQL. When you find a script that's runniung around the same time as your 100%CPU, get to work optimizing the queries.
From experience...
- use the LIMIT clause to limit the size of queries
- use the JOIN clause to greatly optimize queries across tables
- make sure that indexes are defined
|

05-20-2007, 02:30 AM
|
|
Junior Guru
|
|
Join Date: May 2004
Location: Pakistan
Posts: 228
|
|
can you post /etc/my.cnf ??
__________________
Cloud Hosting
~ Shared Cpanel Hosting, Cpanel Reseller, Business Cloud Hosting, SSD Cpanel Reseller Hosting ~
|

05-20-2007, 07:51 AM
|
|
WHT Addict
|
|
Join Date: Apr 2007
Posts: 132
|
|
You need to optimize your mysql & apache well.
__________________
Attacker.NET IT Security Consulting Group
Server Management | Security Hardening | Ethical Hacking/Pen-Testing.
Certified Information Security Professionals
E-mail: sales@attacker.net | http://attacker.net
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
| Postbit Selector |
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
| Login: |
|
|
| Advertisement: |
|
|
| Web Hosting News: |
|
|
|