正在加载...

Tcmalloc 优化 Nginx Mysql

[ 2011/01/09 13:34 | by selboo ]

下载google-perftools-1.6.tar.gz
wget http://google-perftools.googlecode.com/files/google-perftools-1.6.tar.gz
tar zxvf google-perftools-1.6.tar.gz
执行./configure --prefix=/usr/local/google-perftools-1.6
make && make install

echo "/usr/local/google-perftools-1.6/lib" > /etc/ld.so.conf
ldconfig

Nginx 优化

编译nginx时 增加  --with-google_perftools_module

--prefix=/usr/local/nginx --user=www --group=www --with-google_perftools_module
make
make install

ldd /usr/local/nginx/sbin/nginx
        linux-gate.so.1 =>  (0x00493000)
        libcrypt.so.1 => /lib/libcrypt.so.1 (0x00110000)
        libpcre.so.0 => /lib/libpcre.so.0 (0x002db000)
        libcrypto.so.6 => /lib/libcrypto.so.6 (0x009ae000)
        libz.so.1 => /usr/lib/libz.so.1 (0x003b0000)
        libprofiler.so.0 => /usr/local/google-perftools-1.6/lib/libprofiler.so.0 (0x00c51000)
        libc.so.6 => /lib/i686/nosegneg/libc.so.6 (0x00142000)
        libdl.so.2 => /lib/libdl.so.2 (0x0035c000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00d01000)
        libm.so.6 => /lib/i686/nosegneg/libm.so.6 (0x00b28000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00eb8000)
        /lib/ld-linux.so.2 (0x00ed5000)

修改 nginx.conf 增加以下参数
mkdir /tmp/tcmalloc/
google_perftools_profiles /tmp/tcmalloc/;

Mysql 优化

--prefix=/usr/local/mysql --with-pthread --with-big-tables --with-charset=utf8 --with-extra-charsets=all --enable-static --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-mysqld-ldflags=-ltcmalloc --enable-thread-safe-client --enable-assembler --


或者启动执行
export LD_PRELOAD=/usr/local/google-perftools-1.6/lib/libtcmalloc.so
最后编辑: selboo 编辑于2011/10/04 18:24
Tags: , ,
,
发表评论
表情
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]