使用NUMA,将是内存分配不均衡,造成使用swap,引起数据库变慢,使用以下方法解决此问题:
1、强制交叉分配:
numactl --interleave=all ./bin/mysqld_safe --defaults-file=/etc/my.cnf &
2、在开启mysql服务之前,刷新Linux buffer caches:percona支持flush_caches命令行参数
sysctl -q -w vm.drop_caches=3
3、
在mysql启动
时
强制操作系统立即分配Innodb buffer pool:
percona支持
innodb_buffer_pool_populate系统参数,移植来自Twitter补丁
以下使用tpcc-mysql进行测试,观察使用numa和交叉模式的性能数据对比:
测试环境:
Mysql(版本:Percona-Server-5.6.19-rel67.0-618)配置:
innodb_buffer_pool_size=20G
tpcc-mysql测试参数:
测试数据大约为90G
![18150037_HLrG.png](http://static.oschina.net/uploads/img/201407/18150037_HLrG.png)
测试结果:
![18150037_EO7u.png](http://static.oschina.net/uploads/img/201407/18150037_EO7u.png)
总结:
1、关闭numa后,每分钟新订单数(TpmC)提高了很多;numactl --interleave=all比numa模式(default)提高了33%;
2、在BIOS中关闭numa后,性能更好,所以建议在BIOS中设置内存为交叉模式;
如DELL R720中在BIOS中关闭numa:
参考:
1、"The MySQL “swap insanity” problem and the effects of the NUMA architecture":
http://blog.jcole.us/2010/09/28/mysql-swap-insanity-and-the-numa-architecture/
2、"玩转CPU Topology":
http://www.searchtb.com/2012/12/%E7%8E%A9%E8%BD%ACcpu-topology.html
3、"SWAP的罪与罚":
http://huoding.com/2012/11/08/198
4、"Non-uniform memory access":
http://en.wikipedia.org/wiki/Non-Uniform_Memory_Access
5、"Improved NUMA support":
http://www.percona.com/doc/percona-server/5.5/performance/innodb_numa_support.html
6、"A brief update on NUMA and MySQL":
http://blog.jcole.us/2012/04/16/a-brief-update-on-numa-and-mysql/