标题:
[教程]
WDCP升级mysql 8.0脚本,亲测可用 2021.01.26
[打印本页]
作者:
helen5106
时间:
2021-1-26 12:39
标题:
WDCP升级mysql 8.0脚本,亲测可用 2021.01.26
#!/bin/bash
# mysql 8.0 update scripts
# Author: wdlinux
# Url: http://www.wdlinux.cn
# Modify: windsage
IN_DIR="/www/wdlinux"
if [ ! $1 ];then
MYS_VER="8.0.11"
else
MYS_VER=$1
fi
echo "升级有风险 操作需谨慎"
echo "欢迎学习交流互助提高"
echo "qq:242013800"
echo
read -p "DO YOU REALLY WANT TO UPDATE? (Y/N): " yn
if [ "$yn" == "Y" ] || [ "$yn" == "y" ]; then
echo "MYSQL IS NOW UPDATING!"
else
exit
fi
echo
echo "-------------------------------------------------------------"
echo
if [ ! -f mysql-boost-${MYS_VER}.tar.gz ];then
# 因mysql5.7需要boost,所以这个直接是包含boost的源码包
wget -c https://downloads.mysql.com/archives/get/p/23/file/mysql-boost-${MYS_VER}.tar.gz
fi
yum install -y cmake bison libmcrypt-devel libjpeg-devel libpng-devel freetype-devel curl-devel openssl-devel libxml2-devel zip unzip
if [ ! -d $IN_DIR/mysql-${MYS_VER} ];then
mkdir -p $IN_DIR/mysql-${MYS_VER}
# 数据库文件夹默认要求是data
mkdir -p $IN_DIR/mysql-${MYS_VER}/data
fi
if [ ! -d mysql-${MYS_VER} ];then
tar zxvf mysql-boost-${MYS_VER}.tar.gz
fi
cd mysql-${MYS_VER}
echo "START CONFIGURING MYSQL"
sleep 3
#mkdir -p build
#cd build/
make clean
cmake \
-DFORCE_INSOURCE_BUILD=1 \
-DCMAKE_INSTALL_PREFIX=$IN_DIR/mysql-$MYS_VER \
-DSYSCONFDIR=$IN_DIR/etc \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_SSL=bundled \
-DWITH_DEBUG=OFF \
-DWITH_EXTRA_CHARSETS=complex \
-DENABLED_PROFILING=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_BOOST=./boost/boost_1_66_0/
[ $? != 0 ] && echo "NO! CONFIGURE ERROR! :(" && exit
echo "START MAKE"
sleep 3
make
[ $? != 0 ] && echo "NO! MAKE ERROR! :(" && exit
echo "START MAKE INSTALL"
sleep 3
make install
[ $? != 0 ] && echo "NO! MAKE INSTALL ERROR! :(" && exit
service mysqld stop
#cd ..
# 建立备份文件夹,这个可以自定义设置,建议一开始就先备份,不要问我为什么,这样可视化安全更放心
if [ ! -d /www/wdlinux/mysql_bk ];then
mkdir -p /www/wdlinux/mysql_bk
cp -pR /www/wdlinux/mysql/data/* /www/wdlinux/mysql_bk
fi
rm -f /www/wdlinux/mysql
ln -sf $IN_DIR/mysql-$MYS_VER /www/wdlinux/mysql
sh scripts/mysql_install_db.sh --user=mysql --basedir=/www/wdlinux/mysql --datadir=/www/wdlinux/mysql/data
chown -R mysql.mysql /www/wdlinux/mysql
chown -R mysql.mysql /www/wdlinux/mysql/data
mv /www/wdlinux/mysql/data/mysql /www/wdlinux/mysql/data/mysqlo
cp support-files/mysql.server /www/wdlinux/init.d/mysqld
chmod 755 /www/wdlinux/init.d/mysqld
service mysqld restart
ln -sf $IN_DIR/mysql/lib/libmysqlclient.so.20. /usr/lib/libmysqlclient.so.20
cd ..
rm -rf mysql-${Ver}/
# rm -rf mysql-${Ver}.tar.gz
sleep 2
service mysqld restart
sleep 2
mysqld --initialize --user=mysql --console
# 或者把备份的数据库复制回来,注意不要覆盖performance_schema
# cp -pR /mnt/mysql_bk/* /www/wdlinux/mysql/data/
echo
echo "-------------------------------------------------------------"
echo "数据库需要初始化,自动生成的密码会存入mysql的日志,默认在/var/log/mysql/error.log"
echo
echo "此时查看mysql日志,应该一切正常了,但新手朋友注意了,此时你的httpd无法启动了,需要编译安装php。"
echo
复制代码
注意,安装的事8.0.11, 如果是其他的,需要修改boost的文件夹名字,boost_1_66_0 这个地方,可以解压mysql后看看,可能是其他名字
作者:
helen5106
时间:
2021-1-27 15:51
遇到的问题
1. 内存不够容易卡死,增加swap文件
2. my.cnf有写参数错误,导致初始化错误,根据提示,删掉一些没用参数,把/www/wdlinux/mysql/data重新命名,然后重新初始化
mysqld --initialize --user=mysql --console --basedir=/www/wdlinux/mysql --datadir=/www/wdlinux/mysql/data
作者:
helen5106
时间:
2021-1-27 16:02
升级完mysql, 重新编译php
下面是php 7.3.26
#!/bin/bash
# PHP 7.1 update scripts
# Author: wdlinux
# Url: http://www.wdlinux.cn
# Modify: slrainy
if [ ! $1 ];then
Ver=7.3.26
else
Ver=$1
fi
echo "升级有风险 操作需谨慎"
echo "欢迎学习交流互助提高"
echo "qq:6824498"
echo "点击链接加入群(207118653)【lanmp php thinkphp5 交流】:https://jq.qq.com/?_wv=1027&k=45CsOTO"
echo
#read -p "PRESS ENTER IF YOU REALLY WANT TO UPDATE"
read -p "DO YOU REALLY WANT TO UPDATE? (Y/N): " yn
if [ "$yn" == "Y" ] || [ "$yn" == "y" ]; then
echo "PHP IS NOW UPDATING!"
else
exit
fi
echo
echo "-------------------------------------------------------------"
echo
###yum
yum clean all
yum install -y gcc gcc-c++ make autoconf libtool-ltdl-devel gd-devel freetype-devel libxml2-devel libjpeg-devel libpng-devel openssl-devel curl-devel patch libmcrypt-devel libmhash-devel ncurses-devel bzip2-devel libcap-devel gmp-devel t1lib-devel libc-client-devel sqlite-devel aspell-devel readline-devel recode-devel libtidy-devel libxslt-devel openldap-devel
ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
###
if [ ! -f php-${Ver}.tar.gz ];then
wget -c http://cn2.php.net/distributions/php-${Ver}.tar.gz
fi
if [ ! -f iconv_ins.sh ];then
wget -c http://down.wdlinux.cn/in/iconv_ins.sh
fi
sh iconv_ins.sh
###
if [ -f /www/wdlinux/mysql/lib/libmysqlclient.so.20 ];then
if [ -d /usr/lib64 ];then
LIBNCU="/usr/lib64"
else
LIBNCU="/usr/lib"
fi
ln -sf /www/wdlinux/mysql/lib/libmysqlclient.so.20 $LIBNCU
fi
if [ ! -f php-${Ver} ];then
tar zxvf php-${Ver}.tar.gz
fi
cd php-${Ver}
if [ -d /www/wdlinux/apache_php ];then
make clean
./configure \
--prefix=/www/wdlinux/apache_php-${Ver} \
--exec-prefix=/www/wdlinux/apache_php-${Ver} \
--bindir=/www/wdlinux/apache_php-${Ver}/bin \
--sbindir=/www/wdlinux/apache_php-${Ver}/sbin \
--libdir=/www/wdlinux/apache_php-${Ver}/lib/php \
--mandir=/www/wdlinux/apache_php-${Ver}/php/man \
--with-config-file-path=/www/wdlinux/apache_php-${Ver}/etc \
--with-apxs2=/www/wdlinux/apache/bin/apxs \
--with-mhash \
--with-openssl \
--with-mysqli=/www/wdlinux/mysql/bin/mysql_config \
--with-pdo-mysql=/www/wdlinux/mysql \
--with-gd \
--with-iconv \
--with-zlib \
--enable-zip \
--with-kerberos \
--with-pcre-regex \
--with-libxml-dir=/usr \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--enable-opcache \
--enable-fpm \
--without-gdbm \
--disable-fileinfo
[ $? != 0 ] && echo "configure err" && exit
make ZEND_EXTRA_LIBS='-liconv'
[ $? != 0 ] && echo "make err" && exit
make install
[ $? != 0 ] && echo "make install err" && exit
cp php.ini-production /www/wdlinux/apache_php-${Ver}/etc/php.ini
sed -i 's/short_open_tag = Off/short_open_tag = On/g' /www/wdlinux/apache_php-${Ver}/etc/php.ini
rm -f /www/wdlinux/apache_php
ln -sf /www/wdlinux/apache_php-${Ver} /www/wdlinux/apache_php
if [ ! -d /www/wdlinux/apache_php-${Ver}/lib/php/extensions ];then
mkdir -p /www/wdlinux/apache_php-${Ver}/lib/php/extensions/no-debug-zts-20131226
ln -sf /www/wdlinux/apache_php-${Ver}/lib/php/extensions/no-debug-zts-20131226 /www/wdlinux/apache_php-${Ver}/lib/php/extensions/no-debug-non-zts-20131226
fi
service httpd restart
echo
echo "如果升级后httpd无法启动,打开httpd.conf,注释 #LoadModule php5_module modules/libphp5.so"
echo "php update compelete"
fi
if [ -d /www/wdlinux/nginx_php ];then
make clean
./configure --prefix=/www/wdlinux/nginx_php-${Ver} --with-config-file-path=/www/wdlinux/nginx_php-${Ver}/etc --with-mysql=/www/wdlinux/mysql --with-iconv=/usr --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt=/usr --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-soap --with-imap --with-kerberos --with-imap-ssl --enable-ftp --enable-sockets --enable-zip --enable-fpm --with-mysqli=/www/wdlinux/mysql/bin/mysql_config --with-pdo-mysql=/www/wdlinux/mysql
[ $? != 0 ] && echo "configure err" && exit
make
[ $? != 0 ] && echo "make err" && exit
make install
[ $? != 0 ] && echo "make install err" && exit
cp php.ini-production /www/wdlinux/nginx_php-${Ver}/etc/php.ini
sed -i 's/short_open_tag = Off/short_open_tag = On/g' /www/wdlinux/nginx_php-${Ver}/etc/php.ini
service php-fpm stop
rm -f /www/wdlinux/nginx_php
ln -sf /www/wdlinux/nginx_php-${Ver} /www/wdlinux/nginx_php
cp /www/wdlinux/nginx_php-${Ver}/etc/php-fpm.conf.default /www/wdlinux/nginx_php-${Ver}/etc/php-fpm.conf
sed -i 's/user = nobody/user = www/g' /www/wdlinux/nginx_php/etc/php-fpm.conf
sed -i 's/group = nobody/group = www/g' /www/wdlinux/nginx_php/etc/php-fpm.conf
sed -i 's/;pid =/pid =/g' /www/wdlinux/nginx_php/etc/php-fpm.conf
cp -f sapi/fpm/init.d.php-fpm /www/wdlinux/init.d/php-fpm
chmod 755 /www/wdlinux/init.d/php-fpm
if [ ! -d /www/wdlinux/nginx_php-${Ver}/lib/php/extensions ];then
mkdir -p /www/wdlinux/nginx_php-${Ver}/lib/php/extensions/no-debug-zts-20131226
ln -sf /www/wdlinux/nginx_php-${Ver}/lib/php/extensions/no-debug-zts-20131226 /www/wdlinux/nginx_php-${Ver}/lib/php/extensions/no-debug-non-zts-20131226
fi
service php-fpm start
echo
echo "php update is OK"
fi
echo
复制代码
作者:
helen5106
时间:
2021-1-27 16:03
php安装过程中, Lib可能出错,参考https://blog.csdn.net/zsl10/article/details/52143713
作者:
besthome
时间:
2021-3-31 23:40
可能还是每个服务器有其独特的情况吧,在wdcp下升级mysql,极少有顺利的。
mysql升级后,pid有问题,不想折腾,好在云服务器快照下,回滚了。
作者:
jotian
时间:
2021-6-25 19:01
我也是昨天折腾了一天,全报错,我是想升级到5.7.3.4,可能就如上面说的我没有设置boost_1_66_0
欢迎光临 WDlinux官方论坛 (http://wdlinux.cn/bbs/)
Powered by Discuz! 7.2