shell一键安装jemalloc
最近一直在搞mysql5.7,今天把jemalloc整合到mysql里了,写了个很简陋的脚本配合之前shell脚本一键自动安装mysql 5.7一起使用.
系统:centos 7.x(64位)
软件版本:mysql 5.7
jemalloc-4.5.0
脚本内容:
cat /root/soft_shell/auto_install_jemalloc.sh
#!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin:~/bin export PATH # Check if user is root if [ $(id -u) != "0" ]; then echo "Error: You must be root to run this script, please use root to install" exit 1 fi # Check the network status NET_NUM=`ping -c 4 www.baidu.com |awk '/packet loss/{print $6}' |sed -e 's/%//'` if [ -z "$NET_NUM" ] || [ $NET_NUM -ne 0 ];then echo "Please check your internet" exit 1 fi if [ -s /usr/local/mysql ];then echo -e "\033[40;31m mysql [found]\033[40;37m" else exit 1 fi if [ -s jemalloc-4.5.0.tar.bz2 ];then echo -e "\033[40;31m jemalloc [found]\033[40;37m" else wget http://download.slogra.com/tcmalloc/jemalloc-4.5.0.tar.bz2 fi yum -y install libaio libaio-devel bzip2 gcc gcc-c++ make tar jxf jemalloc-4.5.0.tar.bz2 cd jemalloc-4.5.0 ./configure make -j4 && make install echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf ldconfig sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' /usr/local/mysql/bin/mysqld_safe service mysqld restart #cd /root #lsof -n | grep jemalloc
[root@localhost soft_shell]# lsof -n | grep jemalloc
mysqld 23692 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23693 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23694 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23695 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23696 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23697 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23698 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23699 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23700 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23701 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23702 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23703 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23704 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23705 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23706 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23707 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23708 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23709 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23710 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23711 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23712 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23714 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23715 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23716 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23717 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23718 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23719 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23720 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23721 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23722 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23723 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23724 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23725 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23726 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
mysqld 23692 23728 mysql mem REG 253,1 2600702 203862106 /usr/local/lib/libjemalloc.so.2
如果出现以上内容,说明jemalloc优化mysql成功.
评论: