cd /usr/local/src
wget https://github.com/jemalloc/jemalloc/releases/download/5.0.1/jemalloc-5.0.1.tar.bz2
tar -xjvf jemalloc-5.0.1.tar.bz2
cd jemalloc-5.0.1/
./configure -prefix=/usr/local/jemalloc --libdir=/usr/local/lib
make && make install
echo /usr/local/lib >> /etc/ld.so.conf
ldconfig
nginx : --with-ld-opt="-ljemalloc" ##编译的时候添加这个参数
mysql: ##安装之后 修改 my.cnf
cp /usr/local/lib/libjemalloc.so /usr/lib
vim /etc/my.cnf
[mysqld_safe]
malloc-lib=/usr/lib/libjemalloc.so
/etc/init.d/mysqld restart
lsof -n | grep jemalloc 验证是否生效
本文转自 295631788 51CTO博客,原文链接:http://blog.51cto.com/hequan/2044761,如需转载请自行联系原作者