设为首页 收藏本站
查看: 766|回复: 0

[经验分享] centos 6.3 64bit 用tcmalloc优化nginx-damon

[复制链接]

尚未签到

发表于 2018-11-8 08:50:37 | 显示全部楼层 |阅读模式
  一,tcmalloc全称thread-caching malloc,是谷歌开发的开源工具。与标准的glibc库的malloc比。tcmalloc在内存分配效率和速度比malloc高。至于为什么比malloc,有兴趣可以参考。下面这个网址。
  


  • http://www.mysqlops.com/2011/06/14/google-tcmalloc-malloc.html#more-737
  

  二,现在开始介绍在64bit centos 6.3的版本中让nginx使用tcmalloc。需要用到的软件都已经上传到附件中。
  
三,安装libunwind库。
  


  • # tar xf libunwind-1.0.tar.gz
  • # tar xf libunwind-1.0
  • #CFLAGS=-fPIC ./configure添加编译参数
  • # make CFLAGS=-fPIC
  • # make CFLAGS=-fPIC install
这样执行会出现如下错误:  

  


  • libtool: install: error: relink `libunwind-setjmp.la' with the above command before installing it
  • make[3]: *** [install-libLTLIBRARIES] Error 1
  • make[3]: Leaving directory `/down/libunwind-1.0/src'
  • make[2]: *** [install-am] Error 2
  • make[2]: Leaving directory `/down/libunwind-1.0/src'
  • make[1]: *** [install] Error 2
  • make[1]: Leaving directory `/down/libunwind-1.0/src'
  • make: *** [install-recursive] Error 1
  

  产生这种问题的原因:autotools兼容性的问题,运行命令autoreconf -i -f  ,在重新编译安装下。
  


  • #autoreconf -i -f
  • #make clean
  • #CFLAGS=-fPIC ./configure
  • #make  CFLAGS=-fPIC
  • #make  CFLAGS=-fPIC install
  

  四,安装gpperftools:
  


  • #tar xf  gperftools-2.0.tar.gz
  • # cd gperftools-2.0
  • #./configure
  • #make && make install
这样安装会会报如下错误:  

  


  • cc1plus: warning: unrecognized command line option "-Wno-unused-result"
  • ake: *** [stacktrace.lo] Error 1
  

  为什么出现在这种错误,因此是64bit系统,至于更深度的解释,安装说明中有。下面重新编译。
  


  • #make clean
  • #./configure  --enable-frame-pointers
  • #make &&  make install
  • #echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
  • #ldconfig
  

  五,编译pcre,使nginx支持http rewrite。
  


  • # tar xf pcre-8.10.tar.gz
  • # cd pcre-8.10
  • # ./configure
  • # make && make install
  

  六,编译nginx
  


  • # tar xf nginx-1.2.3.tar.gz
  • # ./configure  \
  • --with-http_ssl_module \
  •   --with-http_flv_module \
  •   --with-http_stub_status_module \
  •   --with-http_gzip_static_module \
  •   --http-client-body-temp-path=/var/tmp/nginx/client/ \
  •   --http-proxy-temp-path=/var/tmp/nginx/proxy/ \
  •   --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
  •   --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
  •   --http-scgi-temp-path=/var/tmp/nginx/scgi \
  •   --with-pcre \
  •   --with-google_perftools_module
  • # make && make install
  

  7,为gperftools创建线程目录
  


  • #mkdir /tmp/tcmalloc
  • #chmod 0777 /tmp/tcmalloc
  

  8,修改nginx的配置文件
  


  • #vim /usr/local/nginx/conf/nginx.conf
  • #pid        logs/nginx.pid;
  • google_perftools_profiles /tmp/tcmalloc;添加这一行
  

  9,启动nginx,并验证tcmalloc有没有正常加载
  


  • # /usr/local/nginx/sbin/nginx
  • # lsof -n |grep tcmalloc
  • nginx      1893    nobody    9w      REG              253,0        0      43018 /tmp/tcmalloc.1893
  • nginx      1894    nobody   11w      REG              253,0        0      43016 /tmp/tcmalloc.1894
  

  至此已经替换成功。



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-632190-1-1.html 上篇帖子: 使用rpm-build制作nginx的rpm包 下篇帖子: Terracotta+Tomcat+nginx实现session的共享
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表