利用 gperftools 对nginx 与 mysql  进行 内存管理  性能优化 降低负载.

Gperftools 是由谷歌开发。官方对gperftools 的介绍为:

These tools are for use by developers so that they can create more robust applications. Especially of use to those developing multi-threaded applications in C++ with templates. Includes TCMalloc, heap-checker, heap-profiler and cpu-profiler.

  1. 首先下载软件安装包:

由于我们的系统为CentOS 5.8 x64的系统, 64位系统需要先安装 libunwind 支持库。

wget http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz

gperftools 2.0版本

wget http://gperftools.googlecode.com/files/gperftools-2.0.tar.gz

  1. 安装软件包

tar zxvf libunwind-1.1.tar.gz

cd libunwind-1.1

./configure

make && make install

tar zxvf gperftools-2.0.tar.gz

cd gperftools-2.0

./configure --enable-frame-pointers

make && make install

增加 gperftools 线程目录

mkdir /tmp/tcmalloc

设置权限

chmod 777 /tmp/tcmalloc

配置lib 库文件目录

vim /etc/ld.so.conf

增加

/usr/local/lib

/sbin/ldconfig    使之生效

  1. 重新编译nginx 使其支持gperftools

tar zxvf nginx-1.2.3.tar.gz

cd nginx-1.2.3

./configure --user=upload --group=upload --prefix=/opt/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-google_perftools_module

make && make install

安装完毕以后, 修改 nginx 配置文件 nginx.conf

vim /opt/local/nginx/con/nginx.conf

在pid 下面增加

#gperftools

google_perftools_profiles /tmp/tcmalloc;

然后保存,启动nginx

/opt/local/nginx/sbin/nginx -t  查看配置是否正常

lsof -n | grep tcmalloc  查看是否运行

nginx     18454    upload   10w      REG                8,2          0   10780681 /tmp/tcmalloc.18454

nginx     18455    upload   12w      REG                8,2          0   10780682 /tmp/tcmalloc.18455

---------------------------------------------------------------------------------

优化Mysql 则不需要重新编译mysql 只需要找到 mysqld_safe 这个文件

在# executing mysqld_safe 下面加上

export LD_PRELOAD=/usr/local/lib/libtcmalloc.so

然后重启mysql 就可以啦.

利用 gperftools 对nginx mysql 内存管理 性能优化的更多相关文章

  1. MySQL内存管理机制浅析

    GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. GreatSQL是MySQL的国产分支版本,使用上与MySQL一致. 目录 一.placement new的定义 二.pl ...

  2. mySQL内存及虚拟内存优化设置[转]

    mySQL内存及虚拟内存优化设置 . 数据库mySQL内存优化G-LB  为了装mysql环境测试,装上后发现启动后mysql占用了很大的虚拟内存,达8百多兆.网上搜索了一下,得到高人指点my.ini ...

  3. Atitit 如何利用先有索引项进行查询性能优化

    Atitit 如何利用先有索引项进行查询性能优化 1.1. 再分析的话就是我们所写的查询条件,其实大部分情况也无非以下几种:1 1.2. 范围查找 动态索引查找1 1.2.1. 索引联合 所谓的索引联 ...

  4. nginx slab内存管理

    本来这一篇作为nginx系列的开头是不合适的,不过由于nginx进程框架自己的梳理还没完成,这部分又刚好整理完了,就从这开始吧.这儿谈的是nginx的slab的内存管理方式,这种方式的内存管理在ngi ...

  5. nginx的内存管理

    先来看内存池的实现,nginx的内存池实现的非常简单. 这里内存池的一些图表可以看老朱同学的slides : http://blog.zhuzhaoyuan.com/2009/09/nginx-int ...

  6. mysql内存管理

    1 内存管理结构 mysql有自己的内存申请和释放机制 mysql层有mem_root innodb层有mem_heap,mem_pool,buf_pool 它们的结构图如下 2 mem_root m ...

  7. Nginx源码研究四:NGINX的内存管理

    关于nginx的内存使用,我们先看代码,下面是nginx_cycle.c中对全局数据结构cycle的初始化过程 pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, ...

  8. 安全开发运维必备,如何进行Nginx代理Web服务器性能优化与安全加固配置,看这篇指南就够了

    本章目录 1.引言 1.1 目的 1.2 目标范围 1.3 读者对象 2.参考说明 2.1 帮助参考 2.2 参数说明 3.3 模块说明 3.服务优化 3.1 系统内核 3.2 编译优化 3.3 性能 ...

  9. Android 内存管理之优化建议

    OOM(OutOfMemory)转:http://hukai.me/android-performance-oom/ 前面我们提到过使用getMemoryClass()的方法可以得到Dalvik He ...

随机推荐

  1. Linux 配置tomcat遇见的若干问题

    1.提示catalina.sh缺失 原因:未对bin目录下的.sh文件授权 执行:chmod +x bin/*.sh即可 2.正常启动Tomcat 但是外界无法访问 Linux防火墙原因,进入到 et ...

  2. OpenGL------显示列表

    我们已经知道,使用OpenGL其实只要调用一系列的OpenGL函数就可以了.然而,这种方式在一些时候可能导致问题.比如某个画面中,使用了数千个多边形来表现一个比较真实的人物,OpenGL为了产生这数千 ...

  3. hiho 1015 KMP

    input 1<=T<=20 string1 1<=strlen(string1)<=1e4 string2 2<=strlen(string2)<=1e6 out ...

  4. Local declaration of 'XXX' hides instance variable

    今天调试程序遇到这么一个警告! Local declaration of 'XXX' hides instance variable 遇到这种原因,是因为本地变量跟函数参数变量同名.改变其一即可.

  5. java代码用dom4j解析xml文件的简单操作

    时间: 2016/02/17 目标:为telenor的ALU Femto接口写一个采集xml文件并解析出locationName标签里的值,然后更新到数据库中. 从网上搜了下,有四种常用的解析xml的 ...

  6. POJ 1236 Network of Schools (tarjan算法+缩点)

    思路:使用tarjan求强连通分量并进行缩点,判断所有入度为0的点,这个点就是必须要给予文件的点,分别计算出度,入度为零的点的个数,取二者的最大值就是把这个图变成强连通需要加的边数. 一个取值需要讨论 ...

  7. Django - 模型表单(创建、更新、删除)

    urls.py # /music/alubm/add/ url(r'^album/add/$', views.AlbumCreate.as_view(), name="album-add&q ...

  8. myEclipse JSP 调用 IDL8.2 配置

    新安装了Envi5.0 IDL8.2,路径改动了,一些配置也要随之改动.现在总结一下,JSP调用IDL的配置. jar包配置,环境变量配置,dll配置,tomcat路径配置,tomcat运行选项配置, ...

  9. HDU 3552 I can do it!

    脑洞题.http://blog.csdn.net/dgq8211/article/details/7748078 #include<cstdio> #include<cstring& ...

  10. C++:bitset类的使用

    #include <iostream> #include <bitset> using namespace std; int main() { //初始化一个bitmap , ...