将 MariaDB 10.1 升级到 10.3
首先让我们检查安装的 MariaDB 的当前版本。
[jack@onitroad ~]# mysql -V mysql Ver 15.1 Distrib 10.1.36-MariaDB, for Linux (x86_64) using readline 5.1
正如我们在这里看到的,我们正在运行 MariaDB 10.1.36.
这是从我前段时间创建的存储库安装的,如下所示。
[jack@onitroad ~]# cat /etc/yum.repos.d/mariadb.repo # http://mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = https://yum.mariadb.org/10.1/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
现在只需使用我们喜欢的文本编辑器编辑我们用于 MariaDB 的 .repo 文件并将 10.1 更改为 10.3.
在这种情况下,baseurl 行在编辑后将如下所示。
baseurl = https://yum.mariadb.org/10.3/centos7-amd64
现在要升级 MariaDB,请运行“yum update”命令。
如果这不能为 MariaDB 软件包提供更新,请运行“yum clean all”,然后重试。
在我的服务器上,这开始将 MariaDB-client、MariaDB-common、MariaDB-server 和 MariaDB-shared 包更新到当前最新的 10.3.10 版本。
除了 MariaDB-server 失败之外,所有软件包都成功更新。
Failed: MariaDB-server.x86_64 0:10.0.29-1.el7.centos
之后会记录以下信息:
** A MySQL or MariaDB server package (MariaDB-server-10.1.36-1.el7.centos.x86_64) is installed. Upgrading directly from MySQL 10.1 to MariaDB 10.3 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 MariaDB Foundation - 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. ** error: %pre(MariaDB-server-10.3.10-1.el7.centos.x86_64) scriptlet failed, exit status 1 Error in PREIN scriptlet in rpm package MariaDB-server-10.3.10-1.el7.centos.x86_64 MariaDB-server-10.1.36-1.el7.centos.x86_64 was supposed to be removed but is not! Verifying : MariaDB-server-10.1.36-1.el7.centos.x86_64 1/2 Verifying : MariaDB-server-10.3.10-1.el7.centos.x86_64 2/2 Failed: MariaDB-server.x86_64 0:10.1.36-1.el7.centos MariaDB-server.x86_64 0:10.3.10-1.el7.centos
手动更新
所以基本上我们需要手动完成这个过程。
这可以通过按此顺序运行以下命令来完成。
请注意,按照建议,我们应该在继续之前首先备份所有数据库,并按照上面的输出中的建议复制 /etc/my.cnf 文件。
systemctl stop mariadb yum remove MariaDB-server yum install MariaDB-server systemctl start mariadb mysql_upgrade -u root -p
这将停止 MariaDB,删除旧的 10.1 包,根据之前的存储库更新安装较新的 10.3 版本的包,启动 MariaDB,然后运行升级脚本。
我们需要为运行升级时指定的用户输入密码。
[jack@onitroad ~]# mysql_upgrade -u root -p Enter password: Phase 1/7: Checking and upgrading mysql database Processing databases mysql mysql.column_stats OK ... SNIP ...
升级需要大约 10 秒才能完成,大约 10 个数据库的总大小都小于 500MB,因为检查内容的兼容性请注意,这部分的时间可能因数据库而异。
现在,如果我们再次检查我们的 MariaDB 版本,我们可以看到已成功升级到 10.1.
[jack@onitroad ~]# mysql -V mysql Ver 15.1 Distrib 10.3.10-MariaDB, for Linux (x86_64) using readline 5.1
本简短教程将向我们展示如何在 CentOS 7 Linux 中将 MariaDB 10.1 升级到 10.3.
我们将首先修改存储库文件并执行“yum update”。
这可能无法自动更新 MariaDB-server 包,因此将介绍如何手动使用 mysql_upgrade 脚本来完成该过程。