32位系统静态编译TCMalloc到Mysql5.1.51(Linux CentOS 5.5)
时间:2015-03-09 23:05 来源:linux.it.net.cn 作者:IT
下载google-perftools-1.6.tar.gz
wget http://google-perftools.googlecode.com/files/google-perftools-1.6.tar.gz
tar zxvf google-perftools-1.6.tar.gz
执行./configure
make && make install
ldconfig
可以看到/usr/local/lib下出现了以libtcmalloc开头的so文件
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
/sbin/ldconfig
安装mysql5.1.51
要执行的预编译指令
CFLAGS="-O3"
CXX=g++
CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti"
-
yum install gcc
-
yum install gcc-c++
-
-
groupadd mysql
-
useradd --shell /sbin/nologin -g mysql mysql
-
tar zxvf mysql-5.1.51.tar.gz
-
cd mysql-5.1.51
-
mkdir -p /usr/local/mysql/data
-
./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charsets=gbk,gb2312,latin1,binary --without-docs --with-mysqld-user=mysql --localstatedir=/usr/local/mysql/data --with-big-tables --without-ndb-debug --with-pthread --enable-assembler --with-mysqld-ldflags=-all-static --with-mysqld-ldflags=-ltcmalloc --with-client-ldflags=-all-static --enable-thread-safe-client
-
make
-
make install
-
-
cp support-files/my-medium.cnf /etc/my.cnf
-
cp support-files/mysql.server /etc/init.d/mysql
-
chmod u+x /etc/init.d/mysql
-
-
cd /usr/local/mysql
-
bin/mysql_install_db --user=mysql
-
chown -R root .
-
chown -R mysql data
-
chgrp -R mysql .
-
-
chkconfig --add mysql
-
chkconfig --level 345 mysql on
-
bin/mysqld_safe --user=mysql &
-
service mysql restart
-
-
ln -s /usr/local/mysql/bin/mysql /sbin/mysql
-
ln -s /usr/local/mysql/bin/mysqladmin /sbin/mysqladmin
-
mysqladmin -uroot password "yourpassword"
修改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
在 CentOS 5.5 下编译安装MySQL时出错:
/bin/rm: cannot remove `libtoolT': No such file or directory
解决方法是:
在执行./configure 之前,先执行:
# yum install automake autoconf libtool
# autoreconf --force --install
# libtoolize --automake --force
# automake --force --add-missing
正确运行以上命令后在执行./configure进行编译即可
(责任编辑:IT)
下载google-perftools-1.6.tar.gz wget http://google-perftools.googlecode.com/files/google-perftools-1.6.tar.gz tar zxvf google-perftools-1.6.tar.gz 执行./configure make && make install ldconfig 可以看到/usr/local/lib下出现了以libtcmalloc开头的so文件
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
安装mysql5.1.51
要执行的预编译指令 CFLAGS="-O3" CXX=g++ CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti"
修改MySQL启动脚本(根据你的MySQL安装位置而定):
vi /usr/local/mysql/bin/mysqld_safe
在# executing mysqld_safe的下一行,加上:
export LD_PRELOAD=/usr/local/lib/libtcmalloc.so
保存后退出,然后重启MySQL服务器。
/usr/sbin/lsof -n | grep tcmalloc
如果发现以下信息,说明tcmalloc已经起效:
在 CentOS 5.5 下编译安装MySQL时出错: (责任编辑:IT) |