Mysql/mariadb/percona Database Upgrade Scripts

Source: Internet
Author: User
Tags percona

mysql/mariadb/Percona Database Upgrade script intercepts upgrade_db.sh in Oneinstack, it is generally not recommended to upgrade the database version, this script is specifically provided to you version control. To prevent compatibility issues between large versions, scripts only support upgrades between the same large version by default, such as: MySQL-5.6.25 upgrade to MySQL-5.6.26, MySQL-5.5.44 upgrade to MySQL-5.5.45, MariaDB-10.0.20 upgrade to MariaDB-10.0.21, cannot cross a branch version and cannot span a large version, such as upgrading from MySQL-5.5.44 to perconal-5.5.44-37.3, MySQL-5.5.44 to MySQL-5.6.25.

How does the version support database version upgrade before 2015-07-16?
"Oneinstack" :

CP Oneinstack/Options.Conf./ #备份options. confRm-RF Oneinstack#删除旧版wget http://Mirrors.linuxeye./oneinstack-fulltar. #下载最新版 tar xzf oneinstack-fulltar./bin/MV options.< Span class= "PLN" >conf ./oneinstack  #还原options. conf, Must use legacy options.conf files CD oneinstack./upgrade db  #升级数据库版本               

"Lnmp one-Touch installation package":

CP LNMP/Options.Conf./ #备份options. confRm-RF LNMP#删除旧版wget http://Mirrorslinuxeye./lnmp-full.tar. #下载最新版 tar xzf lnmp-full tar./bin/MV options.< Span class= "PLN" >conf ./lnmp  #还原options. conf, Must use legacy options.conf files CD lnmp./upgrade db # Upgrade database version                 

Ps:
The contents of the Mysql/mariadb/percona Database upgrade script are as follows (Cat upgrade_db.sh):

