优化AWS EC2 t2.small的MySQL设置

时间:2015-02-26 17:24:07

标签: mysql amazon-web-services amazon-ec2

我的ApacheMySQL网络服务器在AWS EC2 t2.small上运行Windows 2012 ServerAWS EC2 t2.small特征:

  • RAM 2 GB(使用率65%)
  • 1 CPU 2.50 GHz(使用1%)

现在MySQL进程(mysqld.exe)使用400 MB的RAM(对我来说太多了)。

MySQL当前设置为(my.ini):

key_buffer                      = 16M
max_allowed_packet              = 16M
sort_buffer_size                = 512K
net_buffer_length               = 8K
read_buffer_size                = 256K
read_rnd_buffer_size            = 512K
myisam_sort_buffer_size         = 8M
tmp-table-size                  = 32M
max-heap-table-size             = 32M
max-connections                 = 500
thread-cache-size               = 50
open-files-limit                = 65535
table-definition-cache          = 1024
table-open-cache                = 2048
query_cache_type                = 1
query_cache_limit               = 256K
query_cache_min_res_unit        = 2k
query_cache_size                = 80M
innodb-log-files-in-group       = 2
innodb-log-file-size            = 64M
innodb-flush-log-at-trx-commit  = 1
innodb-file-per-table           = 1
innodb_buffer_pool_size         = 128M
innodb_additional_mem_pool_size = 2M
innodb_log_file_size            = 5M
innodb_log_buffer_size          = 8M
innodb_flush_log_at_trx_commit  = 1
innodb_lock_wait_timeout        = 50

数据库由20个InnoDB表组成,它们由5/10列组成。服务器的流量很低。

如何优化我的设置以适合EC2 t2.small(2GB RAM)?

1 个答案:

答案 0 :(得分:2)

你的配置中有两次innodb_buffer_pool_size。它应该是下划线,但检查哪一个用于:

show variables like 'innodb_buffer_pool_size';

您可以尝试将innodb_buffer_pool_size和query_cache_size减半。尝试使用query_cache_size = 0时性能良好。