我有一个带有 Apache
和 MySQL
的网络服务器,运行在 AWS EC2 t2.small
和 Windows 2012 Server
上>。 AWS 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 内存)?
最佳答案
您的配置中有两次 innodb_buffer_pool_size。它应该带有下划线,但请检查使用的是哪一个:
show variables like 'innodb_buffer_pool_size';
您可以尝试将 innodb_buffer_pool_size 和 query_cache_size 减半。尝试使用 query_cache_size=0 性能是否正常。
关于mysql - 优化 AWS EC2 t2.small 的 MySQL 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28748827/