1. 下載mysql的源碼包,進行編譯安裝(略)java
2. 下載安裝google-perftools
mysql
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軟件包
web
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軟件包
sql
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. 複製動態連接庫到系統目錄
vim
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配置文件
ide
vim /work/mysql5.5/bin/mysqld_safe
在此行文件的後面添加:
google
# executing mysqld_safe exportLD_PRELOAD="/usr/local/lib/libtcmalloc.so"
7. 重啓mysql
spa
/etc/init.d/mysql restart
8. 驗證
.net
[root@localhost ~]# lsof -n | greptcmalloc mysqld 17895 mysql mem REG 253,0 962769 534587 /usr/local/lib/libtcmalloc_minimal.so.0.1.0 [root@localhost ~]#