Knowledgebase

99% cpu used by MySQL

Posted by Allbert, 04-02-2012, 09:24 AM
hello i have dedicate server for my site and i have one site on it i used cpanel but i transfer it to directadmin now my site use 90-90 % of cpu and im worried about it ! my server info : OVH 24GB Cpu: Corei7 950 (4x 2(HT)x 2.66+ GHz) Ram: 24 GB HDD: 2TB Bw : Unlimited traffic on 100Mbps Port Port : 100 Mbps Self Managed Location: France - OVH ------------------------ is there any change should i make to minimize cpu usage ? whats your solution ?

Posted by twikamltd, 04-02-2012, 10:21 AM
Check your mysql logs? Run mysqltuner script and follow it's suggestions.

Posted by Server Management, 04-02-2012, 10:26 AM
What are you running exactly because you only have a single disk so you might be I/O bound...

Posted by Allbert, 04-02-2012, 12:31 PM
did os version effect this ? i use 32bit os some where i read if we used 32bit sql cant use all ram of server

Posted by twikamltd, 04-02-2012, 12:37 PM
PAE kernel would help, but seriously, upgrade to a 64 bit OS!

Posted by Allbert, 04-03-2012, 01:59 AM
i upgread to 64 bit os version ! but problem steel ! i use mysqltune to fix it but it dose'nt help me ! ---- and here is mysql conf file ! do you have any idea ? this is picture link http://up98.org/upload/server1/02/g/...2d2cao91jq.jpg Last edited by Allbert; 04-03-2012 at 02:04 AM.

Posted by CrocWeb, 04-03-2012, 02:05 AM
Could you post the output of "top" and "sar" please?

Posted by Allbert, 04-03-2012, 02:17 AM
top :::: 8911 mysql 39 19 1963m 60m 4328 S ***123.9***cpu usage 0.2 36:36.41 mysqld 9699 apache 39 19 100m 10m 3452 S 0.7 0.0 0:00.53 httpd 9820 apache 39 19 100m 10m 3456 S 0.7 0.0 0:00.14 httpd 9824 apache 39 19 100m 10m 3396 S 0.7 0.0 0:00.04 httpd 4078 root 39 19 15056 1408 988 S 0.3 0.0 0:02.27 top 9723 apache 39 19 100m 10m 3552 S 0.3 0.0 0:00.48 httpd 9748 apache 39 19 100m 10m 3452 S 0.3 0.0 0:00.28 httpd 9749 apache 39 19 100m 10m 3448 S 0.3 0.0 0:00.40 httpd 9802 apache 39 19 100m 10m 3432 S 0.3 0.0 0:00.18 httpd 9807 apache 39 19 100m 10m 3444 S 0.3 0.0 0:00.22 httpd 9825 apache 39 19 100m 10m 3408 S 0.3 0.0 0:00.04 httpd 1 root 20 0 19248 1492 1220 S 0.0 0.0 0:01.66 init 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 3 root 20 0 0 0 0 S 0.0 0.0 0:00.07 ksoftirqd/0 4 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0 6 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0 7 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/1 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/1:0 9 root 20 0 0 0 0 S 0.0 0.0 0:00.10 ksoftirqd/1 10 root 20 0 0 0 0 S 0.0 0.0 0:04.18 kworker/0:1 11 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/2 Last edited by Allbert; 04-03-2012 at 02:28 AM.

Posted by ArturasLIX, 04-03-2012, 06:09 AM
Why don't you look at specific queries that eats your cpu, instead of trying to optimize perhaps needless things. Run: And check what queries are running at high load time. Perhaps there is no indexes on them, so problem could be trivial with the fix of putting indexes on.

Posted by Allbert, 04-03-2012, 09:38 AM
i run this but it dosent work [root@mehrstat ~]# mysqladmin -i2 processlist mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)' [root@mehrstat ~]#

Posted by ArturasLIX, 04-03-2012, 09:46 AM
Well, login to mysql as root then, it should be something like: Or just login to mysql: then run:

Posted by Allbert, 04-03-2012, 09:54 AM
it dosent show cpu usage it just show id or time ----------------------------------------------------------------------------------------- --------+ +-------+------+-----------+----+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +-------+------+-----------+----+---------+------+-------+------------------+ | 71307 | root | localhost | | Query | 0 | | show processlist | +-------+------+-----------+----+---------+------+-------+------------------+ +-------+--------------+-----------+---------------+--------

Posted by ArturasLIX, 04-03-2012, 10:10 AM
It shouldn't show CPU usage, it should show queries that are running right now. You should run that command then your server is under high load, so you will detect queries that causes that load. Then you'll need to optimize that queries.

Posted by net, 04-03-2012, 10:26 AM
Moved > Hosting Security and Technology.

Posted by WebHostDog, 04-03-2012, 10:59 AM
Have you figured out which MySQL query is eating the CPU ?

Posted by 365SMGROUP, 04-03-2012, 11:23 AM
Hi, You can optimize the databases using the below command. mysqlcheck --defaults-extra-file=/usr/local/directadmin/conf/my.cnf --auto-repair --optimize --all-databases



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
westhost wdclnx32 (Views: 581)
Continuum again! (Views: 669)


Language:

Client Login

Email

Password

Remember Me

Search