加快mysql编译

This commit is contained in:
midoks
2022-08-01 11:00:48 +08:00
parent f2d0de91f8
commit 7cb819b25f
4 changed files with 65 additions and 8 deletions
+15 -2
View File
@@ -31,7 +31,20 @@ Install_mysql()
if [ "$sysName" != "Darwin" ];then
mkdir -p /var/log/mariadb
touch /var/log/mariadb/mariadb.log
fi
fi
if [ -z "${cpuCore}" ]; then
cpuCore="1"
fi
MEM_INFO=$(free -m|grep Mem|awk '{printf("%.f",($2)/1024)}')
if [ "${cpuCore}" != "1" ] && [ "${MEM_INFO}" != "0" ];then
if [ "${cpuCore}" -gt "${MEM_INFO}" ];then
cpuCore="${MEM_INFO}"
fi
else
cpuCore="1"
fi
if [ ! -f ${mysqlDir}/mysql-5.5.62.tar.gz ];then
wget -O ${mysqlDir}/mysql-5.5.62.tar.gz --tries=3 https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.62.tar.gz
@@ -58,7 +71,7 @@ Install_mysql()
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DCMAKE_C_COMPILER=/usr/bin/gcc \
-DCMAKE_CXX_COMPILER=/usr/bin/g++
make && make install && make clean
make -j${cpuCore} && make install && make clean
if [ -d $serverPath/mysql ];then
echo '5.5' > $serverPath/mysql/version.pl
+15 -2
View File
@@ -34,7 +34,20 @@ Install_mysql()
if [ "$sysName" != "Darwin" ];then
mkdir -p /var/log/mariadb
touch /var/log/mariadb/mariadb.log
fi
fi
if [ -z "${cpuCore}" ]; then
cpuCore="1"
fi
MEM_INFO=$(free -m|grep Mem|awk '{printf("%.f",($2)/1024)}')
if [ "${cpuCore}" != "1" ] && [ "${MEM_INFO}" != "0" ];then
if [ "${cpuCore}" -gt "${MEM_INFO}" ];then
cpuCore="${MEM_INFO}"
fi
else
cpuCore="1"
fi
if [ ! -f ${mysqlDir}/mysql-5.6.50.tar.gz ];then
@@ -73,7 +86,7 @@ Install_mysql()
$OPTIONS \
-DCMAKE_C_COMPILER=/usr/bin/gcc \
-DCMAKE_CXX_COMPILER=/usr/bin/g++
make && make install && make clean
make -j${cpuCore} && make install && make clean
if [ -d $serverPath/mysql ];then
+14 -1
View File
@@ -38,6 +38,19 @@ Install_mysql()
touch /var/log/mariadb/mariadb.log
fi
if [ -z "${cpuCore}" ]; then
cpuCore="1"
fi
MEM_INFO=$(free -m|grep Mem|awk '{printf("%.f",($2)/1024)}')
if [ "${cpuCore}" != "1" ] && [ "${MEM_INFO}" != "0" ];then
if [ "${cpuCore}" -gt "${MEM_INFO}" ];then
cpuCore="${MEM_INFO}"
fi
else
cpuCore="1"
fi
cd $serverPath/mdserver-web/plugins/mysql/lib && /bin/bash rpcgen.sh
if [ ! -f ${mysqlDir}/mysql-boost-${VERSION}.tar.gz ];then
@@ -90,7 +103,7 @@ Install_mysql()
-DCMAKE_C_COMPILER=/usr/bin/gcc \
-DCMAKE_CXX_COMPILER=/usr/bin/g++ \
-DWITH_BOOST=${mysqlDir}/mysql-${VERSION}/boost/
make && make install && make clean
make -j${cpuCore} && make install && make clean
if [ -d $serverPath/mysql ];then
echo '5.7' > $serverPath/mysql/version.pl
+21 -3
View File
@@ -75,6 +75,19 @@ Install_mysql()
useradd -g mysql mysql
fi
if [ -z "${cpuCore}" ]; then
cpuCore="1"
fi
MEM_INFO=$(free -m|grep Mem|awk '{printf("%.f",($2)/1024)}')
if [ "${cpuCore}" != "1" ] && [ "${MEM_INFO}" != "0" ];then
if [ "${cpuCore}" -gt "${MEM_INFO}" ];then
cpuCore="${MEM_INFO}"
fi
else
cpuCore="1"
fi
cd $serverPath/mdserver-web/plugins/mysql/lib && /bin/bash rpcgen.sh
INSTALL_CMD=cmake
@@ -120,9 +133,13 @@ Install_mysql()
WHERE_DIR_GCC=/usr/bin/gcc
WHERE_DIR_GPP=/usr/bin/g++
if [ "$OSNAME" == "centos" ] && [ "$VERSION_ID" == "7" ];then
yum install centos-release-scl -y
yum install devtoolset-7 -y
# yum install centos-release-scl -y
# yum install devtoolset-7 -y
# scl enable devtoolset-7 bash
yum install centos-release-scl-rh -y
yum install devtoolset-7-gcc devtoolset-7-gcc-c++ -y
# yum install cmake3 -y
gcc --version
WHERE_DIR_GCC=/opt/rh/devtoolset-7/root/usr/bin/gcc
WHERE_DIR_GPP=/opt/rh/devtoolset-7/root/usr/bin/g++
@@ -141,6 +158,7 @@ Install_mysql()
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
@@ -150,7 +168,7 @@ Install_mysql()
-DCMAKE_C_COMPILER=$WHERE_DIR_GCC \
-DCMAKE_CXX_COMPILER=$WHERE_DIR_GPP \
-DWITH_BOOST=${mysqlDir}/mysql-${VERSION}/boost/
make && make install && make clean
make -j${cpuCore} && make install && make clean
if [ -d $serverPath/mysql ];then
echo '8.0' > $serverPath/mysql/version.pl