wrender

Well-Known Member
Sep 29, 2007
69
3
58
Hello,

I just upgraded my server to 48GB of ram in hopes of improving MySQL performance. The server has 15K RPM SAS drives, with a Raid 5 configuration. A XEON quad core 2.96GHz processor. Would anyone be able to make recommendations on how I could optimize MySQL to take advantage of the upgraded memory? I have been using the mysqltuner.pl and tuning-primer.sh scripts, but they basically just keep telling me to increase my tmp_table_size, max_heap_table_size and table_cache. I am concerned that I may be increasing these too much and there seems to be little documentation on tuning a server with this much memory.

Here is my current configuration:

Code:
[mysqld_safe]
log-error="/var/log/mysqld.log"
pid-file="/var/run/mysqld/mysqld.pid"
default-storage-engine=MyISAM
innodb_file_per_table=1
[mysqld]
tmp_table_size=1024M
max_heap_table_size=1024M
query_cache_size=192M
query_cache_limit=2M
query_cache_type=1
innodb_file_per_table=1
max_allowed_packet=64M
open-files-limit=80K
innodb_buffer_pool_size=7000M
innodb_log_buffer_size=4M
innodb_flush_log_at_trx_commit = 2
thread_cache_size=8
thread_concurrency=8
innodb_thread_concurrency = 16
table_cache=12K
table_definition_cache=18K
key_buffer_size=64M
join_buffer_size=4M
low_priority_updates=1
concurrent_insert=ALWAYS
slow_query_log
long_query_time=2
Here is a current output from the tuning programs. Although the server has not been running for 48 hours, it was outputting the same information before when it had run for 48 hours.

Code:
./mysqltuner.pl

 >>  MySQLTuner 1.2.0 - Major Hayden <[email protected]>
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
 >>  Run with '--help' for additional options and output filtering