#!/bin/bash# Author:yeho <lj2007331 at gmail.com># blog:http://blog.linuxeye.comupgrade_db(){CD $oneinstack _dir/Src[ ! -E"$db _install_dir/bin/mysql" ] &&Echo-E"\033[31mthe Mysql/mariadb/percona is not installed on your system!\033[0m" &&Exit1Db_version_tmp=' $db _install_dir/bin/mysql-v | awk ' {print $} ' | Awk-f, ' {print '} 'Db_tmp=' Echo $DB _version_tmp | Awk-f '-' {print $} 'If [ "$DB _tmp" == ' MariaDB ' ];ThenPublic_ip=`.. /functions/get_public_ip.py 'If [ "`.. /functions/get_ip_area.py $public _ip ' " == ' \U4E2D\U56FD ' ];ThenFlag_ip=CNFi[ "$FLAG _ip"X== "CN"X] &&Down_addr=http://Mirrors.Aliyun.Com/Mariadb||Down_addr=Https://Downloads.Mariadb.Org/F[ -D"/lib64" ] && {Sys_bit_a=x86_64;Sys_bit_b=x86_64; } || {Sys_bit_a=x86;Sys_bit_b=i686; }Libc_version=' Getconf-a | grep gnu_libc_version | awk ' {print $NF} 'Libc_yn=' Echo ' $LIBC _version < 2.14 "| BC '[$LIBC _yn== ' 1 ' ] &&Glibc_flag=Linux||Glibc_flag=Linux-Glibc_214db=MariaDBOld_db_version=' Echo $DB _version_tmp | Awk-f '-' {print '} 'Elif [ -N"$DB _tmp" -A"$DB _tmp" != ' MariaDB ' ];ThenDb=PerconaOld_db_version=$DB _version_tmpelsedb=mysqlold_db_version= $DB _version_tmpfi#backupwhile:d o $db _install_dir/bin/mysql-uroot-p${dbrootpwd}-E " Quit ">/dev/null 2>&1 if [$?-eq 0];then break else echo read-p" Please input the root password of database: "New_dbrootpwd $db _install_dir/bin/mysql-uroot-p${new_dbrootpwd}-E" Quit ">/dev/null 2>&1 if [$?] -eq 0];then dbrootpwd= $NEW _dbrootpwd sed-i "s+^dbrootpwd.*+dbrootpwd= ' $dbrootpwd ' +" ... /options.conf break Else echo-e "\033[31m$db root password incorrect,please Enter again! \033[0m "fi fidoneechoecho-e" \033[32mstarting $DB backup......\033[0m "$db _install_dir/bin/mysqldump-uroot-p${ DBROOTPWD}--opt--all-databases > db_all_backup_$ (date + "%y%m%d"). sql[-F "db_all_backup_$ (date +"%y%m%d "). SQL"] & amp;& echo-e "$DB backup success, backup file: \033[32m ' pwd '/db_all_backup_$ (date +"%y%m%d "). sql\033[0m" # Upgradeechoecho-e "Current $DB Version: \033[32m$old_db_version\033[0m" [-e/usr/local/lib/libtcmalloc.so] && {Je_tc_malloc=2; exe_linker= "-dcmake_exe_linker_flags= '-ltcmalloc '"; }[-e/usr/local/lib/libjemalloc.so] && {je_tc_malloc=1; exe_linker= "-dcmake_exe_linker_flags= '-ljemalloc '"; }while:d o echo read-p "Please input upgrade $DB Version (example:5.6.25):" Db_version if [' Echo $DB _version | Awk-f. ' {print $ '. "$ = =" Echo $Old _db_version | Awk-f. ' {print $ '. $ "]; thenif ["$DB" = = ' MariaDB '];thendb_name=mariadb-${db_version}-${glibc_flag}-${sys_bit_b}db_url= $DOWN _addr/ mariadb-${db_version}/bintar-${glibc_flag}-$SYS _bit_a/$DB _name.tar.gzelif ["$DB" = = ' Percona '];thendb_name= percona-server-$DB _versiondb_url=http://www.percona.com/redir/downloads/percona-server-' echo $DB _version | Awk-f. ' {print $ '. $ '/latest/source/tarball/$DB _name.tar.gzelif ["$DB" = = ' MySQL '];thendb_name=mysql-$DB _versiondb_url=http:// Cdn.mysql.com/downloads/mysql-' echo $DB _version | Awk-f. ' {print $ '. $ "/$DB _name.tar.gzfi [!-e" $DB _name.tar.gz "] && wget-c $DB _url >/dev/null 2>&1 if [-e] $DB _name.tar.gz "];then echo-e" Download \033[32m$db_name.tar.gz\033[0m successfully! "Else Echo-e" \03 3[31mit does not exist!\033[0m "fi break Else Echo-e" \033[31minput error!\033[0m * only input ' \033[32m${old_db_ver Sion%.*}.xx ' \033[0m "Fidoneif [-E" $DB _name.tar.gz "];then echo-e" \033[32m$db_name.tar.gz\033[0m [found] "echo" Press CTRL + C to cancel or press any key to continue ... "char= ' Get_char ' if [" $DB "= = ' MariaDB '];then service mysqld stopmv ${db _install_dir}{,_old_ ' date + "%y%m%d" '}mv ${db_data_dir}{,_old_ ' date + "%y%m%d" '}mkdir-p $db _data_dir;chown Mysql.mysql-r $db _data_dirtar xzf $DB _name.tar.gz[!-d "$db _install_dir"] && mkdir-p $db _INSTALL_DIRMV mariadb -${db_version}-linux-${sys_bit_b}/* $db _install_dirif ["$je _tc_malloc" = = ' 1 '];then sed-i ' [email protected] [ Email protected] Mysqld_safe\nexport ld_preload=/usr/local/lib/[email protected] ' $db _install_dir/bin/ Mysqld_safeelif ["$je _tc_malloc" = = ' 2 '];then sed-i ' [email protected] [email protected] Mysqld_safe\nexport ld_preload=/usr/local/lib/[email  Protected] ' $db _install_dir/bin/mysqld_safefi$db_install_dir/scripts/mysql_install_db--user=mysql--basedir= $db _ Install_dir--datadir= $db _data_dirchown mysql.mysql-r $db _data_dirservice mysqld Start$db_install_dir/bin/mysql < db_all_backup_$ (date + "%y%m%d"). SQL Service Mysqld Restart$db_install_dir/bin/mysql-uroot-p${dbrootpwd}-E "drop Database test; ">/dev/null 2>&1$db_install_dir/bin/mysql-uroot-p${dbrootpwd}-E" reset master; ">/dev/ Null 2>&1 [$?-eq 0] && echo-e "You had \033[32m$db successfully\033[0m upgrade from \033[32m$old_db_ve rsion\033[0m to \033[32m$db_version\033[0m "elif [" $DB "= = ' Percona '];thentar zxf $DB _name.tar.gz cd $DB _namemake cleanif ["' Echo $DB _version | Awk-f. ' {print $ '. $ "" "= = ' 5.5 '];thencmake. -dcmake_install_prefix= $db _install_dir-dmysql_datadir= $db _data_dir-dsysconfdir=/etc-dwith_innobase_storage_enGine=1-dwith_partition_storage_engine=1-dwith_federated_storage_engine=1-dwith_blackhole_storage_engine=1- Dwith_myisam_storage_engine=1-dwith_archive_storage_engine=1-dwith_readline=1-denable_dtrace=0-denabled_local_ Infile=1-ddefault_charset=utf8mb4-ddefault_collation=utf8mb4_general_ci $EXE _linkerelsecmake. -dcmake_install_prefix= $db _install_dir-dmysql_datadir= $db _data_dir-dsysconfdir=/etc-dwith_innobase_storage_ Engine=1-dwith_partition_storage_engine=1-dwith_federated_storage_engine=1-dwith_blackhole_storage_engine=1- Dwith_myisam_storage_engine=1-dwith_archive_storage_engine=1-denabled_local_infile=1-denable_dtrace=0-ddefault _charset=utf8mb4-ddefault_collation=utf8mb4_general_ci $EXE _linkerfimake-j ' grep processor/proc/cpuinfo | Wc-l ' service mysqld stopmv ${db_install_dir}{,_old_ ' date + '%y%m%d ' '} mv ${db_data_dir}{,_old_ ' date + '%y%m%d ' '}[!-d ' $d B_install_dir "] && mkdir-p $db _install_dir mkdir-p $db _data_dir;chown mysql.mysql-r $db _data_dirmakeinstall$db_install_dir/scripts/mysql_install_db--user=mysql--basedir= $db _install_dir--datadir= $db _data_dir Chown mysql.mysql-r $db _data_dir service mysqld Start$db_install_dir/bin/mysql < db_all_backup_$ (date + "%y%m%d"). SQL Service Mysqld Restart$db_install_dir/bin/mysql-uroot-p${dbrootpwd}-E "drop database test;" >/dev/null 2>&am P;1$DB_INSTALL_DIR/BIN/MYSQL-UROOT-P${DBROOTPWD}-e "reset master;" >/dev/null 2>&1 [$?-EQ 0] && EC Ho-e "You had \033[32m$db successfully\033[0m upgrade from \033[32m$old_db_version\033[0m to \033[32m$db_version\033[ 0m "elif [" $DB "= = ' MySQL '];thentar zxf $DB _name.tar.gz cd $DB _name make clean if [" ' Echo $DB _version | Awk-f. ' {print $ '. $ "" "= = ' 5.5 '];then cmake. -dcmake_install_prefix= $db _install_dir-dmysql_datadir= $db _data_dir-dsysconfdir=/etc-dwith_innobase_storage_ Engine=1-dwith_partition_storage_engine=1-dwith_federated_storage_engine=1-dwith_blackhole_storage_engine=1- Dwith_myisam_storage_engine=1-dwith_archive_storage_engine=1-dwith_readline=1-denabled_local_infile=1-denable_dtrace=0-ddefault_charset= Utf8mb4-ddefault_collation=utf8mb4_general_ci-dwith_embedded_server=1 $EXE _linker Else CMake. -dcmake_install_prefix= $db _install_dir-dmysql_datadir= $db _data_dir-dsysconfdir=/etc-dwith_innobase_storage_ Engine=1-dwith_partition_storage_engine=1-dwith_federated_storage_engine=1-dwith_blackhole_storage_engine=1- Dwith_myisam_storage_engine=1-denabled_local_infile=1-denable_dtrace=0-ddefault_charset=utf8mb4-ddefault_ Collation=utf8mb4_general_ci-dwith_embedded_server=1 $EXE _linker fimake-j ' grep processor/proc/cpuinfo | Wc-l ' service mysqld stop MV ${db_install_dir}{,_old_ ' date + '%y%m%d ' '} mv ${db_data_dir}{,_old_ ' date + '%y%m%d ' '} [!-d ' $ Db_install_dir "] && mkdir-p $db _install_dir mkdir-p $db _data_dir;chown mysql.mysql-r $db _data_dir make install $db _install_dir/scripts/mysql_install_db--user=mysql--basedir= $db _install_dir--datadir= $db _data_dir chown mYsql.mysql-r $db _data_dir Service mysqld start $db _install_dir/bin/mysql < db_all_backup_$ (date + "%y%m%d"). sql Service Mysqld Restart$db_install_dir/bin/mysql-uroot-p${dbrootpwd}-E "drop database test;" >/dev/null 2>&1 $db _install_dir/bin/mysql-uroot-p${dbrootpwd}-E "reset master;" >/dev/null 2>&1 [$?-eq 0] && Echo -E "You had \033[32m$db successfully\033[0m upgrade from \033[32m$old_db_version\033[0m to \033[32m$db_version\033[0m" Fi fi}

Original: https://blog.linuxeye.com/424.html

Mysql/mariadb/percona Database Upgrade Scripts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.