700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > gperftools mysql_利用 gperftools 对nginx mysql 内存管理 性能优化

gperftools mysql_利用 gperftools 对nginx mysql 内存管理 性能优化

时间:2020-10-04 13:10:30

相关推荐

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./releases/libunwind/libunwind-1.1.tar.gz

gperftools 2.0版本

wget /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 就可以啦.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。