CentOS7环境下MySQL5.7升级至MariaDB10.6失败求助
问题:CentOS7下通过WHM从MySQL5.7升级MariaDB10.6遇404错误
近期MariaDB官方仓库出现失效问题,在CentOS7环境下通过WHM的“Upgrade MySQL/MariaDB database”功能从MySQL5.7升级至MariaDB10.6时,遭遇404 Not Found错误。具体表现为:
- 手动修改
/etc/yum.repos.d/下的repo配置文件baseurl后,执行WHM升级时会被自动还原 - 通过
yum --add-repo添加并启用MariaDB10.6仓库,WHM升级流程仍会查找已失效的MariaDB10.2仓库 - 即使手动禁用MariaDB10.2仓库,升级时也会被自动重新启用
控制台错误日志
Restarting mysql service. (XID ehvnfq) The “mysql” service is disabled. The system was not able to ensure the availability of the “MariaDB-client” package: (XID httqu8) “/usr/bin/yum” reported error code “1” when it ended: https://yum.mariadb.org/10.2/centos7-amd64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found Trying other mirror. To address this issue please refer to the below wiki article https://wiki.centos.org/yum-errors If above article doesn't help to resolve this issue please use https://bugs.centos.org/. One of the configured repositories failed (MariaDB102), and yum doesn't have enough cached data to continue. At this point the only safe thing yum can do is fail. There are a few ways to work "fix" this: 1. Contact the upstream for the repository and get them to fix the problem. 2. Reconfigure the baseurl/etc. for the repository, to point to a working upstream. This is most often useful if you are using a newer distribution release than is supported by the repository (and the packages for the previous distribution release still work). 3. Run the command with the repository temporarily disabled yum --disablerepo=MariaDB102 ... 4. Disable the repository permanently, so yum won't use it by default. Yum will then just ignore the repository until you permanently enable it again or use --enablerepo for temporary usage: yum-config-manager --disable MariaDB102 or subscription-manager repos --disable=MariaDB102 5. Configure the failing repository to be skipped, if it is unavailable. Note that yum will try to contact the repo. when it runs most commands, so will have to try and fail each time (and thus. yum will be be much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=MariaDB102.skip_if_unavailable=true failure: repodata/repomd.xml from MariaDB102: [Errno 256] No more mirrors to try. https://yum.mariadb.org/10.2/centos7-amd64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
可行解决思路
方法1:通过WHM手动指定MariaDB版本仓库
WHM的MySQL升级工具会自动管理repo配置,需在WHM内直接锁定目标版本:
- 登录WHM,进入
Software > MySQL/MariaDB Upgrade页面 - 在“Choose a MySQL/MariaDB version”选项中,直接选择MariaDB 10.6
- 点击“Continue”后,WHM会自动生成对应版本的合法repo配置,无需手动修改yum文件
方法2:替换WHM默认的MariaDB repo模板
WHM会从内部模板生成repo配置,可手动替换模板强制指定10.6版本:
- 备份原模板文件:
cp /var/cpanel/templates/yum/repos.d/MariaDB102.tmpl /var/cpanel/templates/yum/repos.d/MariaDB102.tmpl.bak - 创建MariaDB10.6的模板文件
/var/cpanel/templates/yum/repos.d/MariaDB106.tmpl,内容如下:
[MariaDB106] name=MariaDB baseurl=https://yum.mariadb.org/10.6/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1 enabled=1
- 执行命令让WHM加载新模板:
/usr/local/cpanel/scripts/rebuild_yum_conf - 再次运行WHM的MySQL升级工具,选择MariaDB10.6完成升级
方法3:跳过WHM工具,手动执行升级
若WHM工具持续干扰repo配置,可绕过工具手动完成升级流程:
- 全量备份数据库:
mysqldump --all-databases > /root/all_databases_backup.sql - 停止并禁用当前MySQL服务:
systemctl stop mysql && systemctl disable mysql - 卸载现有MySQL5.7相关包:
yum remove mysql-server mysql-client mysql-common mysql-libs - 删除旧的MariaDB102 repo文件:
rm -f /etc/yum.repos.d/MariaDB102.repo - 添加MariaDB10.6 repo配置:
cat > /etc/yum.repos.d/MariaDB106.repo <<EOF [MariaDB106] name=MariaDB baseurl=https://yum.mariadb.org/10.6/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1 enabled=1 EOF
- 安装MariaDB10.6:
yum install MariaDB-server MariaDB-client MariaDB-common MariaDB-libs - 启动并启用服务:
systemctl start mariadb && systemctl enable mariadb - 运行数据库升级脚本:
mysql_upgrade -u root -p - 验证版本:
mysql -V
内容的提问来源于stack exchange,提问作者Jayjay95
相关产品推荐
相关产品推荐

