gperftools mysql_利用 gperftools 对nginx mysql 内存管理 性能优化
利用?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.
首先下載軟件安裝包:
由于我們的系統為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
安裝軟件包
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????使之生效
重新編譯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 mysql_利用 gperftools 对nginx mysql 内存管理 性能优化的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 交行信用卡买单吧人品指数在哪里看
- 下一篇: 什么是顺周期?什么是逆周期?