2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 23:18:43 +08:00

feat: 优化部分软件多线程编译参数

This commit is contained in:
耗子
2023-11-21 11:13:14 +08:00
parent bb9f629b8e
commit b4ea470099
9 changed files with 110 additions and 53 deletions

View File

@@ -29,8 +29,12 @@ mysqlVersion=""
mysqlPassword=$(cat /dev/urandom | head -n 16 | md5sum | head -c 16)
cpuCore=$(cat /proc/cpuinfo | grep "processor" | wc -l)
source ${setupPath}/panel/scripts/calculate_j.sh
j=$(calculate_j)
if [[ "${1}" == "80" ]]; then
mysqlVersion="8.0.35"
j=$(calculate_j2)
elif [[ "${1}" == "57" ]]; then
mysqlVersion="5.7.44"
else
@@ -39,12 +43,6 @@ else
exit 1
fi
if [[ "${memTotal}" -lt "4096" ]] && [[ "${1}" == "80" ]]; then
echo -e $HR
echo "错误:这点内存(${memTotal}M)还想装 MySQL 8.0?洗洗睡吧!"
exit 1
fi
# 安装依赖
if [ "${OS}" == "centos" ]; then
dnf makecache -y
@@ -125,11 +123,7 @@ if [ "$?" != "0" ]; then
exit 1
fi
if [[ "${cpuCore}" -gt "1" ]]; then
make -j2
else
make
fi
make "-j${j}"
if [ "$?" != "0" ]; then
echo -e $HR
echo "错误MySQL 编译失败,请截图错误信息寻求帮助。"
@@ -394,6 +388,9 @@ systemctl enable mysqld
systemctl start mysqld
${mysqlPath}/bin/mysqladmin -u root password ${mysqlPassword}
${mysqlPath}/bin/mysql -uroot -p${mysqlPassword} -e "DROP DATABASE test;"
${mysqlPath}/bin/mysql -uroot -p${mysqlPassword} -e "DELETE FROM mysql.user WHERE user='';"
${mysqlPath}/bin/mysql -uroot -p${mysqlPassword} -e "FLUSH PRIVILEGES;"
panel writePlugin mysql${1} ${mysqlVersion}
panel writeMysqlPassword ${mysqlPassword}

View File

@@ -26,11 +26,15 @@ downloadUrl="https://jihulab.com/haozi-team/download/-/raw/main/panel/mysql"
setupPath="/www"
mysqlPath="${setupPath}/server/mysql"
mysqlVersion=""
mysqlPassword=$(cat /dev/urandom | head -n 16 | md5sum | head -c 16)
mysqlPassword=$(panel getSetting mysql_root_password)
cpuCore=$(cat /proc/cpuinfo | grep "processor" | wc -l)
source ${setupPath}/panel/scripts/calculate_j.sh
j=$(calculate_j)
if [[ "${1}" == "80" ]]; then
mysqlVersion="8.0.35"
j=$(calculate_j2)
elif [[ "${1}" == "57" ]]; then
mysqlVersion="5.7.44"
else
@@ -39,12 +43,6 @@ else
exit 1
fi
if [[ "${memTotal}" -lt "4096" ]] && [[ "${1}" == "80" ]]; then
echo -e $HR
echo "错误:这点内存(${memTotal}M)还想装 MySQL 8.0?洗洗睡吧!"
exit 1
fi
# 安装依赖
if [ "${OS}" == "centos" ]; then
dnf makecache -y
@@ -60,11 +58,8 @@ else
exit 1
fi
mysqlUserCheck=$(cat /etc/passwd | grep mysql)
if [ "${mysqlUserCheck}" == "" ]; then
groupadd mysql
useradd -s /sbin/nologin -g mysql mysql
fi
# 停止已有服务
systemctl stop mysqld
# 准备目录
cd ${mysqlPath}
@@ -100,7 +95,7 @@ rm -f openssl-1.1.1u.tar.gz.checksum.txt
mv openssl-1.1.1u openssl
cd openssl
./config --prefix=/usr/local/openssl-1.1 --openssldir=/usr/local/openssl-1.1
make -j$(nproc)
make "-j${j}"
make install
echo "/usr/local/openssl-1.1/lib" > /etc/ld.so.conf.d/openssl-1.1.conf
ldconfig
@@ -118,20 +113,13 @@ if [ "$?" != "0" ]; then
exit 1
fi
if [[ "${cpuCore}" -gt "1" ]]; then
make -j2
else
make
fi
make "-j${j}"
if [ "$?" != "0" ]; then
echo -e $HR
echo "错误MySQL 编译失败,请截图错误信息寻求帮助。"
exit 1
fi
# 停止已有服务
systemctl stop mysqld
# 安装
make install
if [ "$?" != "0" ]; then
@@ -146,8 +134,13 @@ chmod -R 755 ${mysqlPath}
chmod 644 ${mysqlPath}/conf/my.cnf
# 启动服务
systemctl daemon-reload
systemctl enable mysqld
systemctl start mysqld
# 执行更新后的初始化
${mysqlPath}/bin/mysql -uroot -p${mysqlPassword} -e "DROP DATABASE test;"
${mysqlPath}/bin/mysql -uroot -p${mysqlPassword} -e "DELETE FROM mysql.user WHERE user='';"
${mysqlPath}/bin/mysql -uroot -p${mysqlPassword} -e "FLUSH PRIVILEGES;"
${mysqlPath}/bin/mysql_upgrade -uroot -p${mysqlPassword} --force
panel writePlugin mysql${1} ${mysqlVersion}