一、安装libunwind

wget http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz

本地下载:https://files.cnblogs.com/files/hacker1394/libunwind-1.1.tar.gz

tar zxvf libunwind-1.1.tar.gz

CFLAGS=-fPIC ./configure --enable-shared

make CFLAGS=-fPIC

make CFLAGS=-fPIC install

 

二、google模块 

下载地址:https://code.google.com/p/gperftools/   (需FQ)

wget https://googledrive.com/host/0B6NtGsLhIcf7MWxMMF9JdTN3UVk/gperftools-2.2.1.tar.gz

本地下载:https://files.cnblogs.com/files/hacker1394/gperftools-2.4.tar.gz

tar zxvf  gperftools-2.2.1.tar.gz

./configure  --enable-shared --enable-frame-pointers

make 

make install

 

三、更新,使动态链接库能够被系统共享

echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf

ldconfig

 

四、建立目录

mkdir -p /tmp/tcmalloc/

chmod 777 /tmp/tcmalloc/

 

五、一键脚本

下载地址:https://files.cnblogs.com/files/hacker1394/setup.sh

使用方法:

mkdir -p /root/setup/Nginx 

下载的三个文件放至Nginx文件夹

chmod +x /root/setup/Nginx/setup.sh

./setup.sh

 

六、nginx 加载google_perftools_module

例:./configure --user=website --group=website  --prefix=/usr/local/nginx/  --with-google_perftools_module

修改nginx.conf

在pid下添加一行

google_perftools_profiles /tmp/tcmalloc;

service nginx restart   (重启nginx)

验证:lsof -n | grep tcmalloc

 

七、MySQL

修改MySQL启动脚本(my.cnf)

vim /usr/local/mysql/bin/mysqld_safe

#executing mysqld_safe 下增加如下:

export LD_PRELOAD=/usr/local/lib/libtcmalloc.so

service mysqld restart    (重启mysql)

验证:  lsof -n | grep tcmalloc

 

posted on 2015-06-25 23:40  hacker1394  阅读(486)  评论(0编辑  收藏  举报