Why mysql get so high cpu usage? Is there any way I can monitor mysql, like mytop? top - 10:39:48 up 10 days, 35 min, 1 user, load average: 8.22, 9.38, 8.50 Tasks: 132 total, 5 running, 127 sleeping, 0 stopped, 0 zombie Cpu(s): 73.5%us, 22.3%sy, 0.0%ni, 2.1%id, 0.0%wa, 0.1%hi, 2.0%si, 0.0%st Mem: 2075000k total, 1919256k used, 155744k free, 113660k buffers Swap: 2031608k total, 56k used, 2031552k free, 1177200k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 21899 mysql 20 0 200m 53m 4752 S 182 2.6 8100:18 mysqld 2548 lighttpd 20 0 20288 16m 680 S 19 0.8 878:33.76 lighttpd 9759 lighttpd 20 0 23168 7880 3048 S 10 0.4 8:50.96 php-cgi 30959 lighttpd 20 0 23164 7896 3096 S 10 0.4 11:40.95 php-cgi 9732 lighttpd 20 0 23204 7544 2664 S 8 0.4 8:59.42 php-cgi 10671 lighttpd 20 0 23248 7612 2664 S 8 0.4 4:51.95 php-cgi 9769 lighttpd 20 0 23312 8012 3048 S 7 0.4 8:55.61 php-cgi 9771 lighttpd 20 0 23104 7312 2584 S 7 0.4 8:50.33 php-cgi 10601 lighttpd 20 0 23336 8032 2996 S 7 0.4 4:56.21 php-cgi 31091 lighttpd 20 0 23064 7860 3100 S 7 0.4 11:30.69 php-cgi 9782 lighttpd 20 0 23116 7880 3060 S 7 0.4 8:57.46 php-cgi 8559 lighttpd 20 0 23396 7780 2668 R 6 0.4 6:43.16 php-cgi
Sounds like you got some nasty queries going on there. mytop would be one way to see the queries that are going through mysql at that very moment. What you'd want to do it look further into this is put the following in my.cnf log-slow-queries Now it'll put all slow queries into a file hostname-slow.log in /var/lib/mysql or wherever your mysql files are being stored. So if you have slow queries showing up there then you should look to optimizing those queries by either changing them or adding missing indexes and things of that nature.
You need mysql optimization. Seems you're peaking Memory usage as well. Upgrading RAM might solve the problem to a extent but not completely.