技术头条 - 一个快速在微博传播文章的方式     搜索本站
您现在的位置首页 --> MySQL --> Linux 64位, MySQL, Swap & Memory 优化

Linux 64位, MySQL, Swap & Memory 优化

浏览:4460次  出处信息

    MySQL的性能优化文章有很多,这里介绍个通过优化Swap & Memory来提高性能的方法。

    The VM for Linux prefers system cache over application memory. What does this mean? The best way I can explain is by example.

    Imagine you have 32 GB of RAM

    MySQL is set to take 20 GB of RAM for a process based buffer and up to 6M for the various thread buffers.

    Over a period of time the box swaps. The only thing that is running is mysql and its memory size is around 21GB for resident memory. Why does swap grow when there is plenty of memory? The reason is when a memory alloc is needed (thread based buffer is tickled) the VM will choose to use swap over allocating from the system cache, when there is not enough free memory.

    DO NOT TURN OFF SWAP to prevent this. Your box will crawl, kswapd will chew up a lot of the processor, Linux needs swap enabled, lets just hope its not used.

    So how do you stop Nagios pages because of swap usage? Well if you have a few choices.

    reboot the box

    or

    stop mysql && swapoff -a;swapon -a;

    or just

    swapoff -a;swapon -a;

    (注意!如果你在MySQL正在使用Swap时执行,会把MySQL搞死,所以执行前一定要反复确认Swap没有被使用。)

    Doing the latter command is rather scary and fun at the same time. Because you can either crash mysql or not. I just did the swap* commands live, I was very certain nothing was using swap and it worked. YAY no more pages and I didn’t have to shut down the service!

    参考文章:

    http://mysqldba.blogspot.com/2008/05/linux-64-bit-mysql-swap-and-memory.html

相关日志

今天卸载Mysql时碰到的问题 (0) MySQL4.1/5.0中字符集_chinese_ci和_bin的区 (0) MySQL Proxy 编译安装 By CentOS (1)

建议继续学习:

  1. WEB系统需要关注的一些点    (阅读:14064)
  2. 30分钟3300%性能提升――python+memcached网页优化小记    (阅读:12110)
  3. Linux服务器性能评估    (阅读:8151)
  4. 基于SSD的数据库性能优化    (阅读:7385)
  5. jQuery性能优化指南    (阅读:7303)
  6. 查看 CPU, Memory, I/O and NetFlow    (阅读:6414)
  7. 一次简单C程序的性能优化    (阅读:5582)
  8. mysql sql 百万级数据库优化方案    (阅读:5034)
  9. 一次神奇的MySQL优化    (阅读:4869)
  10. PHP最佳实践    (阅读:4921)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
© 2009 - 2024 by blogread.cn 微博:@IT技术博客大学习

京ICP备15002552号-1