Linux 64位, MySQL, Swap & Memory 优化
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)建议继续学习:
- WEB系统需要关注的一些点 (阅读:14106)
- 30分钟3300%性能提升――python+memcached网页优化小记 (阅读:12128)
- Linux服务器性能评估 (阅读:8185)
- 基于SSD的数据库性能优化 (阅读:7412)
- jQuery性能优化指南 (阅读:7325)
- 查看 CPU, Memory, I/O and NetFlow (阅读:6436)
- 一次简单C程序的性能优化 (阅读:5598)
- mysql sql 百万级数据库优化方案 (阅读:5056)
- 一次神奇的MySQL优化 (阅读:4895)
- PHP最佳实践 (阅读:4952)
扫一扫订阅我的微信号:IT技术博客大学习
- 作者:Penner 来源: Penner Blog
- 标签: Memory Swap 优化
- 发布时间:2009-10-21 22:10:31
- [56] 如何拿下简短的域名
- [55] Oracle MTS模式下 进程地址与会话信
- [55] IOS安全–浅谈关于IOS加固的几种方法
- [53] Go Reflect 性能
- [52] android 开发入门
- [51] 图书馆的世界纪录
- [50] 读书笔记-壹百度:百度十年千倍的29条法则
- [47] 【社会化设计】自我(self)部分――欢迎区
- [37] 程序员技术练级攻略
- [31] 视觉调整-设计师 vs. 逻辑