Good day, im request help because i have a problem with a mysql server, i have a dedicated server only with mysql and phpMyAdmin, with: 8gb RAM 2 SSD hard drive the problem is i have 6gb free, and always is using a lot of CPU but nothing of ram, my file my.cnf is the next: # Example MySQL config file for very large systems. # # This is for a large system with memory of 1G-2G where the system runs mainly # MySQL. # # You can copy this file to # /etc/my.cnf to set global options, # mysql-data-dir/my.cnf to set server-specific options (in this # installation this directory is /var/lib/mysql) or # ~/.my.cnf to set user-specific options. # # In this file, you can use all long options that a program supports. # If you want to know which options a program supports, run the program # with the "--help" option. # The following options will be passed to all MySQL clients [client] #password = your_password port = 3306 socket = /var/lib/mysql/mysql.sock # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3306 socket = /var/lib/mysql/mysql.sock skip-locking key_buffer_size = 384M max_allowed_packet = 1M table_open_cache = 512 sort_buffer_size = 2M read_buffer_size = 2M read_rnd_buffer_size = 8M myisam_sort_buffer_size = 64M thread_cache_size = 16 max_connections = 800 query_cache_size = 32M # Try number of CPU's*2 for thread_concurrency thread_concurrency = 2 connect_timeout=60 wait_timeout = 30 skip-innodb # Don't listen on a TCP/IP port at all. This can be a security enhancement, # if all processes that need to connect to mysqld run on the same host. # All interaction with mysqld must be made via Unix sockets or named pipes. # Note that using this option without enabling named pipes on Windows # (via the "enable-named-pipe" option) will render mysqld useless! # #skip-networking # Replication Master Server (default) # binary logging is required for replication #log-bin=mysql-bin # required unique id between 1 and 2^32 - 1 # defaults to 1 if master-host is not set # but will not function as a master if omitted server-id = 1 # Replication Slave (comment out master section to use this) # # To configure this host as a replication slave, you can choose between # two methods : # # 1) Use the CHANGE MASTER TO command (fully described in our manual) - # the syntax is: # # CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>, # MASTER_USER=<user>, MASTER_PASSWORD=<password> ; # # where you replace <host>, <user>, <password> by quoted strings and # <port> by the master's port number (3306 by default). # # Example: # # CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306, # MASTER_USER='joe', MASTER_PASSWORD='secret'; # # OR # # 2) Set the variables below. However, in case you choose this method, then # start replication for the first time (even unsuccessfully, for example # if you mistyped the password in master-password and the slave fails to # connect), the slave will create a master.info file, and any later # change in this file to the variables' values below will be ignored and # overridden by the content of the master.info file, unless you shutdown # the slave server, delete master.info and restart the slaver server. # For that reason, you may want to leave the lines below untouched # (commented) and instead use CHANGE MASTER TO (see above) # # required unique id between 2 and 2^32 - 1 # (and different from the master) # defaults to 2 if master-host is set # but will not function as a slave if omitted #server-id = 2 # # The replication master for this slave - required #master-host = <hostname> # # The username the slave will use for authentication when connecting # to the master - required #master-user = <username> # # The password the slave will authenticate with when connecting to # the master - required #master-password = <password> # # The port the master is listening on. # optional - defaults to 3306 #master-port = <port> # # binary logging - not required for slaves, but recommended #log-bin=mysql-bin # # binary logging format - mixed recommended #binlog_format=mixed # Point the following paths to different dedicated disks #tmpdir = /tmp/ #log-update = /path-to-dedicated-directory/hostname [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash # Remove the next comment character if you are not familiar with SQL #safe-updates [myisamchk] key_buffer_size = 256M sort_buffer_size = 256M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout Code (markup): i want know what values i have to change to my.cnf for the server use more ram and lees CPU, i know here are exellent sysadmin, so i hope somebody can help me. thanks in advance
Try this one: [mysqld] local-infile=0 tmpdir=/var/lib/mysql datadir=/var/lib/mysql skip-locking skip-networking safe-show-database query_cache_limit=32M query_cache_size=128M query_cache_type=1 max_connections=500 interactive_timeout=10 wait_timeout=100 connect_timeout=100 thread_cache_size=128 key_buffer=256M join_buffer=32M max_connect_errors=20 max_allowed_packet=32M table_cache=1024 record_buffer=32M sort_buffer_size=32M read_buffer_size=32M read_rnd_buffer_size=32M thread_concurrency=4 myisam_sort_buffer_size=128M server-id=1 collation-server=latin1_general_ci [mysql.server] user=mysql [safe_mysqld] err-log=/var/log/mysqld.log pid-file=/var/lib/mysql/mysql.pid open_files_limit=8192 [mysqldump] quick max_allowed_packet=16M [mysql] no-auto-rehash [isamchk] key_buffer=64M sort_buffer=64M read_buffer=64M write_buffer=64M [myisamchk] key_buffer=64M sort_buffer=64M read_buffer=64M write_buffer=64M [mysqlhotcopy] interactive-timeout Code (markup): Chris
@RHS-Chris: Thanks, i just change now and ill see the performance of the server and post here, thanks
sorry for the noob question: did you restarted mysql after the changes? Do it if not. Also a few lines with google: "First I'd say you probably want to turn off persistent connections" "I'd say you want to turn on the MySQL Slow Query Log to keep an eye on any queries that are taking a long time, and use that to make sure you don't have any queries locking up key tables for too long." Google it (Mysql high cpu usage - within a one year time range) and you will find a lot of (possible) answers.
Hi, i restart the server, yes, and im searching but still dont find anything, and here i left a suggestions from mysqltuner.pl:
Hello, It is really foolishness to configure mysql server without knowing what application is using it mostly. So let me know which scripts you running in your server like vb forum , openx , etc,. May be I can help you to give optimization . Also after every change you need to monitor it for 24 to 48 hours .