1. 下载mysql的源码包,进行编译安装(略)
2. 下载安装google-perftools
wget https://lnamp-web-server.googlecode.com/files/google-perftools-1.7.tar.gz wget http://ftp.twaren.net/Unix/NonGNU//libunwind/libunwind-0.99.tar.gz
3. 64位的系统需要安装libunwind软件包
tar zxvf libunwind-0.99.tar.gz cd libunwind-0.99 CFLAGS=-fPIC ./configure --enable-shared make CFLAGS=-fPIC make CFLAGS=-fPIC install
4. 安装google-perftools软件包
tar zxvf google-perftools-1.7.tar.gz cd google-perftools-1.7 mkdir /work/tc ./configure --prefix=/work/tc --disable-cpu-profiler --disable-heap-profiler--disable-heap-checker --disable-debugalloc --enable-minimal make && make install
5. 复制动态链接库到系统目录
cp /work/tc/lib/libtcmalloc_minimal.so.0.1.0 /usr/local/lib ln -s /usr/local/lib/libtcmalloc_minimal.so.0.1.0 /usr/local/lib/libtcmalloc.so ln -s /usr/local/lib/libtcmalloc_minimal.so.0.1.0 /usr/local/lib/libtcmalloc.so.0 ln -s /usr/local/lib/libtcmalloc_minimal.so.0.1.0 /usr/local/lib/libtcmalloc.so.0.1.0
6. 调整mysqld_safe配置文件
vim /work/mysql5.5/bin/mysqld_safe
在此行文件的后面添加:
# executing mysqld_safe exportLD_PRELOAD="/usr/local/lib/libtcmalloc.so"
7. 重启mysql
/etc/init.d/mysql restart
8. 验证
[[email protected] ~]# lsof -n | greptcmalloc mysqld 17895 mysql mem REG 253,0 962769 534587 /usr/local/lib/libtcmalloc_minimal.so.0.1.0 [[email protected] ~]#
时间: 2024-11-11 21:36:49