由于drupal11依赖mariadb10.6以上版本,看了一下官网已经发布11.5的版本了,本地还是10.5,因此决定对现有的版本进行升级,直接升级到11.5版本。参考官方的指导文档,对mariadb的升级简单的做了一个总结。
1、备份全量数据库
sudo mariadb-backup --backup \
--user=mariabackup_user \
--password=mariabackup_passwd \
--target-dir=/data/backup/preupgrade_backup
sudo mariadb-backup --prepare \
--target-dir=/data/backup/preupgrade_backup
此处的user和password替换为真实的用户名和密码,建议使用root用户执行,避免权限问题引起各类问题。
2、创建mariadb软件源,注意:此处使用的为阿里镜像源
# MariaDB 11.5 CentOS repository list - created 2024-09-05 13:27 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
# rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# baseurl = https://rpm.mariadb.org/11.5/centos/$releasever/$basearch
baseurl = https://mirrors.aliyun.com/mariadb/yum/11.5/centos/$releasever/$basearch
# gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgkey = https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1
3、停止mariadb服务
sudo systemctl stop mariadb
4、卸载mariadb
sudo dnf remove mariadb
5、安装mariadb
sudo dnf install mariadb
6、升级mariadb文件目录
sudo mariadb-upgrade
若成功执行完上述命令,仍无法访问数据,或中途执行失败需要回退数据,可通过如下命令回退
sudo mariabackup –copy-back –target-dir=/data/backup/preupgrade_backup
参考文档:
https://mariadb.com/docs/server/service-management/upgrades/community-server/minor-release-cs10-6/
https://mariadb.com/docs/server/data-operations/backups/community-server/mariadb-backup/