MySQL 5.1 和内存分页缓慢。有图
我们使用的是 RHEL 5.4 64 位、16 GB RAM 6x AMD Opteron。
所以我们一直遇到这个问题:
https://i.sstatic.net/2sKuq.jpg
正如您所看到的,交换/分页开始慢慢增加。最终这会导致问题。那个大的下降是在 Mysqld 重新启动时发生的。该系统上没有运行其他任何东西。
主要使用Innodb,配置如下;
key_buffer = 512M
max_allowed_packet = 128M
thread_stack = 192K
thread_cache_size = 8
table_cache = 812
thread_concurrency = 10
query_cache_limit = 4M
query_cache_size = 512M
join_buffer_size = 512K
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 10G
innodb_file_io_threads = 4
innodb_thread_concurrency = 12
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 8M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
我听说过很多关于关闭“swappiness”或将其设置为“10”的消息。但这不是会引发 OOM 并终止 mysql 吗? 为什么会发生这种情况?
We are on a RHEL 5.4 64 bit , 16 GB RAM 6x AMD Opteron.
So we have been experiencing this issue:
https://i.sstatic.net/2sKuq.jpg
As you can see, the swap/paging starts to slowly creep up. Eventually this causes a problem. That large dip is when Mysqld was restarted. There is nothing else running on this system.
Mainly using Innodb with the following config;
key_buffer = 512M
max_allowed_packet = 128M
thread_stack = 192K
thread_cache_size = 8
table_cache = 812
thread_concurrency = 10
query_cache_limit = 4M
query_cache_size = 512M
join_buffer_size = 512K
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 10G
innodb_file_io_threads = 4
innodb_thread_concurrency = 12
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 8M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
I have heard a lot about turning off "swappiness" or setting it to '10'. But wouldn't that just call up an OOM and kill mysql?
why is this happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是在事后一年多后回答我自己的问题。
这是经验得出的。
MySQL 倾向于缓慢地进行交换。特别是如果它配置为耗尽所有必要的内存。
在这种情况下,我只是将 buffer_pool_size 降低到比文档中建议的稍低一些(<物理内存的 80%),并将 swappiness 更改为 10。
将其设置为 10 不会导致 OOM,因为系统在需要时仍会使用交换,只是不会那么积极。
Just to answer my own question after 1+ years after the fact.
This is from experience.
MySQL has a tendency to swap, slowly. Especially if it's configured to use up all necessary memory.
In this case I simply both lowered the buffer_pool_size to a bit lower than recomended on the documents (<80% of physical memory) also changed the swappiness to 10.
Setting it to 10 would not cause an OOM as the system would still use the swap when needed just not so aggressively.