将 MariaDB 10.0 升级到 10.1
首先让我们检查安装的 MariaDB 的当前版本。
[jack@onitroad ~]# mysql -V mysql Ver 15.1 Distrib 10.0.29-MariaDB, for Linux (x86_64) using readline 5.1
正如我们在这里看到的,我们正在运行 MariaDB 10.0.29.
这是从我前段时间创建的存储库安装的,如下所示。
[jack@onitroad ~]# cat /etc/yum.repos.d/mariadb.repo # MariaDB 10.0 CentOS repository list - created 2014-05-01 13:50 UTC [mariadb] name = MariaDB baseurl = https://yum.mariadb.org/10.0/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
现在只需使用我们喜欢的文本编辑器编辑我们用于 MariaDB 的 .repo 文件并将 10.0 更改为 10.1.
在这种情况下,baseurl 行在编辑后将如下所示。
baseurl = https://yum.mariadb.org/10.1/centos7-amd64
现在要升级 MariaDB,请运行“yum update”命令。
如果这不能为 MariaDB 软件包提供更新,请运行“yum clean all”,然后重试。
在我的服务器上,这开始将 MariaDB-client、MariaDB-common、MariaDB-server 和 MariaDB-shared 包更新到 10.1.21 版本。
除了 MariaDB-server 失败之外,所有软件包都成功更新。
Failed: MariaDB-server.x86_64 0:10.0.29-1.el7.centos
之后会记录以下信息:
** A MySQL or MariaDB server package (MariaDB-server-10.0.29-1.el7.centos.x86_64) is installed. Upgrading directly from MySQL 10.0 to MariaDB 10.1 may not be safe in all cases. A bananaal dump and restore using mysqldump is recommended. It is important to review the MariaDB bananaal's Upgrading section for version-specific incompatibilities. A bananaal upgrade is required. - Ensure that you have a complete, working backup of your data and my.cnf files - Shut down the MySQL server cleanly - Remove the existing MySQL packages. Usually this command will list the packages you should remove: rpm -qa | grep -i '^mysql-' You may choose to use 'rpm --nodeps -ev ' to remove the package which contains the mysqlclient shared library. The library will be reinstalled by the MariaDB-shared package. - Install the new MariaDB packages supplied by Monty Program AB - Ensure that the MariaDB server is started - Run the 'mysql_upgrade' program This is a brief description of the upgrade process. Important details can be found in the MariaDB bananaal, in the Upgrading section. **
手动更新
所以基本上我们需要手动完成这个过程。
这可以通过按此顺序运行以下命令来完成。
请注意,按照建议,我们应该先备份所有数据库,然后再继续。
systemctl stop mysql yum remove MariaDB-server yum install MariaDB-server systemctl start mysql mysql_upgrade -u root -p
这将停止 MariaDB,删除 10.0 包,根据之前的存储库更新安装 10.1 版本的包,启动 MariaDB,然后运行升级脚本。
我们需要为运行升级时指定的用户输入密码。
升级需要大约 15 秒才能完成大约 8 个数据库,所有这些数据库的总大小都小于 300MB,因为检查内容的兼容性请注意,这部分的时间可能因数据库而异。
现在,如果我们再次检查我们的 MariaDB 版本,我们可以看到我们已成功升级到 10.1.
[jack@onitroad ~]# mysql -V mysql Ver 15.1 Distrib 10.1.21-MariaDB, for Linux (x86_64) using readline 5.1
本教程将介绍如何在 CentOS 7 Linux 中将 MariaDB 10.0 升级到 10.1.