[文章作者:张宴 本文版本:v1.1 最后修改:2008.06.02 转载请注明出自:http://blog.zyan.cc]

  TCMalloc(Thread-Caching Malloc)是google开发的开源工具──“google-perftools”中的成员。与标准的glibc库的malloc相比,TCMalloc在内存的分配上效率和速度要高得多,可以在很大程度上提高MySQL服务器在高并发情况下的性能,降低系统负载。

  TCMalloc的实现原理和测试报告请见一篇文章:《TCMalloc:线程缓存的Malloc

  为MySQL添加TCMalloc库的安装步骤(Linux环境):

  1、64位操作系统请先安装libunwind库,32位操作系统不要安装。libunwind库为基于64位CPU和操作系统的程序提供了基本的堆栈辗转开解功能,其中包括用于输出堆栈跟踪的API、用于以编程方式辗转开解堆栈的API以及支持C++异常处理机制的API。
wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99-alpha.tar.gz
tar zxvf libunwind-0.99-alpha.tar.gz
cd libunwind-0.99-alpha/
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC
make CFLAGS=-fPIC install


  2、安装google-perftools:
wget http://google-perftools.googlecode.com/files/google-perftools-0.97.tar.gz
tar zxvf google-perftools-0.97.tar.gz
cd google-perftools-0.97/
./configure
make && make install

echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
/sbin/ldconfig


  3、修改MySQL启动脚本(根据你的MySQL安装位置而定):
vi /usr/local/mysql/bin/mysqld_safe

  在# executing mysqld_safe的下一行,加上:
引用
export LD_PRELOAD=/usr/local/lib/libtcmalloc.so

  保存后退出,然后重启MySQL服务器。


  4、使用lsof命令查看tcmalloc是否起效:
/usr/sbin/lsof -n | grep tcmalloc

  如果发现以下信息,说明tcmalloc已经起效:
  mysqld    10847   mysql  mem       REG        8,5  1203756   20484960 /usr/local/lib/libtcmalloc.so.0.0.0  



  注:2008年6月2日,修正了libunwind在x86_64位操作系统下的编译错误,TCMalloc无法加载等问题。

  涉及修改内容:
  1、libunwind的编译参数改为:
  CFLAGS=-fPIC ./configure
  make CFLAGS=-fPIC
  make CFLAGS=-fPIC install

  2、增加:
  echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
  /sbin/ldconfig

  3、修改MySQL加载TCMalloc的语句:
  export LD_PRELOAD=/usr/local/lib/libtcmalloc.so

  感谢网友router。






技术大类 » 数据库技术 | 评论(66) | 引用(0) | 阅读(96534)
Hibah Email
2022-9-9 21:54
There are such a lot of poker video games which can be to be had a few are for greater excessive stakes than others and a few which can be greater a laugh oriented. High stake poker video games are for folks who are a bit greater professional in gambling the game.  플레이포커
Hibbah Email
2022-9-12 10:08
That`s due to the fact DuroMAX combines the herbal elements you want to get the excellent consequences in bed. All elements are established to be effective.   duromax vende em farmácia
Lucky cola
2024-2-7 16:03
Experience the thrill of victory in every game.  Lucky cola
SexyPGGAME Email Homepage
2024-2-9 15:56
slot777 A new gaming website that meets every gambling lifestyle.
SexyPGGAME Email Homepage
2024-2-9 15:56
slot777 A new gaming website that meets every gambling lifestyle.
SexyPGGAME Email Homepage
2024-2-9 15:56
slot777 A new gaming website that meets every gambling lifestyle.
分页: 4/4 第一页 上页 1 2 3 4 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]