一、安装libunwind库。
cd /usr/local
wget http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz
tar xf libunwind-1.1.tar.gz cd libunwind-1.1
CFLAGS=-fPIC ./configure #添加编译参数 make CFLAGS=-fPIC make CFLAGS=-fPIC install
二、 安装gpperftools:
cd /usr/local
用迅雷下载 https://gperftools.googlecode.com/files/gperftools-2.0.tar.gz
然后上传到 /usr/local,因为好像wget 下载https的东东是不行的,或者很麻烦。
tar -zxvf gperftools-2.0.tar.gz cd gperftools-2.0
./configure
make && make install
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
/sbin/ldconfig
三、 Mysql加入动态库
vi /usr/local/mysql/bin/mysqld_safe
在“# executing mysqld_safe”行后添加行:
export LD_PRELOAD="/usr/local/lib/libtcmalloc.so"
目的是在启动mysql前, 加载tcmalloc动态库。
四、重启Mysql服务:
service mysql restart
五、验证TCMalloc
使用lsof查看mysql进 程是否已经加载了tcmalloc库:"
# lsof -n | grep tcmalloc
参考文档:
http://www.cnblogs.com/minglog/archive/2011/05/11/2043342.html
进一步测试:
模块压力进行内存占用测试,并评估执行效率。