-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.5.27-cll
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 1G (Tables: 4520)
[--] Data in InnoDB tables: 1G (Tables: 4653)
[--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
[!!] Total fragmented tables: 381

-------- Security Recommendations  -------------------------------------------
[OK] All database users have passwords assigned

-------- Performance Metrics -------------------------------------------------
[--] Up for: 13m 6s (170K q [216.503 qps], 1K conn, TX: 982M, RX: 35M)
[--] Reads / Writes: 62% / 38%
[--] Total buffers: 8.1G global + 6.6M per thread (151 max threads)
[OK] Maximum possible memory usage: 9.1G (19% of installed RAM)
[OK] Slow queries: 0% (1/170K)
[OK] Highest usage of available connections: 7% (11/151)
[OK] Key buffer size / total MyISAM indexes: 64.0M/313.7M
[OK] Key buffer hit rate: 99.5% (1M cached / 9K reads)
[OK] Query cache efficiency: 82.7% (118K cached / 143K selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 2K sorts)
[!!] Joins performed without indexes: 9
[!!] Temporary tables created on disk: 35% (1K on disk / 3K total)
[OK] Thread cache hit rate: 99% (11 created / 1K connections)
[!!] Table cache hit rate: 0% (3 open / 18K opened)
[OK] Open file limit used: 0% (7/81K)
[OK] Table locks acquired immediately: 100% (46K immediate / 46K locks)
[OK] InnoDB data size / buffer pool: 1.1G/6.8G

-------- Recommendations -----------------------------------------------------
General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    MySQL started within last 24 hours - recommendations may be inaccurate
    Adjust your join queries to always utilize indexes
    Temporary table size is already large - reduce result set size
    Reduce your SELECT DISTINCT queries without LIMIT clauses
    Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
    join_buffer_size (> 4.0M, or always use indexes with joins)
    table_cache (> 12288)
And tuning-primer.sh results:

Code:
-- MYSQL PERFORMANCE TUNING PRIMER --
             - By: Matthew Montgomery -

MySQL Version 5.5.27-cll x86_64

Uptime = 0 days 0 hrs 14 min 38 sec
Avg. qps = 205
Total Questions = 180106
Threads Connected = 4

Warning: Server has not been running for at least 48hrs.
It may not be safe to use these recommendations

To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html
Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL's Enterprise Monitoring and Advisory Service

SLOW QUERIES
The slow query log is enabled.
Current long_query_time = 2.000000 sec.
You have 1 out of 180127 that take longer than 2.000000 sec. to complete
Your long_query_time seems to be fine

BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See http://dev.mysql.com/doc/refman/5.5/en/point-in-time-recovery.html

WORKER THREADS
Current thread_cache_size = 8
Current threads_cached = 5
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 151
Current threads_connected = 5
Historic max_used_connections = 11
The number of used connections is 7% of the configured maximum.
You are using less than 10% of your configured max_connections.
Lowering max_connections could help to avoid an over-allocation of memory
See "MEMORY USAGE" section to make sure you are not over-allocating

INNODB STATUS
Current InnoDB index space = 724 M
Current InnoDB data space = 1.07 G
Current InnoDB buffer pool free = 85 %
Current innodb_buffer_pool_size = 6.83 G
Depending on how much space your innodb indexes take up it may be safe
to increase this value to up to 2 / 3 of total system memory

MEMORY USAGE
Max Memory Ever Allocated : 7.16 G
Configured Max Per-thread Buffers : 1000 M
Configured Max Global Buffers : 7.09 G
Configured Max Memory Limit : 8.07 G
Physical Memory : 47.04 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 313 M
Current key_buffer_size = 64 M
Key cache miss rate is 1 : 179
Key buffer free ratio = 79 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is enabled
Current query_cache_size = 192 M
Current query_cache_used = 13 M
Current query_cache_limit = 2 M
Current Query cache Memory fill ratio = 6.92 %
Current query_cache_min_res_unit = 4 K
Your query_cache_size seems to be too high.
Perhaps you can use these resources elsewhere
MySQL won't cache query results that are larger than query_cache_limit in size

SORT OPERATIONS
Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 256 K
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 4.00 M
You have had 9 queries where a join could not use an index properly
join_buffer_size >= 4 M
This is not advised
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.

OPEN FILES LIMIT
Current open_files_limit = 81920 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine

TABLE CACHE
Current table_open_cache = 12288 tables
Current table_definition_cache = 18432 tables
You have a total of 9214 tables
You have 9218 open tables.
The table_cache value seems to be fine

TEMP TABLES
Current max_heap_table_size = 1.00 G
Current tmp_table_size = 1.00 G
Of 2897 temp tables, 32% were created on disk
Perhaps you should increase your tmp_table_size and/or max_heap_table_size
to reduce the number of disk-based temporary tables
Note! BLOB and TEXT columns are not allow in memory tables.
If you are using these columns raising these values might not impact your
ratio of on disk temp tables.

TABLE SCANS
Current read_buffer_size = 128 K
Current table scan ratio = 19 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 0 : 180531
Your table locking seems to be fine
 

JaredR.

Well-Known Member
Feb 25, 2010
1,834
25
143
Houston, TX
cPanel Access Level
Root Administrator
As tank said, you need to run mysqltuner.pl, make the changes it suggests, restart MySQL, wait a full day, and run it again. MySQL optimization is a complex task and can be something of a moving target, so you will need to run mysqltuner.pl and adjust the MySQL configuration several times over the course of days or weeks until gradually MySQL is tweaked into a better configuration.

Unfortunately, there is no simple one-step solution to instantly optimize MySQL for all your sites. Tuning it requires making observations, making changes based on those observations, and then making more observations. Like many facets of server administration, it can be a slow, tedious process, and bad database design or poor programming of scripts that access a database can significantly complicate the task.
 

wrender

Well-Known Member
Sep 29, 2007
69
3
58
Thanks, but I already know these things. I was hoping that someone could make a suggestion based on the amount of tables, and physical resources I have. Even after waiting 48 hours, the tuning programs still always recommend turning up the tmp_table_size, max_heap_table_size and table_cache.