Tuning up a MySQL server

Posted by NinjaCat on Server Fault See other posts from Server Fault or by NinjaCat
Published on 2011-02-06T16:35:59Z Indexed on 2011/02/09 15:27 UTC
Read the original article Hit count: 218

Filed under:

I inherited a mysql server, and so I've started with running the MySQLTuner.pl script. I am not a MySQL expert but I can see that there is definitely a mess here. I'm not looking to go after every single thing that needs fixing and tuning, but I do want to grab the major, low hanging fruit.

Total Memory on the system is: 512MB. Yes, I know it's low, but it's what we have for the time being.

Here's what the script had to say:

General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    MySQL started within last 24 hours - recommendations may be inaccurate
    Enable the slow query log to troubleshoot bad queries
    When making adjustments, make tmp_table_size/max_heap_table_size equal
    Reduce your SELECT DISTINCT queries without LIMIT clauses
    Increase table_cache gradually to avoid file descriptor limits
    Your applications are not closing MySQL connections properly
Variables to adjust:
    query_cache_limit (> 1M, or use smaller result sets)
    tmp_table_size (> 16M)
    max_heap_table_size (> 16M)
    table_cache (> 64)
    innodb_buffer_pool_size (>= 326M)

For the variables that it recommends that I adjust, I don't even see most of them in the mysql.cnf file.

[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock

[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock
nice            = 0

[mysqld]
innodb_buffer_pool_size         = 220M
innodb_flush_log_at_trx_commit  = 2
innodb_file_per_table           = 1
innodb_thread_concurrency       = 32
skip-locking
big-tables
max_connections             = 50
innodb_lock_wait_timeout    = 600
slave_transaction_retries   = 10
innodb_table_locks      = 0
innodb_additional_mem_pool_size = 20M
user                = mysql
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir             = /usr
datadir         = /var/lib/mysql
tmpdir              = /tmp
skip-external-locking
bind-address        = localhost
key_buffer              = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 4
myisam-recover          = BACKUP
query_cache_limit       = 1M
query_cache_size        = 16M
log_error               = /var/log/mysql/error.log
expire_logs_days    = 10
max_binlog_size         = 100M
skip-locking
innodb_file_per_table   = 1
big-tables

[mysqldump]
quick
quote-names
max_allowed_packet      = 16M

[mysql]

[isamchk]
key_buffer              = 16M

!includedir /etc/mysql/conf.d/

© Server Fault or respective owner

Related posts about mysql