如何升级作为 docker 容器运行的 MariaDB [英] How to upgrade MariaDB running as a docker container

查看:47
本文介绍了如何升级作为 docker 容器运行的 MariaDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Docker 容器中运行 MariaDB 10.1,我想升级到 10.2.我的数据保存在/var/lib/mysql 映射到的卷中,my.cnf 未映射且未更改.正确的程序是什么最终得到一个包含完整数据的 Maria 10.2 容器?

I have MariaDB 10.1 running in a Docker container and I want to upgrade to 10.2. My data is persisted in a volume which /var/lib/mysql is mapped to, my.cnf, is not mapped and unchanged. What is the correct procedure to end up with a Maria 10.2 container with my data intact?

我考虑的过程如下:

  1. 停止 10.1 容器
  2. 复制数据量
  3. 创建一个新的 10.3 容器,将数据目录映射到复制的卷
  4. 启动新容器

我关心的是第 3 步.在标准"(非 Docker)升级期间,升级过程可能不会以某种方式改变数据目录吗?如果是这样,在升级期间应该对/var/lib/mysql 目录进行的任何更改都不会对卷进行,因为它在 Docker 外部.

My concern in this is step 3. During a 'standard' (non-Docker) upgrade, might the upgrade process not alter the data directory in some way? And if so, any changes that should be made to the /var/lib/mysql directory during upgrade would not be made to the volume, as its outside Docker.

我的程序正确吗?我的担心有道理吗?

Is my procedure correct? Is my concern justified?

推荐答案

MariaDB 文档确实从 10.1 ->10.2 文档 值得一读.

MariaDB documentation does have an upgrade from 10.1 -> 10.2 documentation that is worth reading.

虽然其中大部分是关于包升级,但是有一些关于可选的 SET GLOBAL innodb_fast_shutdown=0 并以 mysql_upgrade.

Although most of it is around package upgrades however there are some notes around an optional SET GLOBAL innodb_fast_shutdown=0 and finishing with mysql_upgrade.

docker volume inspect 查看挂载点并获取datadir 的副本是谨慎的,特别是如果您没有最近的备份或有快速恢复业务需求(但如果是这种情况,您应该使用从备份恢复和就地升级过程测试更高版本).

A docker volume inspect to look at the mountpoint and take a copy of the datadir is prudent, especially if you don't have recent backups or have a quick restoration business requirement (though if this is the case you should test the later version with a restore from backup and the inplace upgrade procedure).

在关闭之前没有 SET GLOBAL innodb_fast_shutdown=0 的就地升级将导致 innodb 开始恢复并将重做日志应用到数据目录.这样做的风险可能与之前有所不同.

An inplace upgrade without SET GLOBAL innodb_fast_shutdown=0 prior to shutdown will cause the innodb to begin recovery and apply the redo log to the datadir. There is small risk that this could be doing something differently to what it was doing before.

随着新容器的启动,您可以测试数据是否存在.准备好后,运行 mysql_upgrade(我通常会执行 docker exec -i {container} mysql_upgrade).这有望实现自动化(gh#350, MDEV-25670) 当我想到一个可靠的方法来做到这一点时.

With the new container started you can test the data exists. When you are ready, run the mysql_upgrade (I'd normally do docker exec -i {container} mysql_upgrade). This will hopefully be automated (gh#350, MDEV-25670) when I think of a reliable way to do this.

正如蒙蒂所说,你应该能够轻松地从任何早期的 MariaDB 版本升级到最新版本"(或任何中间值),所以不要觉得你必须 10.1 ->10.2 和最终 10.3.

As Monty says "You should be able to trivially upgrade from ANY earlier MariaDB version to the latest one" (or any intermediate one), so don't feel as though you have to 10.1 -> 10.2 and eventually 10.3.

这篇关于如何升级作为 docker 容器运行的 MariaDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