[文章作者:张宴 本文版本: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) | 阅读(96581)
rpm
2008-9-27 14:08
rpm装的mysql 是不是都是静态编译的
--with-mysqld-ldflags="-all-static  去不掉 装了没检测到。。。
如何解决rpm包装的这个问题
mysql
2009-1-2 08:56
成功安装加载进去后发现mysqld_safe不断自动重启mysql, 不知道什么原因
系统是RHEL 5 x86_64
FreeBSD
2009-1-10 22:40
请问张哥BSD64位系统用不用装   1、64位操作系统请先安装libunwind库,32位操作系统不要安装。libunwind库为基于64位CPU和操作系统的程序提供了基本的堆栈辗转开解功能,其中包括用于输出堆栈跟踪的API、用于以编程方式辗转开解堆栈的API以及支持C++异常处理机制的API。
成功编译
2009-2-11 17:58
./configure --prefix=/opt/mysql --enable-assembler --with-mysqld-ldflags="-all-static -ltcmalloc -lunwind" --with-client-ldflags=-all-static --without-debug --with-innodb --without-docs --with-charset=gbk --with-collation=gbk_chinese_ci  --with-extra-charset=complex --enable-large-files --with-big-tables --enable-thread-safe-client --without-uca

一定要加--enable-thread-safe-client
ellison
2009-5-20 10:17
http://www.chinaunix.net/jh/17/1447506.html大哥 碰到这样滴状况了么搞啊
QQ农场 Email Homepage
2010-8-9 14:43
没弄好,再看一下。cry
bugx
2010-10-7 14:23
有人测试成功32位系统静态编译TCMalloc到Mysql,方法是:

要执行的预编译指令
Java代码

   1. CFLAGS="-O3"  
   2. CXX=g++  
   3. CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti"  

CFLAGS="-O3"
CXX=g++
CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti"


在configure时要加入的参数
Java代码

   1. --with-mysqld-ldflags=-all-static  
   2. --with-mysqld-ldflags=-ltcmalloc  
   3. #网上都写成了--with-mysqld-ldflags="-all-static -ltcmalloc",结果make错误,分开写没问题  
   4. --enable-thread-safe-client  
   5. #有人说必须要  

--with-mysqld-ldflags=-all-static
--with-mysqld-ldflags=-ltcmalloc
#网上都写成了--with-mysqld-ldflags="-all-static -ltcmalloc",结果make错误,分开写没问题
--enable-thread-safe-client
#有人说必须要
littlefang
2010-11-23 10:54
google的这个工具这个费劲,还不如用hoard呢。
ccitt
2011-4-28 14:48
lsof无法执行的安装以下即可
redhat/centos系统直接用yum安装下
yum install lsof
dresses Email Homepage
2011-7-26 10:13
Here are a variety of the empire <a href="http://www.romancearound.com/">dresses</a>, I want to introduce yourself. The first shoulder chiffon <a href="http://www.romancearound.com/bridesmaid-dresses-c-197.html">bridesmaid dresses</a> empire style wedding will <a href="http://www.romancearound.com/wedding-dresses-trumpet-wedding-dresses-c-180_253.html">trumpet wedding dresses</a>.This Tia cowries, dressed in her wedding day.Chiffon of the empire the best clothes, because they are the size of the drum as complete motion from the wind the site makes it easy to create a plan impression.One romantic flowers floating above shoulder function and help catch the eyes of the cut of the chest and neck problems, so that more comprehensive coverage of physical illusion bust.Clothing do not like big long torso, short legs, or pear-shaped<a href="http://www.romancearound.com/bridesmaid-dresses-ankle-length-bridesmaid-dresses-c-197_198.html">ankle length bridesmaid dresses</a> figure.special is also suitable for pregnant brides since the mobility as a dress can accommodate more Many of the abdomen.
cnrainbing
2011-8-30 13:17
请问老师tcmalloc是否支持oracle 呢?
louis vuitton uk Email Homepage
2011-11-23 09:00
This louis vuitton uk for sale belongs to the sounding just what are termed as Louis Vuitton vintage best sellers, many other products and services for the reason that range appearing companies.You will easily notice the unfold zippers of this coach outlet store online. That is the decoration. There are some inside pockets for you as well. They are easy to match your clothes and to carry.Let us inspire your inner beauty with fine christian louboutin sale. Purse the elegance in bridal wedding. Enjoy the fashion.
coach factory outlet Email Homepage
2012-5-17 11:34
Today, following half a century, mentor leather-bases coach factory outlet continues to be the delicate craft of leather-based master is accountable for,Would you like to meet more friends, or go with the times? If yes, coach factory online is opening welcome doors to you.in the market you definitely can find various colorways that are designed in as well as the high quality that applied in. For most of you would like to come. So just come to our coach factory outlet online store to choose one.
louis vuitton sale Email Homepage
2012-5-17 11:34
Louis Vuitton belt at louis vuitton sale is one kind of fashion accessory with high cost performance among the Louis Vuitton accessories.Offering quality LV products with favorable prices, louis vuitton outlet store is at your service. Hurry up, or you can not seize the chance.in fact, louis vuitton is one of the most famous fashion design master.he opened the fist suitcase shop called after his name.
coach outlet online Email Homepage
2012-5-17 11:34
I heard of coach outlet online through the advertisement when I was shopping. And now I often brow the webpage and buy Coach bags online.It is a symbol regarding position not to mention nature.Here I would like to launch a excellent bags pertaining to business men.Which may be coach outlet store.coach outlet has always been simple,durable style features to win consumers.The products are more flexible,with easy bleaching,wear characteristics,and simply use a damp cloth.
coach outlet, Email Homepage
2012-5-17 11:34
Remember the coach outlet provide coach bags which won't be deteriorated into its overall styles by any means. It will maintain its looks, colors, and uniqueness for long time.coach outlet store online has been voted by Hour Detroit magazine readers as the Best of Detroit in their 12th annual readers'poll.Lots of women like which usually amount normally include a coach outlet online ,it provides coziness to many girls that don't even think it is a great bushel of great interest directly to them.
xujie777 Email
2012-5-18 16:43
We aim to make all our customers satisfy with our products. You will find a variety of Men's fashion louis vuitton uk, fashion Women's cheap Louis Vuitton bags in our store at affordable price.Thinking of interesting ways to cost a milestone birthday? louis vuitton online shop had one of the most distinctive distinctive celebrations.bakery along with living room operated by means of about three moment louis vuitton online Most effective Pastry Chef’s of the year Rammy Nominee Chef’s.
分页: 2/4 第一页 上页 1 2 3 4 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]