$ vi /usr/local/mysql/bin/mysqld_safe #!/bin/sh # Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB # This file is public domain and comes with NO WARRANTY of any kind # # Script to start the MySQL daemon and restart it if it dies unexpectedly # # This should be executed in the MySQL base directory if you are using a # binary installation that is not installed in its compile-time default # location # # mysql.server works by first doing a cd to the base directory and from there # executing mysqld_safe export LD_PRELOAD=/usr/local/lib/libtcmalloc.so
重启数据库
$ /etc/init.d/mysqld restart
查看tcmalloc是否应用
$ lsof |grep -i libtcmalloc.so mysqld 112616 mysql mem REG 253,0 2588008 1459281 /usr/local/lib/libtcmalloc.so.4.5.5 mysqld 112616 112618 mysql mem REG 253,0 2588008 1459281 /usr/local/lib/libtcmalloc.so.4.5.5 mysqld 112616 112619 mysql mem REG 253,0 2588008 1459281 /usr/local/lib/libtcmalloc.so.4.5.5 mysqld 112616 112620 mysql mem REG 253,0 2588008 1459281 /usr/local/lib/libtcmalloc.so.4.5.5