I'd really recommend doing some research online. It's difficult to know exactly what you need to configure it to. We can make recommendations but ultimately it's up to you to decide what fits best for your usage.
Tuning primer will allow best configuration for your server based on the previous mysql usage, it won't practically forcefully limit the usage within 2GB/3GB if you want to. You need to calculate the usage if you want to limit the memory usage by the mysql.
-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -
MySQL Version 5.0.81-community i686
Uptime = 5 days 11 hrs 9 min 29 sec
Avg. qps = 25
Total Questions = 11812181
Threads Connected = 1
Server has been running for over 48hrs.
It should be safe to follow these recommendations
To find out more information on how each of these
runtime variables effects performance visit:
for info about MySQL's Enterprise Monitoring and Advisory Service
The slow query log is NOT enabled.
Current long_query_time = 10 sec.
You have 3 out of 11812202 that take longer than 10 sec. to complete
Your long_query_time may be too high, I typically set this under 5 sec.
BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
Current thread_cache_size = 0
Current threads_cached = 0
Current threads_per_sec = 1
Historic threads_per_sec = 0
Your thread_cache_size is fine
Current max_connections = 500
Current threads_connected = 1
Historic max_used_connections = 15
The number of used connections is 3% 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
Max Memory Ever Allocated : 58 M
Configured Max Per-thread Buffers : 1.31 G
Configured Max Global Buffers : 17 M
Configured Max Memory Limit : 1.32 G
Physical Memory : 1.97 G
Max memory limit seem to be within acceptable norms
Current MyISAM index space = 89 M
Current key_buffer_size = 7 M
Key cache miss rate is 1 : 362
Key buffer free ratio = 57 %
Your key_buffer_size seems to be fine
Query cache is supported but not enabled
Perhaps you should set the query_cache_size
Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 256 K
Sort buffer seems to be fine
Current join_buffer_size = 132.00 K
You have had 410333 queries where a join could not use an index properly
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.
If you are unable to optimize your queries you may want to increase your
join_buffer_size to accommodate larger joins in one pass.
Note! This script will still suggest raising the join_buffer_size when
ANY joins not using indexes are found.
OPEN FILES LIMIT
Current open_files_limit = 4096 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
Current table_cache value = 64 tables
You have a total of 403 tables
You have 64 open tables.
Current table_cache hit rate is 0%, while 100% of your table cache is in use
You should probably increase your table_cache
Current max_heap_table_size = 16 M
Current tmp_table_size = 32 M
Of 488700 temp tables, 8% were created on disk
Effective in-memory tmp_table_size is limited to max_heap_table_size.
Created disk tmp tables ratio seems fine
Current read_buffer_size = 128 K
Current table scan ratio = 269 : 1
read_buffer_size seems to be fine
Current Lock Wait ratio = 1 : 9498
Your table locking seems to be fine
Both of these scripts are quite useful for MySQL tuning. Here is some sample output of mysqltuner.pl
>> MySQLTuner 1.0.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.0.81-community
[OK] Operating on 32-bit architecture with less than 2GB RAM
-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 350M (Tables: 373)
[--] Data in InnoDB tables: 144K (Tables: 9)
[--] Data in MEMORY tables: 252K (Tables: 4)
[!!] Total fragmented tables: 30
-------- Performance Metrics -------------------------------------------------
[--] Up for: 5d 11h 29m 12s (11M q [24.998 qps], 271K conn, TX: 922M, RX: 2B)
[--] Reads / Writes: 88% / 12%
[--] Total buffers: 34.0M global + 2.7M per thread (500 max threads)
[OK] Maximum possible memory usage: 1.3G (67% of installed RAM)
[OK] Slow queries: 0% (3/11M)
[OK] Highest usage of available connections: 3% (15/500)
[OK] Key buffer size / total MyISAM indexes: 8.0M/89.8M
[OK] Key buffer hit rate: 99.7% (1B cached / 3M reads)
[!!] Query cache is disabled
[OK] Sorts requiring temporary tables: 0% (2K temp sorts / 1M sorts)
[!!] Joins performed without indexes: 411675
[OK] Temporary tables created on disk: 8% (44K on disk / 534K total)
[!!] Thread cache is disabled
[!!] Table cache hit rate: 0% (64 open / 313K opened)
[OK] Open file limit used: 2% (116/4K)
[OK] Table locks acquired immediately: 99% (13M immediate / 13M locks)
[OK] InnoDB data size / buffer pool: 144.0K/8.0M
-------- Recommendations -----------------------------------------------------
Run OPTIMIZE TABLE to defragment tables for better performance
Enable the slow query log to troubleshoot bad queries
Adjust your join queries to always utilize indexes
Set thread_cache_size to 4 as a starting value
Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
query_cache_size (>= 8M)
join_buffer_size (> 128.0K, or always use indexes with joins)
thread_cache_size (start at 4)
table_cache (> 64)