[文章作者:张宴 本文版本: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) | 阅读(99183)
xujie777 Email
2012-5-18 16:43
The choices are likely to be basically countless seeing that louis vuitton outlet occurs with the help of completely new and also incredible concepts once in a while.Louis vuitton Wholesale Monogram Canvas HandbagsLouis Vuitton Collection Beach Handbags louis vuitton bags outlet Damier Canvas HandbagsLouis vuitton Mahina HandbagsLouis Vuitton Monogram Mini Lin HandbagsLouis Vuitton Monogram Multicolore HandbagsLouis vuitton Monogram Vernis HandbagsLouis Vuitton Wholesale Epi Leather HandbagsLouis Vuitton For Men HandbagsLouis Vuitton Damier Canvas WalletsLouis Vuitton Epi Leather WalletsLouis Vuitton Monogram Canvas WalletsLouis Vuitton Monogram Vernis WalleLouis Vuitton ShoesLouis Vuitton Men wallets.As the Authentic Louis Vuitton are so high-priced, so came the louis vuitton handbags outlet.
xujie777 Email
2012-5-18 16:43
coach outlet has become a popular shopping experience for consumers around the world, and a desirable distribution channel for manufacturer's and retailers.Getting your hands on coach outlet store online can be a hefty investment of hundreds of dollars.But do not despair,the Coach Outlet store could be the answer to your prayers.coach outlet online is your smart choice when you want to get the discount Coach accessory. You can find the exact Coach Bags and other accessory you want at a low price that's right for you. My dear friends, let the coach outlet online pave your way into the world of high fashion with their ultimate fashion factory.
xujie123
2012-5-21 11:20
Our online store offers you discounted Designer louis vuitton replica wallet at present. You could find them in desirable quality and price. If you don't mind high class louis vuitton uk, have a good time here.louis vuitton Store Online Handbags can also bring great accuracy as well as practical applicability and fashionable.Have you ever dreamed of being as charming as Madonna? Have you ever thought of becoming an envy of all your friends? If so, come to louis vuitton outlet.<br/>
xujie555
2012-5-21 13:44
coach factory outlet uses graceful accessories to match the classical logo of coach, which is the best combination of coach. The handmade coach products?can make you more charming and graceful.coach factory online provides people many coach goods. If you wish to snatch the coach handbag, then this best method is made for that you like for coach discount.coach factory outlet online is a fashion brand to ensure its quality. With designer coach shoulder bags, you will always attract people's attention. The bags will emphasize your personal style and taste.<br/>
xujie333
2012-5-21 15:08
coach outlet online Store guarantee that all the coach handbags offered are own high quality. In addition , all of them are sold at an unexpected low price.If you want to purchase, just visit their website.coach factory outlet is really sizzling kinds of shopping way for you. With the usage of the replica designer coach bags, you can surely be able to change your individual looks in a stunning manner.Coach bags on sale from the coach outlet are cheap or discount prices that you certainly will stand out from the crowd on your next camping trip!<br/>
磨延城 Email Homepage
2013-10-21 21:12
磨途歌学习了
wangguo
2013-11-4 17:09
问题:系统是centos 6.4 64位;已经安装google-perftools-1.9.1,并且nginx也已经加载;[root@localhost lib]# lsof -n | grep tcmallnginx     10968   nginx    9w      REG              253,0         0     538187 /tmp/tcmalloc.10968已经通过yum方式安装mysql-5.5.34;看了很多资料说修改mysqld_safe文件,增加export LD_PRELOAD=/usr/local/lib/libtcmalloc.so这行。死活不能载入google-perftools.想重新编译mysql,结果下载的5.5.34只能用cmake安装,没有./configure 命令。最后解决:修改 /etc/init.d/mysqld 在第二行添加export LD_PRELOAD=/usr/local/lib/libtcmalloc.so重启mysql结果竟然可以了。mysqld_sa 11022    root  mem       REG              253,0   2211536     276443 /usr/local/lib/libtcmalloc.so.0.3.0就这个问题饶了好几天啊。大家可以试下这个方法。
shz Email
2022-7-2 23:37
Thanks for the nice blog. It was very useful for me. I'm happy I found this blog. Thank you for sharing with us,I too always learn something new from your post.  Lead generation
shzz Email
2022-7-2 23:37
A good blog always comes-up with new and exciting information and while reading I have feel that this blog is really have all those quality that qualify a blog to be a one.  Lead generation
shzz Email
2022-7-2 23:41
Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.  Lead generation
shz Email
2022-7-2 23:42
Hello! I just wish to give an enormous thumbs up for the nice info you've got right here on this post. I will probably be coming back to your weblog for more soon!  Lead generation
shzz Email
2022-7-3 00:07
it's really cool blog. Linking is very useful thing.you have really helped  Lead generation
shz Email
2022-7-3 00:10
I must say, I thought this was a pretty interesting read when it comes to this topic. Liked the material. . . . .  Lead generation
shzz Email
2022-7-3 00:11
Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained!  Lead generation
shzz Email
2022-7-3 00:14
This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article.  Lead generation
shz Email
2022-7-3 00:15
Great survey. I'm sure you're getting a great response.  Lead generation
shz Email
2022-7-3 00:23
This website is remarkable information and facts it's really excellent  Lead generation
MNJHU Email
2022-9-7 10:34
I am leader mentor for the British affiliation of Physicians of Indian Origin (BAPIO) and feature designed, advanced and educated the mentors who're mentoring different medical doctors successfully.   Dr Rajeev Gupta BAPIO Yorkshire
CDFRG Email
2022-9-9 10:26
We additionally provide numerous translation alternatives to house your project`s scope and budget. If you're searching out powerful, proper translations that pressure your enterprise or comprehensive, turn-key translation management.   MTPE
分页: 3/4 第一页 上页 1 2 3 4 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]