Mariadb版本升级的一些事儿
1.概述
鉴于业务需要,数据库需要升级。如果数据库不大,可以先导出数据,再卸载原来的数据库,再安装新的数据库,最后导入数据,如果数据库很大,那将会是灾难。其实完全没必要,只需卸载原来的数据库,备份好配置文件,再安装成自己需要的版本即可。笔者源数据库版本为mariadb 5.5.52,要升级到5.6,其实mariadb并没有5.6这个版本,代之的是10.0。故而,本次升级,是将数据库版本由5.5.52升级到10.0的最新版本,即10.0.32。目前最新的版本是10.3。
2.添加需要升级版本的repo库
# MariaDB 10.0 CentOS repository list – created 2014-10-13 13:04 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
其中http://yum.mariadb.org/10.0/centos7-amd64是对应版本的repo路径,根据需要选择适合自己的版本。
为了能正确升级到选择的版本,可先警用默认的repo源
mv CentOS-Base.repo CentOS-Base.repo.bak
3.卸载掉原来的版本
查看数据库版本
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 16094
Server version: 5.5.52-MariaDB-log MariaDB Server
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
暂停数据库
systemctl stop mariadb.service
查看需要卸载的数据包
rpm -qa|grep mariadb
mariadb-server-5.5.52-1.el7.x86_64
mariadb-libs-5.5.52-1.el7.x86_64
mariadb-5.5.52-1.el7.x86_64
卸载数据库
yum remove mariadb-server mariadb mariadb-libs
清空缓存
yum clean all
生成缓存
yum makecache
4.安装新版本
yum -y install mariadb-server mariadb-client
卸载数据库时,会将源配置文件存储在/etc/my.cnf.rpmsave中,如果不放心,可以备份配置文件
用备份的配置文件替换新的配置文件
rm -rf /etc/my.cnf
mv /etc/my.cnf.rpmsave /etc/my.cnf
5.启动数据库
systemctl start mariadb.service
如果没有生成mariadb.service,可以通过/etc/init.d/mysql start启动,或者制作systemctl启动
制作systemctl启动见:http://www.jianshu.com/p/78e3b024fb8e
6.检验数据库版本
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 20
Server version: 10.0.32-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
升级成功!
7.遇到的问题
如果在升级过程中,遇到数据库启动失败,可根据错误日志逐一排查,笔者将遇到错误罗列如下。
错误日志如下:
170831 9:30:10 [ERROR] Plugin 'InnoDB' init function returned error.
170831 9:30:10 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
170831 9:30:10 [Note] Plugin 'FEEDBACK' is disabled.
170831 9:30:10 [ERROR] Unknown/unsupported storage engine: InnoDB
170831 9:30:10 [ERROR] Aborting
解决办法:
删除datadir目录下的ib_logfile0和ib_logfile1两个文件即可。
参考地址:
http://blog.csdn.net/iastro/article/details/52047227
yum源http://yum.mariadb.org/
http://ilgnep.iteye.com/blog/705830