gperftools优化nginx(内存)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了gperftools优化nginx(内存)相关的知识,希望对你有一定的参考价值。
gperftools优化nginx(内存)
说明:
操作系统: CentOS 6.5 64bit (虚拟机) nginx安装路径: /data/apps/nginx 配置文件路径: /data/apps/nginx/conf/nginx.conf nginx源码包: /data/softwrare/nginx-1.8.1
1、下载软件包
libunwind: http://download.savannah.gnu.org/releases/libunwind/ gperftools: https://github.com/gperftools/gperftools/releases
2、安装libunwind
#cd /data/software #tar -xvf libunwind-1.1.tar.gz #cd libunwind-1.1 #CFLAGS=-fPIC ./configure --enable-shared #make CFLAGS=-fPIC #make CFLAGS=-fPIC install
3、安装gperftools
#cd /data/software #tar -xvf gperftools-2.5.tar.gz #cd gperftools-2.5 #./configure --enable-shared && make && make install
4、配置gperftools
#echo "/usr/local/lib" >>/etc/ld.so.conf (注:如果先安装nginx可不运行) #ldconfig
5、与nginx配置编译
添加--with-google_perftools_module参数 #cd nginx-1.8.1 #./configure --prefix=/data/apps/nginx --conf-path=/data/apps/nginx/conf/nginx.conf --error-log-path=/data/logs/nginxlogs/error.log --http-log-path=/data/logs/nginxlogs/access.log --pid-path=/data/apps/nginx/run/nginx.pid --user=website --group=website --with-http_ssl_module --with-http_spdy_module --with-http_addition_module --with-http_sub_module --with-pcre=/data/software/pcre-8.39 --with-zlib=/data/software/zlib-1.2.8 --with-openssl=/data/software/openssl-1.0.2j/ --http-client-body-temp-path=/data/apps/nginx/temp/client_body_temp --http-proxy-temp-path=/data/apps/nginx/temp/proxy_temp --http-fastcgi-temp-path=/data/apps/nginx/temp/fastcgi_temp --http-uwsgi-temp-path=/data/apps/nginx/temp/uwsgi_temp --http-scgi-temp-path=/data/apps/nginx/temp/scgi_temp --with-google_perftools_module #make && make install
6、配置、测试nginx
#vim /data/apps/nginx/conf/nginx.conf 在#pid logs/nginx.pid;增加 google_perftools_profiles /data/temp/tcmalloc/; #service nginx reload #lsof -n |grep tcmalloc #lsof -i tcp:80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME nginx 20119 root 6u IPv4 425316 0t0 TCP *:http (LISTEN) nginx 20120 website 6u IPv4 425316 0t0 TCP *:http (LISTEN) nginx 20121 website 6u IPv4 425316 0t0 TCP *:http (LISTEN) nginx 20122 website 6u IPv4 425316 0t0 TCP *:http (LISTEN) nginx 20123 website 6u IPv4 425316 0t0 TCP *:http (LISTEN)
本文出自 “运维人生空间” 博客,请务必保留此出处http://hacker3389.blog.51cto.com/2331801/1877306
以上是关于gperftools优化nginx(内存)的主要内容,如果未能解决你的问题,请参考以下文章