Let lnmp support tcmalloc

  

What is tcmalloc? TCMalloc (google-perftools) is a multi-threaded application for optimizing C++ writes, faster than glibc 2.3's malloc. This module can be used to make MySQL's memory usage more stable under high concurrency. Adding mysql and nginx to lnmp using the online method is not acceptable. Because nginx is added when compiling, mysql lnmp defaults to all static compilation. So to modify the lnmp installation script, install tcmalloc before installing lnmp due to static compilation. Download wget http://gperftools.googlecode.com/files/gperftools-2.0.tar.gz Unzip tar xf gperftools-2.0.tar.gz cd gperftools-2.0 Configuration ./configure Compile and install make && make install Everything goes well Echo “/usr/local/lib” > /etc/ld.so.conf.d/usr_local_lib.conf /sbin/ldconfig

Download wget -c http://soft.vpser.net /lnmp/lnmp0.9-full.tar.gz Unzip tar xf lnmp0.9-full.tar.gz cd lnmp0.9-full

Modify the installation script, I am using the centos vi. Centos.sh

Let mysql support tcmalloc increase at the end of line 306 –with-mysqld-ldflags=-ltcmalloc Approximate increase at the end of line 308 –with-mysqld-ldflags=-ltcmalloc

Let nginx support tcmalloc increase at the end of 460 lines –with-google_perftools_module

After wq exits saving, execute ./centos.sh and install lnmp

as usual. Some nginx parameters mkdir -p /tmp/tcmalloc/chown -R www:www /tmp/tcmalloc/Edit vi /usr/local/nginx/conf/nginx.conf worker_rlimit_nofile 51200; Line increase (on the outside anyway) google_perftools_profiles /tmp /tcmalloc /; wq save and exit

Then restart lnmp execute lsof -n |  Grep tcmalloc can see that the description is successful. Nginx 12256 www 9w REG 0,29 0 13011440 /tmp/tcmalloc/.12256 mysqld 13425 mysql mem REG 253,0 10685079 /usr/local/lib/libtcmalloc.so.4.1.0 (path dev=0,29)

Copyright © Windows knowledge All Rights Reserved