Upgrade Jemalloc, optimize MySQL and Nginx
in Tutorial with 0 comment
Upgrade Jemalloc, optimize MySQL and Nginx
in Tutorial with 0 comment

This tutorial has been practiced on this blog linpx.com on March 11, 2016, including upgrading or installing Jemalloc, optimizing MySQL and Nginx.

So now:

Upgrade or install Jemalloc

 wget  http://www.canonware.com/download/jemalloc/jemalloc-4.1.0.tar.bz2 tar xjf jemalloc-4.1.0.tar.bz2 cd jemalloc-4.1.0 ./configure make && make install echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf ldconfig

Use jemalloc to optimize MySQL

Method 1:

MySQL/MaridDB compilation method, add the following parameters when cmake is precompiled

 -DCMAKE_EXE_LINKER_FLAGS="-ljemalloc" -DWITH_SAFEMALLOC=OFF

Method 2:

Use the following code to automatically modify the mysqld_safe file

 sed -i 's@executing  mysqld_safe@executing  mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' /usr/local/mysql/bin/mysqld_safe

Restart MYSQL

CentOS 6.x:

 service mysqld restart

CentOS 7.x:

 systemctl restart mysqld

Optimize Nginx with jemalloc

Upgrade Nginx to 1.9.12

 cd /usr/src wget  http://nginx.org/download/nginx-1.9.12.tar.gz tar -xzvf nginx-1.9.12.tar.gz

Check the configuration arguments of your Nginx. The next step of installation and compilation requires

 nginx -V

Copy the content of configure arguments in/ After configure, bring the content you copied, and then don't forget to bring it --with-ld-opt="-ljemalloc"

 cd nginx-1.9.12 make clean ./configure --prefix=/usr/local/nginx --user=www --group=www --with-openssl=/usr/src/openssl-1.0.2g --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-ld-opt="-ljemalloc" make && make install

Verify whether jemalloc optimized Nginx works

 lsof -n | grep jemalloc

Over~

Responses