Linux · 2012-06-28

Directadmin使用gperftools工具包TCMalloc优化MySQL

首先安装gperftools工具包,可以放心使用,因为很简单,他来自Google!包含了TCMalloc, heap-checker, heap-profiler 和 cpu-profiler
项目主页
该安装套提供了.tar.gz RPM deb 等多种格式的安装包,只支持Linux

#rpm -Uvh https://gperftools.googlecode.com/files/gperftools-devel-2.0-1.i386.rpm
#或者下载tar.gz再手动编译
[root@localhost ~]# wget -c http://gperftools.googlecode.com/files/gperftools-2.0.tar.gz -O /root/downloads/gperftools-2.0.tar.gz #下载安装包
[root@localhost ~]# cd ~/downloads/ #进入刚下载的文件夹
[root@localhost ~]# tar zxf  gperftools-2.0.tar.gz #解压缩
[root@localhost ~]# cd gperftools-2.0/ #进入
[root@localhost ~]# ./configure ; make ; make install #并编译安装
[root@localhost ~]# echo '/usr/local/lib' >> /etc/ld.so.conf.d/usr_local_lib.conf
[root@localhost ~]# ldconfig -v #重新读取新的动态链接库文件
[root@localhost ~]# sed -i '/bin\/bash/a\export LD_PRELOAD=/usr/local/lib/libtcmalloc.so' /usr/bin/mysqld_safe #修改这个文件
[root@localhost ~]# service mysqld restart #重启MySQL服务

#经过测试,MySQL并发在100左右,负载高达60-70,MySQL表现良好,不愧为Google出品!