Skip to main content

Mysqld - high CPU usage

Comments

4 comments

  • httpdocs
    Use This Command For More Information: mysqladmin pr|awk -F "|" '{ print $3 }'|grep _|sort|uniq -c|sort -n
    0
  • RhymeGuy
    Output: 2 db_shop
    0
  • cPRex Jurassic Moderator
    Hello there, @RhymeGuy, One of my favorite ways to see MySQL usage on a machine is to run this command: mysqladmin proc status
    as this will show you the user running the command, how long it has been running, the database, and the query. It will also give you a summary of what MySQL doing, including how many queries per second are being run and how many open tables there are, which can help you identify if MySQL is reaching any limits. Seeing one process using high resources doesn't necessarily mean there is an issue. If that only happens every so often it could just mean there is a CPU intensive query that is being run that uses a large amount of CPU. If you see the high usage again, running the mysqladmin proc status
    command may show you exactly what is happening. It's best to let the system run a bit longer as the mysqltuner tool will tell you, as your output did, that the MySQL service wasn't online for at least 24 hours, so the data and recommendations may not be complete enough for the tuner script to get a full picture of your server's situation. If you need more details on any of this, just let us know!
    0
  • anton_latvia
    I would login to MySQL shell (run "mysql" from console) and run: [CODE=sql]show full processlist;
    this will show you current running queries. You will need to run it several times and see, if some queries appear often or stay for a while. With that information you should analyze both queries or databases. There is no single reason for the high load. For example your MySQL config is pretty empty and can be improved by enabling query cache and adding more memory. High load can come from the overloaded filesystem or lack of CPU or bad table indexing or any kind of abuse. Bad indexes, bad queries, bad MySQL config is first thing to check. I would add these lines to your /etc/my.cnf to begin with. remember to restart MySQL server afterwards. query_cache_type=1 query_cache_limit=512K query_cache_size=64M query_cache_min_res_unit=256 key_buffer=64M key_buffer_size=64M innodb_buffer_pool_size=512M innodb_thread_concurrency=0 innodb_log_file_size=128M
    0

Please sign in to leave a comment.