首先下载jemalloc
wget -c http://www.canonware.com/download/jemalloc/jemalloc-4.2.1.tar.bz2 tar jxvf jemalloc-4.2.1.tar.bz2 cd jemalloc-4.2.1 ./configure make make install echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf ldconfig
MySQL/MaridDB 5.5编译方法,cmake预编译时加上下面参数
-DCMAKE_EXE_LINKER_FLAGS="-ljemalloc" -DWITH_SAFEMALLOC=OFF
或者直接加载,修改mysqld_safe
sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' /usr/local/mysql/bin/mysqld_safe service mysqld restart
使用jemalloc优化Nginx
cd lnmp/src/nginx-1.4.2 make clean ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-ld-opt="-ljemalloc" make make install
验证jemalloc优化Nginx是否生效,如下
lsof -n | grep jemalloc
我要评论